| 361 | } |
| 362 | |
| 363 | static void drawOpenGLImage(const OpenGLImage& image, const Point<int>& pos, const GLuint textureId, bool& setupCalled) |
| 364 | { |
| 365 | if (textureId == 0 || image.isInvalid()) |
| 366 | return; |
| 367 | |
| 368 | if (! setupCalled) |
| 369 | { |
| 370 | setupOpenGLImage(image, textureId); |
| 371 | setupCalled = true; |
| 372 | } |
| 373 | |
| 374 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
| 375 | |
| 376 | glEnable(GL_TEXTURE_2D); |
| 377 | glBindTexture(GL_TEXTURE_2D, textureId); |
| 378 | |
| 379 | glBegin(GL_QUADS); |
| 380 | |
| 381 | { |
| 382 | const int x = pos.getX(); |
| 383 | const int y = pos.getY(); |
| 384 | const int w = static_cast<int>(image.getWidth()); |
| 385 | const int h = static_cast<int>(image.getHeight()); |
| 386 | |
| 387 | glTexCoord2f(0.0f, 0.0f); |
| 388 | glVertex2d(x, y); |
| 389 | |
| 390 | glTexCoord2f(1.0f, 0.0f); |
| 391 | glVertex2d(x+w, y); |
| 392 | |
| 393 | glTexCoord2f(1.0f, 1.0f); |
| 394 | glVertex2d(x+w, y+h); |
| 395 | |
| 396 | glTexCoord2f(0.0f, 1.0f); |
| 397 | glVertex2d(x, y+h); |
| 398 | } |
| 399 | |
| 400 | glEnd(); |
| 401 | |
| 402 | glBindTexture(GL_TEXTURE_2D, 0); |
| 403 | glDisable(GL_TEXTURE_2D); |
| 404 | } |
| 405 | |
| 406 | void OpenGLImage::drawAt(const GraphicsContext&, const Point<int>& pos) |
| 407 | { |