From 02399852fe18b37e883f7651a3590334fb228b24 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 10 Sep 2016 17:43:07 +0200 Subject: [PATCH] Examples: OpenGL2: Uploading font texture as RGBA32 to increase compatibility with users shaders for beginners (#824) --- examples/opengl2_example/imgui_impl_glfw.cpp | 4 ++-- examples/opengl3_example/imgui_impl_glfw_gl3.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/opengl2_example/imgui_impl_glfw.cpp b/examples/opengl2_example/imgui_impl_glfw.cpp index a9a64292f..cd8e60d41 100644 --- a/examples/opengl2_example/imgui_impl_glfw.cpp +++ b/examples/opengl2_example/imgui_impl_glfw.cpp @@ -161,7 +161,7 @@ bool ImGui_ImplGlfw_CreateDeviceObjects() ImGuiIO& io = ImGui::GetIO(); unsigned char* pixels; int width, height; - io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height); + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. // Upload texture to graphics system GLint last_texture; @@ -170,7 +170,7 @@ bool ImGui_ImplGlfw_CreateDeviceObjects() glBindTexture(GL_TEXTURE_2D, g_FontTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // Store our identifier io.Fonts->TexID = (void *)(intptr_t)g_FontTexture; diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index 03a4aa013..6552e5937 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -178,7 +178,7 @@ bool ImGui_ImplGlfwGL3_CreateFontsTexture() ImGuiIO& io = ImGui::GetIO(); unsigned char* pixels; int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader. + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. // Upload texture to graphics system GLint last_texture;