ref: 64f7a2eae3fbe666241211487e22196fa5485100
parent: 348a691c6c7f6ae918ebdc861b43f74439606375
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Jul 30 22:52:43 EDT 2019
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
--- a/src/Backends/Rendering/OpenGL2.cpp
+++ b/src/Backends/Rendering/OpenGL2.cpp
@@ -428,7 +428,7 @@
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 @@
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 @@
for (unsigned int x = 0; x < width; ++x)
{
+ *destination_pointer++ = 0xFF;
*destination_pointer++ = *source_pointer++ ? 0xFF : 0;
}
}
@@ -473,7 +475,7 @@
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);