From e1baadba8498e4e0159145cf2f0d63de32a4544d Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 12 Aug 2025 15:02:58 +0200 Subject: [PATCH] Backends: Allegro5: Fixed texture format setup. (#8770, #8465) Amend/fix ee8941e. --- backends/imgui_impl_allegro5.cpp | 9 ++++++--- docs/CHANGELOG.txt | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backends/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp index 554588a4b..7b92ab54b 100644 --- a/backends/imgui_impl_allegro5.cpp +++ b/backends/imgui_impl_allegro5.cpp @@ -268,8 +268,6 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex) al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE); ALLEGRO_BITMAP* cpu_bitmap = al_create_bitmap(tex->Width, tex->Height); - al_set_new_bitmap_flags(new_bitmap_flags); - al_set_new_bitmap_format(new_bitmap_format); IM_ASSERT(cpu_bitmap != nullptr && "Backend failed to create texture!"); // Upload pixels @@ -279,10 +277,15 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex) al_unlock_bitmap(cpu_bitmap); // Convert software texture to hardware texture. + al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); + al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA); ALLEGRO_BITMAP* gpu_bitmap = al_clone_bitmap(cpu_bitmap); al_destroy_bitmap(cpu_bitmap); IM_ASSERT(gpu_bitmap != nullptr && "Backend failed to create texture!"); + al_set_new_bitmap_flags(new_bitmap_flags); + al_set_new_bitmap_format(new_bitmap_format); + // Store identifiers tex->SetTexID((ImTextureID)(intptr_t)gpu_bitmap); tex->SetStatus(ImTextureStatus_OK); @@ -521,7 +524,7 @@ void ImGui_ImplAllegro5_SetDisplay(ALLEGRO_DISPLAY* display) if (bd->Display && !bd->VertexDecl) { - // Create custom vertex declaration. + // Create custom vertex declaration. // Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats. // We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion. ALLEGRO_VERTEX_ELEMENT elems[] = diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 0477f3491..c0e2b8414 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -43,6 +43,8 @@ Breaking Changes: Other Changes: +- Backends: Allegro5: Fixed texture format setup which didn't work on all + setups/drivers. (#8770, #8465) - Backends: Allegro5: Added ImGui_ImplAllegro5_SetDisplay() function to change current ALLEGRO_DISPLAY, as Allegro applications often need to do that.