MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / copyAtlasPixels

Method copyAtlasPixels

source/application/StarRenderer_opengl.cpp:698–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

696}
697
698void 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
719OpenGlRenderer::GlTextureGroup::GlTextureGroup(unsigned atlasNumCells)
720 : textureAtlasSet(atlasNumCells) {}

Callers

nothing calls this directly

Calls 4

pixelFormatMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected