Skip to content

Commit

Permalink
convert textures to rgba for vulkan
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Adenis-Lamarre <[email protected]>
  • Loading branch information
nadenislamarre committed Dec 16, 2021
1 parent 1d5ad5d commit 7f5a81c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/overlay.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
10 changes: 5 additions & 5 deletions src/vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,16 +685,16 @@ static void check_fonts(struct swapchain_data* data)
create_fonts(instance_data->params, data->sw_stats.font1, data->sw_stats.font_text);
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);

// wait for rendering to complete, if any
device_data->vtable.DeviceWaitIdle(device_data->device);
shutdown_swapchain_font(data);

if (desc_set)
create_image(data, desc_set, width, height, VK_FORMAT_R8_UNORM, data->font_image, data->font_mem, data->font_image_view);
create_image(data, desc_set, width, height, VK_FORMAT_R8G8B8A8_SRGB, data->font_image, data->font_mem, data->font_image_view);
else
desc_set = create_image_with_desc(data, width, height, VK_FORMAT_R8_UNORM, data->font_image, data->font_mem, data->font_image_view);
desc_set = create_image_with_desc(data, width, height, VK_FORMAT_R8G8B8A8_SRGB, data->font_image, data->font_mem, data->font_image_view);

io.Fonts->SetTexID((ImTextureID)desc_set);
data->font_uploaded = false;
Expand All @@ -717,8 +717,8 @@ static void ensure_swapchain_fonts(struct swapchain_data *data,
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
size_t upload_size = width * height * 1 * sizeof(char);
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
size_t upload_size = width * height * 4 * sizeof(char);
upload_image_data(device_data, command_buffer, pixels, upload_size, width, height, data->upload_font_buffer, data->upload_font_buffer_mem, data->font_image);
}

Expand Down

0 comments on commit 7f5a81c

Please sign in to comment.