From 64f7a2eae3fbe666241211487e22196fa5485100 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 31 Jul 2019 02:52:43 +0000 Subject: [PATCH] Use GL_LUMINANCE_ALPHA instead of GL_ALPHA GL_ALPHA sets the RGB values to 0.0, but I want them set to 1.0 --- src/Backends/Rendering/OpenGL2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Backends/Rendering/OpenGL2.cpp b/src/Backends/Rendering/OpenGL2.cpp index bf34eb58..21327e5c 100644 --- a/src/Backends/Rendering/OpenGL2.cpp +++ b/src/Backends/Rendering/OpenGL2.cpp @@ -428,7 +428,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width if (glyph == NULL) return NULL; - const int destination_pitch = (width + 3) & ~3; // Round up to the nearest 4 (OpenGL needs this) + const int destination_pitch = ((width * 2) + 3) & ~3; // Round up to the nearest 4 (OpenGL needs this) unsigned char *buffer = (unsigned char*)malloc(destination_pitch * height); @@ -450,6 +450,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width for (unsigned int x = 0; x < width; ++x) { + *destination_pointer++ = 0xFF; *destination_pointer++ = (unsigned char)(pow((double)*source_pointer++ / (total_greys - 1), 1.0 / 1.8) * 255.0); } } @@ -464,6 +465,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width for (unsigned int x = 0; x < width; ++x) { + *destination_pointer++ = 0xFF; *destination_pointer++ = *source_pointer++ ? 0xFF : 0; } } @@ -473,7 +475,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width glGenTextures(1, &glyph->texture_id); glBindTexture(GL_TEXTURE_2D, glyph->texture_id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA8, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, buffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);