From 8eba5e2ed21c3a2a80417715db1bb524edbe965d Mon Sep 17 00:00:00 2001 From: jackun Date: Tue, 30 Jun 2020 02:03:21 +0300 Subject: [PATCH] [OpenGL] Use GL_R8 for font textures Randomly getting squares with GL_ALPHA for some reason --- src/gl/imgui_impl_opengl3.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gl/imgui_impl_opengl3.cpp b/src/gl/imgui_impl_opengl3.cpp index 38633d23..2103773b 100644 --- a/src/gl/imgui_impl_opengl3.cpp +++ b/src/gl/imgui_impl_opengl3.cpp @@ -125,14 +125,7 @@ static bool ImGui_ImplOpenGL3_CreateFontsTexture() if (g_IsGLES || g_GlVersion >= 200) glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - // FIXME can compress? - glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels); - -#ifndef NDEBUG - GLint compFlag= 0; - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &compFlag); - fprintf(stderr, "GL tex compressed: %s\n", compFlag ? "yes" : "no"); -#endif + glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width, height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); // Store our identifier io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; @@ -261,7 +254,7 @@ static bool ImGui_ImplOpenGL3_CreateDeviceObjects() "varying vec4 Frag_Color;\n" "void main()\n" "{\n" - " gl_FragColor = Frag_Color * vec4(1, 1, 1, texture2D(Texture, Frag_UV.st).a);\n" + " gl_FragColor = Frag_Color * vec4(1, 1, 1, texture2D(Texture, Frag_UV.st).r);\n" "}\n"; const GLchar* fragment_shader_glsl_130 = @@ -271,7 +264,7 @@ static bool ImGui_ImplOpenGL3_CreateDeviceObjects() "out vec4 Out_Color;\n" "void main()\n" "{\n" - " Out_Color = Frag_Color * vec4(1, 1, 1, texture(Texture, Frag_UV.st).a);\n" + " Out_Color = Frag_Color * vec4(1, 1, 1, texture(Texture, Frag_UV.st).r);\n" "}\n"; const GLchar* fragment_shader_glsl_300_es = @@ -282,7 +275,7 @@ static bool ImGui_ImplOpenGL3_CreateDeviceObjects() "layout (location = 0) out vec4 Out_Color;\n" "void main()\n" "{\n" - " Out_Color = Frag_Color * vec4(1, 1, 1, texture(Texture, Frag_UV.st).a);\n" + " Out_Color = Frag_Color * vec4(1, 1, 1, texture(Texture, Frag_UV.st).r);\n" "}\n"; const GLchar* fragment_shader_glsl_410_core = @@ -292,7 +285,7 @@ static bool ImGui_ImplOpenGL3_CreateDeviceObjects() "layout (location = 0) out vec4 Out_Color;\n" "void main()\n" "{\n" - " Out_Color = Frag_Color * vec4(1, 1, 1, texture(Texture, Frag_UV.st).a);\n" + " Out_Color = Frag_Color * vec4(1, 1, 1, texture(Texture, Frag_UV.st).r);\n" "}\n"; #ifndef NDEBUG