Skip to content

Commit

Permalink
[update #103] imgui v1.91.7
Browse files Browse the repository at this point in the history
  • Loading branch information
tiawl authored Jan 15, 2025
2 parents 9fdff17 + 4f16101 commit f05c0ab
Show file tree
Hide file tree
Showing 31 changed files with 2,059 additions and 648 deletions.
2 changes: 1 addition & 1 deletion .references/imgui
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.91.6
v1.91.7
14 changes: 14 additions & 0 deletions dcimgui/backends/cimgui_impl_dx10.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

// Auto-generated forward declarations for C header
typedef struct ImGui_ImplDX10_RenderState_t ImGui_ImplDX10_RenderState;
#pragma once

#ifdef __cplusplus
Expand All @@ -26,6 +28,8 @@ extern "C"
#include "dcimgui.h"
#ifndef IMGUI_DISABLE
typedef struct ID3D10Device_t ID3D10Device;
typedef struct ID3D10SamplerState_t ID3D10SamplerState;
typedef struct ID3D10Buffer_t ID3D10Buffer;

typedef struct ImDrawData_t ImDrawData;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
Expand All @@ -37,6 +41,16 @@ CIMGUI_IMPL_API void cImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing Dear ImGui state.
CIMGUI_IMPL_API bool cImGui_ImplDX10_CreateDeviceObjects(void);
CIMGUI_IMPL_API void cImGui_ImplDX10_InvalidateDeviceObjects(void);

// [BETA] Selected render state data shared with callbacks.
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplDX10_RenderDrawData() call.
// (Please open an issue if you feel you need access to more data)
struct ImGui_ImplDX10_RenderState_t
{
ID3D10Device* Device;
ID3D10SamplerState* SamplerDefault;
ID3D10Buffer* VertexConstantBuffer;
};
#endif// #ifndef IMGUI_DISABLE
#ifdef __cplusplus
} // End of extern "C" block
Expand Down
2 changes: 2 additions & 0 deletions dcimgui/backends/cimgui_impl_dx11.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern "C"
typedef struct ID3D11Device ID3D11Device;
typedef struct ID3D11DeviceContext ID3D11DeviceContext;
typedef struct ID3D11SamplerState_t ID3D11SamplerState;
typedef struct ID3D11Buffer_t ID3D11Buffer;

typedef struct ImDrawData_t ImDrawData;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
Expand All @@ -51,6 +52,7 @@ struct ImGui_ImplDX11_RenderState_t
ID3D11Device* Device;
ID3D11DeviceContext* DeviceContext;
ID3D11SamplerState* SamplerDefault;
ID3D11Buffer* VertexConstantBuffer;
};
#endif// #ifndef IMGUI_DISABLE
#ifdef __cplusplus
Expand Down
5 changes: 5 additions & 0 deletions dcimgui/backends/cimgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForSDLRenderer(cimgui::SDL_Wind
return ::ImGui_ImplSDL3_InitForSDLRenderer(reinterpret_cast<::SDL_Window*>(window), reinterpret_cast<::SDL_Renderer*>(renderer));
}

CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForSDLGPU(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForSDLGPU(reinterpret_cast<::SDL_Window*>(window));
}

CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForOther(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForOther(reinterpret_cast<::SDL_Window*>(window));
Expand Down
1 change: 1 addition & 0 deletions dcimgui/backends/cimgui_impl_sdl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForD3D(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForMetal(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForSDLGPU(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForOther(SDL_Window* window);
CIMGUI_IMPL_API void cImGui_ImplSDL3_Shutdown(void);
CIMGUI_IMPL_API void cImGui_ImplSDL3_NewFrame(void);
Expand Down
10 changes: 10 additions & 0 deletions dcimgui/backends/cimgui_impl_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ CIMGUI_IMPL_API VkPresentModeKHR cimgui::cImGui_ImplVulkanH_SelectPresentMode(Vk
return ::ImGui_ImplVulkanH_SelectPresentMode(physical_device, surface, request_modes, request_modes_count);
}

CIMGUI_IMPL_API VkPhysicalDevice cimgui::cImGui_ImplVulkanH_SelectPhysicalDevice(VkInstance instance)
{
return ::ImGui_ImplVulkanH_SelectPhysicalDevice(instance);
}

CIMGUI_IMPL_API uint32_t cimgui::cImGui_ImplVulkanH_SelectQueueFamilyIndex(VkPhysicalDevice physical_device)
{
return ::ImGui_ImplVulkanH_SelectQueueFamilyIndex(physical_device);
}

CIMGUI_IMPL_API int cimgui::cImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode)
{
return ::ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(present_mode);
Expand Down
24 changes: 17 additions & 7 deletions dcimgui/backends/cimgui_impl_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ extern "C"
#if defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
#endif // #if defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)
// Current version of the backend use 1 descriptor for the font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
// It is expected that as early as Q1 2025 the backend will use a few more descriptors. Use this value + number of desired calls to ImGui_ImplVulkan_AddTexture().
#define IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE (1) // Minimum per atlas

// Initialization data, for ImGui_ImplVulkan_Init()
// [Please zero-clear before use!]
// - About descriptor pool:
// - A VkDescriptorPool should be created with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
// and must contain a pool size large enough to hold a small number of VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptors.
// - As an convenience, by setting DescriptorPoolSize > 0 the backend will create one for you.
// - Current version of the backend use 1 descriptor for the font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
// - It is expected that as early as Q1 2025 the backend will use a few more descriptors, so aim at 10 + number of desierd calls to ImGui_ImplVulkan_AddTexture().
// - About dynamic rendering:
// - When using dynamic rendering, set UseDynamicRendering=true and fill PipelineRenderingCreateInfo structure.
struct ImGui_ImplVulkan_InitInfo_t
Expand Down Expand Up @@ -147,18 +149,24 @@ struct ImGui_ImplVulkan_RenderState_t

//-------------------------------------------------------------------------
// Internal / Miscellaneous Vulkan Helpers
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
//-------------------------------------------------------------------------
// Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.
//
// You probably do NOT need to use or care about those functions.
// Those functions only exist because:
// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
// 2) the multi-viewport / platform window implementation needs them internally.
// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings,
// Generally we avoid exposing any kind of superfluous high-level helpers in the backends,
// but it is too much code to duplicate everywhere so we exceptionally expose them.
//
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain,
// render pass, frame buffers, etc.). You may read this code if you are curious, but
// it is recommended you use you own custom tailored code to do equivalent work.
//
// We don't provide a strong guarantee that we won't change those functions API.
//
// The ImGui_ImplVulkanH_XXX functions should NOT interact with any of the state used
// by the regular ImGui_ImplVulkan_XXX functions).
//-------------------------------------------------------------------------

typedef struct ImGui_ImplVulkanH_Frame_t ImGui_ImplVulkanH_Frame;
Expand All @@ -169,6 +177,8 @@ CIMGUI_IMPL_API void cImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance
CIMGUI_IMPL_API void cImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
CIMGUI_IMPL_API VkSurfaceFormatKHR cImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
CIMGUI_IMPL_API VkPresentModeKHR cImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
CIMGUI_IMPL_API VkPhysicalDevice cImGui_ImplVulkanH_SelectPhysicalDevice(VkInstance instance);
CIMGUI_IMPL_API uint32_t cImGui_ImplVulkanH_SelectQueueFamilyIndex(VkPhysicalDevice physical_device);
CIMGUI_IMPL_API int cImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);

// Helper structure to hold the data needed by one rendering frame
Expand Down
14 changes: 12 additions & 2 deletions dcimgui/backends/imgui_impl_allegro5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-01-06: Avoid calling al_set_mouse_cursor() repeatedly since it appears to leak on on X11 (#8256).
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
Expand Down Expand Up @@ -95,6 +96,7 @@ struct ImGui_ImplAllegro5_Data
ALLEGRO_MOUSE_CURSOR* MouseCursorInvisible;
ALLEGRO_VERTEX_DECL* VertexDecl;
char* ClipboardTextData;
ImGuiMouseCursor LastCursor;

ImVector<ImDrawVertAllegro> BufVertices;
ImVector<int> BufIndices;
Expand Down Expand Up @@ -438,6 +440,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)

bd->Display = display;
bd->LastCursor = ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE;

// Create custom vertex declaration.
// Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 floats.
Expand Down Expand Up @@ -568,9 +571,16 @@ static void ImGui_ImplAllegro5_UpdateMouseCursor()

ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)

// Hide OS mouse cursor if imgui is drawing it
if (io.MouseDrawCursor)
imgui_cursor = ImGuiMouseCursor_None;

if (bd->LastCursor == imgui_cursor)
return;
bd->LastCursor = imgui_cursor;
if (imgui_cursor == ImGuiMouseCursor_None)
{
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
al_set_mouse_cursor(bd->Display, bd->MouseCursorInvisible);
}
else
Expand Down
56 changes: 32 additions & 24 deletions dcimgui/backends/imgui_impl_dx10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-01-06: DirectX10: Expose selected render state in ImGui_ImplDX10_RenderState, which you can access in 'void* platform_io.Renderer_RenderState' during draw callbacks.
// 2024-10-07: DirectX10: Changed default texture sampler to Clamp instead of Repeat/Wrap.
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
Expand Down Expand Up @@ -95,7 +96,28 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
vp.TopLeftX = vp.TopLeftY = 0;
device->RSSetViewports(1, &vp);

// Bind shader and vertex buffers
// Setup orthographic projection matrix into our constant buffer
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
void* mapped_resource;
if (bd->pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) == S_OK)
{
VERTEX_CONSTANT_BUFFER_DX10* constant_buffer = (VERTEX_CONSTANT_BUFFER_DX10*)mapped_resource;
float L = draw_data->DisplayPos.x;
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
float T = draw_data->DisplayPos.y;
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
float mvp[4][4] =
{
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.5f, 0.0f },
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
};
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
bd->pVertexConstantBuffer->Unmap();
}

// Setup shader and vertex buffers
unsigned int stride = sizeof(ImDrawVert);
unsigned int offset = 0;
device->IASetInputLayout(bd->pInputLayout);
Expand Down Expand Up @@ -171,28 +193,6 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
bd->pVB->Unmap();
bd->pIB->Unmap();

// Setup orthographic projection matrix into our constant buffer
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
{
void* mapped_resource;
if (bd->pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
return;
VERTEX_CONSTANT_BUFFER_DX10* constant_buffer = (VERTEX_CONSTANT_BUFFER_DX10*)mapped_resource;
float L = draw_data->DisplayPos.x;
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
float T = draw_data->DisplayPos.y;
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
float mvp[4][4] =
{
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.5f, 0.0f },
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
};
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
bd->pVertexConstantBuffer->Unmap();
}

// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
struct BACKUP_DX10_STATE
{
Expand Down Expand Up @@ -236,6 +236,13 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)

// Setup desired DX state
ImGui_ImplDX10_SetupRenderState(draw_data, device);
// Setup render state structure (for callbacks and custom texture bindings)
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
ImGui_ImplDX10_RenderState render_state;
render_state.Device = bd->pd3dDevice;
render_state.SamplerDefault = bd->pFontSampler;
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
platform_io.Renderer_RenderState = &render_state;

// Render command lists
// (Because we merged all buffers into a single one, we maintain our own offset into them)
Expand All @@ -248,7 +255,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
if (pcmd->UserCallback != nullptr)
{
// User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
Expand Down Expand Up @@ -278,6 +285,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
global_idx_offset += draw_list->IdxBuffer.Size;
global_vtx_offset += draw_list->VtxBuffer.Size;
}
platform_io.Renderer_RenderState = nullptr;

// Restore modified DX state
device->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
Expand Down
12 changes: 12 additions & 0 deletions dcimgui/backends/imgui_impl_dx10.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef IMGUI_DISABLE

struct ID3D10Device;
struct ID3D10SamplerState;
struct ID3D10Buffer;

// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device);
Expand All @@ -29,4 +31,14 @@ IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();

// [BETA] Selected render state data shared with callbacks.
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplDX10_RenderDrawData() call.
// (Please open an issue if you feel you need access to more data)
struct ImGui_ImplDX10_RenderState
{
ID3D10Device* Device;
ID3D10SamplerState* SamplerDefault;
ID3D10Buffer* VertexConstantBuffer;
};

#endif // #ifndef IMGUI_DISABLE
Loading

0 comments on commit f05c0ab

Please sign in to comment.