Skip to content

Commit aa23f38

Browse files
Daniel K. O. (dkosmari)ocornut
authored andcommitted
Backends: SDL_Renderer2/3: Use endian-dependent RGBA32 texture format, to match SDL_Color. (ocornut#8327)
1 parent 80c9cd1 commit aa23f38

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

backends/imgui_impl_sdlrenderer2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// - Introduction, links and more at the top of imgui.cpp
2222

2323
// CHANGELOG
24+
// 2025-01-18: Use endian-dependent RGBA32 texture format, to match SDL_Color.
2425
// 2024-10-09: Expose selected render state in ImGui_ImplSDLRenderer2_RenderState, which you can access in 'void* platform_io.Renderer_RenderState' during draw callbacks.
2526
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
2627
// 2023-05-30: Renamed imgui_impl_sdlrenderer.h/.cpp to imgui_impl_sdlrenderer2.h/.cpp to accommodate for upcoming SDL3.
@@ -228,7 +229,7 @@ bool ImGui_ImplSDLRenderer2_CreateFontsTexture()
228229

229230
// Upload texture to graphics system
230231
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
231-
bd->FontTexture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
232+
bd->FontTexture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, width, height);
232233
if (bd->FontTexture == nullptr)
233234
{
234235
SDL_Log("error creating texture");

backends/imgui_impl_sdlrenderer3.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// - Introduction, links and more at the top of imgui.cpp
2424

2525
// CHANGELOG
26+
// 2025-01-18: Use endian-dependent RGBA32 texture format, to match SDL_Color.
2627
// 2024-10-09: Expose selected render state in ImGui_ImplSDLRenderer3_RenderState, which you can access in 'void* platform_io.Renderer_RenderState' during draw callbacks.
2728
// 2024-07-01: Update for SDL3 api changes: SDL_RenderGeometryRaw() uint32 version was removed (SDL#9009).
2829
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
@@ -247,7 +248,7 @@ bool ImGui_ImplSDLRenderer3_CreateFontsTexture()
247248

248249
// Upload texture to graphics system
249250
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
250-
bd->FontTexture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
251+
bd->FontTexture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, width, height);
251252
if (bd->FontTexture == nullptr)
252253
{
253254
SDL_Log("error creating texture");

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Other changes:
6060
vkAcquireNextImageKHR() or vkQueuePresentKHR(). (#7825, #7831) [@NostraMagister]
6161
- Backends: SDLGPU3: Exposed ImGui_ImplSDLGPU3_CreateDeviceObjects()/_DestroyDeviceObjects().
6262
Removed return value from ImGui_ImplSDLGPU3_CreateFontsTexture(). (#8163, #7998, #7988)
63+
- Backends: SDL_Renderer2/3: Use endian-dependent RGBA32 texture format, to match
64+
SDL_Color. (#8327) [@dkosmari]
6365
- Backends: DirectX12: Texture upload use the command queue provided in
6466
ImGui_ImplDX12_InitInfo instead of creating its own.
6567

0 commit comments

Comments
 (0)