Adding sdl2 and sdl3 SDL_Renderer backend#59
Conversation
This commit might be directly incompatible with zig-gamedev#51
There was a problem hiding this comment.
Pull Request Overview
This PR adds SDL_Renderer backend support for both SDL2 and SDL3, expanding the library's rendering capabilities beyond OpenGL and other graphics APIs. The changes provide a complete implementation of SDL_Renderer-based backends that can be used as alternatives to OpenGL when simpler 2D rendering is sufficient.
Key changes:
- Adds new backend options
.sdl2_rendererand.sdl3_rendererto the existing backend enum - Implements complete SDL_Renderer backend modules for both SDL2 and SDL3
- Includes corresponding Dear ImGui C++ implementation files for SDL_Renderer backends
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/gui.zig | Adds backend enum cases for sdl2_renderer and sdl3_renderer |
| src/backend_sdl2_renderer.zig | New SDL2 renderer backend implementation with init, event processing, and drawing functions |
| src/backend_sdl3_renderer.zig | New SDL3 renderer backend implementation with similar API to SDL2 version |
| src/backend_sdl2.zig | Adds initRenderer function to support SDL_Renderer initialization |
| src/backend_sdl3.zig | Adds initRenderer function and moves TODO comment for SDL_Renderer to implemented extern |
| libs/imgui/backends/imgui_impl_sdlrenderer2.h | Header file for SDL2 renderer backend with C API declarations |
| libs/imgui/backends/imgui_impl_sdlrenderer2.cpp | Complete SDL2 renderer implementation with device object management |
| libs/imgui/backends/imgui_impl_sdlrenderer3.h | Header file for SDL3 renderer backend with C API declarations |
| libs/imgui/backends/imgui_impl_sdlrenderer3.cpp | Complete SDL3 renderer implementation with updated SDL3 API usage |
| libs/imgui/backends/imgui_impl_sdl2.cpp | Adds extern C declaration for SDL_Renderer initialization function |
| build.zig | Adds build configuration for both sdl2_renderer and sdl3_renderer backends |
| renderer: *const anyopaque, // SDL_Renderer | ||
| ) void { | ||
| backend_sdl2.initRenderer(window, renderer); | ||
| if(!ImGui_ImplSDLRenderer2_Init(renderer)){ |
There was a problem hiding this comment.
[nitpick] Missing space after 'if' keyword. Should be 'if (!ImGui_ImplSDLRenderer2_Init(renderer)){' to follow consistent code formatting.
| if(!ImGui_ImplSDLRenderer2_Init(renderer)){ | |
| if (!ImGui_ImplSDLRenderer2_Init(renderer)){ |
| renderer: *const anyopaque, // SDL_Renderer | ||
| ) void { | ||
| backend_sdl3.initRenderer(window, renderer); | ||
| if(!ImGui_ImplSDLRenderer3_Init(renderer)){ |
There was a problem hiding this comment.
[nitpick] Missing space after 'if' keyword. Should be 'if (!ImGui_ImplSDLRenderer3_Init(renderer)){' to follow consistent code formatting.
| if(!ImGui_ImplSDLRenderer3_Init(renderer)){ | |
| if (!ImGui_ImplSDLRenderer3_Init(renderer)){ |
| window: *const anyopaque, // SDL_Window | ||
| renderer: *const anyopaque, // SDL_Renderer | ||
| ) void { | ||
| if (!ImGui_ImplSDL2_InitForSDLRenderer(window, renderer)){ |
There was a problem hiding this comment.
[nitpick] Missing space before opening brace. Should be 'if (!ImGui_ImplSDL2_InitForSDLRenderer(window, renderer)) {' to follow consistent code formatting.
| if (!ImGui_ImplSDL2_InitForSDLRenderer(window, renderer)){ | |
| if (!ImGui_ImplSDL2_InitForSDLRenderer(window, renderer)) { |
| window: *const anyopaque, | ||
| sdl_gl_context: *const anyopaque | ||
| ) void { | ||
| if (!ImGui_ImplSDL3_InitForSDLRenderer(window, sdl_gl_context)){ |
There was a problem hiding this comment.
[nitpick] Missing space before opening brace. Should be 'if (!ImGui_ImplSDL3_InitForSDLRenderer(window, sdl_gl_context)) {' to follow consistent code formatting.
| if (!ImGui_ImplSDL3_InitForSDLRenderer(window, sdl_gl_context)){ | |
| if (!ImGui_ImplSDL3_InitForSDLRenderer(window, sdl_gl_context)) { |
This commit might be directly incompatible with #51
Patch following #58