From 4bad852a785d6361ab0744c28f3ca3dbb847a8fc Mon Sep 17 00:00:00 2001 From: Sean Ridenour Date: Mon, 20 Dec 2021 21:27:48 -0700 Subject: [PATCH] Backends: SDL_Renderer: Handle change to SDL_RenderGeometryRaw() function signature in SDL 2.0.19 (#4819) --- backends/imgui_impl_sdlrenderer.cpp | 7 ++++++- docs/CHANGELOG.txt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_sdlrenderer.cpp b/backends/imgui_impl_sdlrenderer.cpp index 1aab5b48..ca4c432f 100644 --- a/backends/imgui_impl_sdlrenderer.cpp +++ b/backends/imgui_impl_sdlrenderer.cpp @@ -18,6 +18,7 @@ // Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG +// 2021-12-21: Update SDL_RenderGeometryRaw() format to work with SDL 2.0.19. // 2021-12-03: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. // 2021-10-06: Backup and restore modified ClipRect/Viewport. // 2021-09-21: Initial version. @@ -174,7 +175,11 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data) const float* xy = (const float*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, pos)); const float* uv = (const float*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, uv)); - const int* color = (const int*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, col)); +#if SDL_VERSION_ATLEAST(2,0,19) + const SDL_Color* color = (const SDL_Color*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, col)); // SDL 2.0.19+ +#else + const int* color = (const int*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, col)); // SDL 2.0.17 and 2.0.18 +#endif // Bind texture, Draw SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID(); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f02157bb..9caacb13 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -117,6 +117,7 @@ Other Changes: - Backends: DX12: Fixed DRAW_EMPTY_SCISSOR_RECTANGLE warnings. (#4775) - Backends: SDL_Renderer: Added support for large meshes (64k+ vertices) with 16-bit indices, enabling 'ImGuiBackendFlags_RendererHasVtxOffset' in the backend. (#3926) [@rokups] +- Backends: SDL_Renderer: Fix for SDL 2.0.19+ RenderGeometryRaw() API signature change. (#4819) [@sridenour] - Backends: OSX: Generally fix keyboard support. Keyboard arrays indexed using kVK_* codes, e.g. ImGui::IsKeyPressed(kVK_Space). Don't set mouse cursor shape unconditionally. Handle two fingers scroll cancel event. (#4759, #4253, #1873) [@stuartcarnie]