File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub const Backend = enum {
1010 glfw ,
1111 sdl2_opengl3 ,
1212 osx_metal ,
13+ sdl2 ,
1314};
1415
1516pub fn build (b : * std.Build ) void {
@@ -385,6 +386,17 @@ pub fn build(b: *std.Build) void {
385386 .flags = objcflags ,
386387 });
387388 },
389+ .sdl2 = > {
390+ if (b .lazyDependency ("zsdl" , .{})) | zsdl | {
391+ imgui .addIncludePath (zsdl .path ("libs/sdl2/include" ));
392+ }
393+ imgui .addCSourceFiles (.{
394+ .files = &.{
395+ "libs/imgui/backends/imgui_impl_sdl2.cpp" ,
396+ },
397+ .flags = cflags ,
398+ });
399+ },
388400 .no_backend = > {},
389401 }
390402
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
138138extern " C" {
139139
140140bool ImGui_ImplSDL2_InitForOpenGL (SDL_Window* window, void * sdl_gl_context);
141+ bool ImGui_ImplSDL2_InitForOther (SDL_Window* window);
141142void ImGui_ImplSDL2_Shutdown ();
142143void ImGui_ImplSDL2_NewFrame ();
143144bool ImGui_ImplSDL2_ProcessEvent (const SDL_Event* event);
Original file line number Diff line number Diff line change 11const gui = @import ("gui.zig" );
22
3+ pub fn init (
4+ window : * const anyopaque , // SDL_Window
5+ ) void {
6+ if (! ImGui_ImplSDL2_InitForOther (window )) {
7+ unreachable ;
8+ }
9+ }
10+
311pub fn initOpenGL (
412 window : * const anyopaque , // SDL_Window
513 context : * const anyopaque , // SDL_GL_Context
@@ -24,6 +32,7 @@ pub fn newFrame() void {
2432}
2533
2634// These functions are defined in `imgui_impl_sdl2.cpp`
35+ extern fn ImGui_ImplSDL2_InitForOther (window : * const anyopaque ) bool ;
2736extern fn ImGui_ImplSDL2_InitForOpenGL (window : * const anyopaque , sdl_gl_context : * const anyopaque ) bool ;
2837extern fn ImGui_ImplSDL2_ProcessEvent (event : * const anyopaque ) bool ;
2938extern fn ImGui_ImplSDL2_NewFrame () void ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ pub const backend = switch (@import("zgui_options").backend) {
1818 .win32_dx12 = > @import ("backend_win32_dx12.zig" ),
1919 .sdl2_opengl3 = > @import ("backend_sdl2_opengl.zig" ),
2020 .osx_metal = > @import ("backend_osx_metal.zig" ),
21+ .sdl2 = > @import ("backend_sdl2.zig" ),
2122 .no_backend = > .{},
2223};
2324const te_enabled = @import ("zgui_options" ).with_te ;
You can’t perform that action at this time.
0 commit comments