| 449 | // OpenGLImage |
| 450 | |
| 451 | static void setupOpenGLImage(const OpenGLImage& image, GLuint textureId) |
| 452 | { |
| 453 | DISTRHO_SAFE_ASSERT_RETURN(image.isValid(),); |
| 454 | |
| 455 | const ImageFormat imageFormat = image.getFormat(); |
| 456 | GLint intformat; |
| 457 | |
| 458 | #ifdef DGL_USE_GLES |
| 459 | // GLES does not support BGR |
| 460 | DISTRHO_SAFE_ASSERT_RETURN(imageFormat != kImageFormatBGR && imageFormat != kImageFormatBGRA,); |
| 461 | #endif |
| 462 | |
| 463 | glBindTexture(GL_TEXTURE_2D, textureId); |
| 464 | |
| 465 | switch (imageFormat) |
| 466 | { |
| 467 | case kImageFormatBGR: |
| 468 | case kImageFormatRGB: |
| 469 | intformat = GL_RGB; |
| 470 | break; |
| 471 | case kImageFormatGrayscale: |
| 472 | #ifdef DGL_USE_GLES2 |
| 473 | intformat = GL_LUMINANCE; |
| 474 | #else |
| 475 | intformat = GL_RED; |
| 476 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED); |
| 477 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); |
| 478 | #endif |
| 479 | break; |
| 480 | default: |
| 481 | intformat = GL_RGBA; |
| 482 | break; |
| 483 | } |
| 484 | |
| 485 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 486 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 487 | |
| 488 | #ifndef DGL_USE_GLES |
| 489 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 490 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 491 | |
| 492 | static const float trans[] = { 0.0f, 0.0f, 0.0f, 0.0f }; |
| 493 | glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, trans); |
| 494 | #endif |
| 495 | |
| 496 | glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 497 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 498 | |
| 499 | glTexImage2D(GL_TEXTURE_2D, |
| 500 | 0, |
| 501 | intformat, |
| 502 | static_cast<GLsizei>(image.getWidth()), |
| 503 | static_cast<GLsizei>(image.getHeight()), |
| 504 | 0, |
| 505 | asOpenGLImageFormat(imageFormat), |
| 506 | GL_UNSIGNED_BYTE, |
| 507 | image.getRawData()); |
| 508 |
no test coverage detected