Skip to content

Commit db40bda

Browse files
committed
Merge branch 'docking' of github.com:ocornut/imgui into HEAD
2 parents 715f127 + 3f0699c commit db40bda

93 files changed

Lines changed: 8922 additions & 3951 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/issue_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ body:
44
- type: markdown
55
attributes:
66
value: |
7-
FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions)
7+
FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions)
88
For anything else: **we are happy to use 'GitHub Issues' for many types of open-ended questions**. We are encouraging 'Issues' becoming a large, centralized, tagged, cross-referenced database of Dear ImGui contents.
99
1010
Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.

.github/pull_request_template.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
1. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md)
44

5-
2. Clear this template before submitting your PR.
5+
2. Make sure you're using a special branch just for this pull request. (Sometimes people unknowingly use a default branch, then later update that branch, which updates the pull request with the other changes if it hasn't been merged yet.)
6+
7+
3. Clear this template before submitting your PR.
68

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ jobs:
218218
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
219219

220220
Linux:
221-
runs-on: ubuntu-24.04
221+
runs-on: ubuntu-latest
222222
steps:
223223
- uses: actions/checkout@v4
224224

@@ -516,7 +516,7 @@ jobs:
516516
xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
517517
518518
Emscripten:
519-
runs-on: ubuntu-24.04
519+
runs-on: ubuntu-latest
520520
steps:
521521
- uses: actions/checkout@v4
522522

@@ -557,7 +557,7 @@ jobs:
557557
cmake --build build
558558
559559
Android:
560-
runs-on: ubuntu-24.04
560+
runs-on: ubuntu-latest
561561
steps:
562562
- uses: actions/checkout@v4
563563

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
PVS-Studio:
13-
runs-on: ubuntu-22.04
13+
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
1616
with:

.gitignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ ipch
2929
## Getting files created in JSON/Schemas/Catalog/ from a VS2022 update
3030
JSON/
3131

32-
## Commonly used CMake directories
32+
## Commonly used CMake directories & CMake CPM cache
3333
build*/
34+
.cache
3435

35-
## Xcode artifacts
36+
## Xcode & macOS artifacts
3637
project.xcworkspace
3738
xcuserdata
39+
examples/*/*.dSYM
3840

3941
## Emscripten artifacts
4042
examples/*.o.tmp
@@ -53,12 +55,20 @@ cmake-build-*
5355
.vscode
5456

5557
## Unix executables from our example Makefiles
58+
examples/example_apple_metal/example_apple_metal
59+
examples/example_apple_opengl2/example_apple_opengl2
5660
examples/example_glfw_metal/example_glfw_metal
5761
examples/example_glfw_opengl2/example_glfw_opengl2
5862
examples/example_glfw_opengl3/example_glfw_opengl3
63+
examples/example_glfw_vulkan/example_glfw_vulkan
5964
examples/example_glut_opengl2/example_glut_opengl2
6065
examples/example_null/example_null
6166
examples/example_sdl2_metal/example_sdl2_metal
6267
examples/example_sdl2_opengl2/example_sdl2_opengl2
6368
examples/example_sdl2_opengl3/example_sdl2_opengl3
64-
examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer
69+
examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2
70+
examples/example_sdl2_vulkan/example_sdl2_vulkan
71+
examples/example_sdl3_opengl3/example_sdl3_opengl3
72+
examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3
73+
examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3
74+
examples/example_sdl3_vulkan/example_sdl3_vulkan

backends/imgui_impl_allegro5.cpp

Lines changed: 86 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
33

44
// Implemented features:
5-
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
5+
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
6+
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
67
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
78
// [X] Platform: Clipboard support (from Allegro 5.1.12).
89
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
@@ -21,6 +22,7 @@
2122

2223
// CHANGELOG
2324
// (minor and older changes stripped away, please see git history for details)
25+
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLGPU3_CreateFontsTexture() and ImGui_ImplSDLGPU3_DestroyFontsTexture().
2426
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
2527
// 2025-01-06: Avoid calling al_set_mouse_cursor() repeatedly since it appears to leak on on X11 (#8256).
2628
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
@@ -138,6 +140,13 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
138140
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
139141
return;
140142

143+
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
144+
// (This almost always points to ImGui::GetPlatformIO().Textures[] but is part of ImDrawData to allow overriding or disabling texture updates).
145+
if (draw_data->Textures != nullptr)
146+
for (ImTextureData* tex : *draw_data->Textures)
147+
if (tex->Status != ImTextureStatus_OK)
148+
ImGui_ImplAllegro5_UpdateTexture(tex);
149+
141150
// Backup Allegro state that will be modified
142151
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
143152
ALLEGRO_TRANSFORM last_transform = *al_get_current_transform();
@@ -233,43 +242,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
233242

234243
bool ImGui_ImplAllegro5_CreateDeviceObjects()
235244
{
236-
// Build texture atlas
237245
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
238-
ImGuiIO& io = ImGui::GetIO();
239-
unsigned char* pixels;
240-
int width, height;
241-
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
242-
243-
// Create texture
244-
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
245-
int flags = al_get_new_bitmap_flags();
246-
int fmt = al_get_new_bitmap_format();
247-
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
248-
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
249-
ALLEGRO_BITMAP* img = al_create_bitmap(width, height);
250-
al_set_new_bitmap_flags(flags);
251-
al_set_new_bitmap_format(fmt);
252-
if (!img)
253-
return false;
254-
255-
ALLEGRO_LOCKED_REGION* locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY);
256-
if (!locked_img)
257-
{
258-
al_destroy_bitmap(img);
259-
return false;
260-
}
261-
memcpy(locked_img->data, pixels, sizeof(int) * width * height);
262-
al_unlock_bitmap(img);
263-
264-
// Convert software texture to hardware texture.
265-
ALLEGRO_BITMAP* cloned_img = al_clone_bitmap(img);
266-
al_destroy_bitmap(img);
267-
if (!cloned_img)
268-
return false;
269-
270-
// Store our identifier
271-
io.Fonts->SetTexID((ImTextureID)(intptr_t)cloned_img);
272-
bd->Texture = cloned_img;
273246

274247
// Create an invisible mouse cursor
275248
// Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
@@ -280,16 +253,81 @@ bool ImGui_ImplAllegro5_CreateDeviceObjects()
280253
return true;
281254
}
282255

283-
void ImGui_ImplAllegro5_InvalidateDeviceObjects()
256+
void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex)
284257
{
285-
ImGuiIO& io = ImGui::GetIO();
286-
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
287-
if (bd->Texture)
258+
if (tex->Status == ImTextureStatus_WantCreate)
259+
{
260+
// Create and upload new texture to graphics system
261+
//IMGUI_DEBUG_LOG("UpdateTexture #%03d: WantCreate %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
262+
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
263+
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
264+
265+
// Create texture
266+
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
267+
const int new_bitmap_flags = al_get_new_bitmap_flags();
268+
int new_bitmap_format = al_get_new_bitmap_format();
269+
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
270+
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
271+
ALLEGRO_BITMAP* cpu_bitmap = al_create_bitmap(tex->Width, tex->Height);
272+
al_set_new_bitmap_flags(new_bitmap_flags);
273+
al_set_new_bitmap_format(new_bitmap_format);
274+
IM_ASSERT(cpu_bitmap != nullptr && "Backend failed to create texture!");
275+
276+
// Upload pixels
277+
ALLEGRO_LOCKED_REGION* locked_region = al_lock_bitmap(cpu_bitmap, al_get_bitmap_format(cpu_bitmap), ALLEGRO_LOCK_WRITEONLY);
278+
IM_ASSERT(locked_region != nullptr && "Backend failed to create texture!");
279+
memcpy(locked_region->data, tex->GetPixels(), tex->GetSizeInBytes());
280+
al_unlock_bitmap(cpu_bitmap);
281+
282+
// Convert software texture to hardware texture.
283+
ALLEGRO_BITMAP* gpu_bitmap = al_clone_bitmap(cpu_bitmap);
284+
al_destroy_bitmap(cpu_bitmap);
285+
IM_ASSERT(gpu_bitmap != nullptr && "Backend failed to create texture!");
286+
287+
// Store identifiers
288+
tex->SetTexID((ImTextureID)(intptr_t)gpu_bitmap);
289+
tex->SetStatus(ImTextureStatus_OK);
290+
}
291+
else if (tex->Status == ImTextureStatus_WantUpdates)
292+
{
293+
// Update selected blocks. We only ever write to textures regions which have never been used before!
294+
// This backend choose to use tex->Updates[] but you can use tex->UpdateRect to upload a single region.
295+
ImTextureRect r_bb = tex->UpdateRect; // Bounding box encompassing all individual updates
296+
ALLEGRO_BITMAP* gpu_bitmap = (ALLEGRO_BITMAP*)(intptr_t)tex->TexID;
297+
ALLEGRO_LOCKED_REGION* locked_region = al_lock_bitmap_region(gpu_bitmap, r_bb.x, r_bb.y, r_bb.w, r_bb.h, al_get_bitmap_format(gpu_bitmap), ALLEGRO_LOCK_WRITEONLY);
298+
IM_ASSERT(locked_region && "Backend failed to update texture!");
299+
for (ImTextureRect& r : tex->Updates)
300+
for (int y = 0; y < r.h; y++)
301+
memcpy((unsigned char*)locked_region->data + locked_region->pitch * (r.y - r_bb.y + y) + (r.x - r_bb.x) * tex->BytesPerPixel, // dst
302+
tex->GetPixelsAt(r.x, r.y + y), r.w * tex->BytesPerPixel); // src, block pitch
303+
al_unlock_bitmap(gpu_bitmap);
304+
tex->SetStatus(ImTextureStatus_OK);
305+
}
306+
else if (tex->Status == ImTextureStatus_WantDestroy)
288307
{
289-
io.Fonts->SetTexID(0);
290-
al_destroy_bitmap(bd->Texture);
291-
bd->Texture = nullptr;
308+
ALLEGRO_BITMAP* backend_tex = (ALLEGRO_BITMAP*)(intptr_t)tex->TexID;
309+
if (backend_tex)
310+
al_destroy_bitmap(backend_tex);
311+
312+
// Clear identifiers and mark as destroyed (in order to allow e.g. calling InvalidateDeviceObjects while running)
313+
tex->SetTexID(ImTextureID_Invalid);
314+
tex->SetStatus(ImTextureStatus_Destroyed);
292315
}
316+
}
317+
318+
void ImGui_ImplAllegro5_InvalidateDeviceObjects()
319+
{
320+
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
321+
322+
// Destroy all textures
323+
for (ImTextureData* tex : ImGui::GetPlatformIO().Textures)
324+
if (tex->RefCount == 1)
325+
{
326+
tex->SetStatus(ImTextureStatus_WantDestroy);
327+
ImGui_ImplAllegro5_UpdateTexture(tex);
328+
}
329+
330+
// Destroy mouse cursor
293331
if (bd->MouseCursorInvisible)
294332
{
295333
al_destroy_mouse_cursor(bd->MouseCursorInvisible);
@@ -440,6 +478,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
440478
io.BackendPlatformUserData = (void*)bd;
441479
io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5";
442480
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
481+
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
443482

444483
bd->Display = display;
445484
bd->LastCursor = ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE;
@@ -479,7 +518,7 @@ void ImGui_ImplAllegro5_Shutdown()
479518

480519
io.BackendPlatformName = io.BackendRendererName = nullptr;
481520
io.BackendPlatformUserData = nullptr;
482-
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseCursors;
521+
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_RendererHasTextures);
483522
IM_DELETE(bd);
484523
}
485524

@@ -609,12 +648,11 @@ void ImGui_ImplAllegro5_NewFrame()
609648
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
610649
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplAllegro5_Init()?");
611650

612-
if (!bd->Texture)
651+
if (!bd->MouseCursorInvisible)
613652
ImGui_ImplAllegro5_CreateDeviceObjects();
614653

615-
ImGuiIO& io = ImGui::GetIO();
616-
617654
// Setup display size (every frame to accommodate for window resizing)
655+
ImGuiIO& io = ImGui::GetIO();
618656
int w, h;
619657
w = al_get_display_width(bd->Display);
620658
h = al_get_display_height(bd->Display);

backends/imgui_impl_allegro5.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
33

44
// Implemented features:
5-
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
5+
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
6+
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
67
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
78
// [X] Platform: Clipboard support (from Allegro 5.1.12).
89
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
@@ -37,4 +38,7 @@ IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event);
3738
IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects();
3839
IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
3940

41+
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
42+
IMGUI_IMPL_API void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex);
43+
4044
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)