convert textures to rgba

images textures need rgba (to load alpha for example for decorations).
thus, this commit globally convert gl textures in rgba

Signed-off-by: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>
pr-642
Nicolas Adenis-Lamarre 3 years ago committed by jackun
parent 3963a451d3
commit 882f44f5ee
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -109,7 +109,7 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture()
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// Upload texture to graphics system
GLint last_texture;
@ -122,7 +122,7 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture()
if (g_IsGLES || g_GlVersion >= 200)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width, height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
// Store our identifier
io.Fonts->SetTexID((ImTextureID)(intptr_t)g_FontTexture);
@ -261,7 +261,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).r);\n"
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
"}\n";
const GLchar* fragment_shader_glsl_300_es =
@ -272,7 +272,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).r);\n"
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
"}\n";
const GLchar* fragment_shader_glsl_410_core =
@ -282,7 +282,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).r);\n"
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
"}\n";
#ifndef NDEBUG

@ -10,5 +10,5 @@ layout(location = 0) in struct{
void main()
{
fColor = In.Color * vec4(1, 1, 1, texture(sTexture, In.UV.st).r);
fColor = In.Color * texture(sTexture, In.UV.st);
}

@ -832,20 +832,20 @@ static void check_fonts(struct device_data* device_data)
unsigned char* pixels;
int width, height;
device_data->font_atlas->GetTexDataAsAlpha8(&pixels, &width, &height);
device_data->font_atlas->GetTexDataAsRGBA32(&pixels, &width, &height);
// wait for rendering to complete, if any
VK_CHECK(device_data->vtable.DeviceWaitIdle(device_data->device));
shutdown_device_font(device_data);
create_image(device_data, width, height, VK_FORMAT_R8_UNORM, device_data->font_img);
create_image(device_data, width, height, VK_FORMAT_R8G8B8A8_UNORM, device_data->font_img);
SPDLOG_DEBUG("Default font tex size: {}x{}px", width, height);
SPDLOG_DEBUG("Update font image descriptor {}", (void*)device_data->descriptor_set);
update_image_descriptor(device_data, device_data->font_img.image_view, device_data->descriptor_set);
device_data->font_atlas->SetTexID((ImTextureID)device_data->descriptor_set);
std::thread(submit_image_upload_cmd, device_data, &device_data->font_img, pixels, width * height * 1 * sizeof(char)).detach();
// submit_image_upload_cmd(device_data, &device_data->font_img, pixels, width * height * 1 * sizeof(char));
std::thread(submit_image_upload_cmd, device_data, &device_data->font_img, pixels, width * height * 4 * sizeof(char)).detach();
// submit_image_upload_cmd(device_data, &device_data->font_img, pixels, width * height * 4 * sizeof(char));
}
static void check_fonts(struct swapchain_data* data)

Loading…
Cancel
Save