| 696 | } |
| 697 | |
| 698 | void OpenGlRenderer::GlTextureAtlasSet::copyAtlasPixels( |
| 699 | GLuint const& glTexture, Vec2U const& bottomLeft, Image const& image) { |
| 700 | glBindTexture(GL_TEXTURE_2D, glTexture); |
| 701 | |
| 702 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 703 | GLenum format; |
| 704 | auto pixelFormat = image.pixelFormat(); |
| 705 | if (pixelFormat == PixelFormat::RGB24) |
| 706 | format = GL_RGB; |
| 707 | else if (pixelFormat == PixelFormat::RGBA32) |
| 708 | format = GL_RGBA; |
| 709 | else if (pixelFormat == PixelFormat::BGR24) |
| 710 | format = GL_BGR; |
| 711 | else if (pixelFormat == PixelFormat::BGRA32) |
| 712 | format = GL_BGRA; |
| 713 | else |
| 714 | throw RendererException("Unsupported texture format in OpenGlRenderer::TextureGroup::copyAtlasPixels"); |
| 715 | |
| 716 | glTexSubImage2D(GL_TEXTURE_2D, 0, bottomLeft[0], bottomLeft[1], image.width(), image.height(), format, GL_UNSIGNED_BYTE, image.data()); |
| 717 | } |
| 718 | |
| 719 | OpenGlRenderer::GlTextureGroup::GlTextureGroup(unsigned atlasNumCells) |
| 720 | : textureAtlasSet(atlasNumCells) {} |
nothing calls this directly
no test coverage detected