Get OpenGL renderers working again
This commit is contained in:
parent
2b848ad16e
commit
86d084f750
1 changed files with 20 additions and 10 deletions
|
@ -923,17 +923,27 @@ void RenderBackend_DestroyGlyphAtlas(RenderBackend_GlyphAtlas *atlas)
|
||||||
free(atlas);
|
free(atlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height)
|
void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height, size_t pitch)
|
||||||
{
|
{
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
unsigned char *buffer = (unsigned char*)malloc(width * height);
|
||||||
glBindTexture(GL_TEXTURE_2D, atlas->texture_id);
|
|
||||||
#ifdef USE_OPENGLES2
|
if (buffer != NULL)
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels);
|
{
|
||||||
#else
|
for (size_t y = 0; y < height; ++y)
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RED, GL_UNSIGNED_BYTE, pixels);
|
memcpy (&buffer[y * width], &pixels[y * pitch], width);
|
||||||
#endif
|
|
||||||
glBindTexture(GL_TEXTURE_2D, last_source_texture);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
glBindTexture(GL_TEXTURE_2D, atlas->texture_id);
|
||||||
|
#ifdef USE_OPENGLES2
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
#else
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RED, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
#endif
|
||||||
|
glBindTexture(GL_TEXTURE_2D, last_source_texture);
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
|
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
|
|
Loading…
Add table
Reference in a new issue