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 {
10
10
glfw ,
11
11
sdl2_opengl3 ,
12
12
osx_metal ,
13
+ sdl2 ,
13
14
sdl3_gpu ,
14
15
};
15
16
@@ -386,6 +387,17 @@ pub fn build(b: *std.Build) void {
386
387
.flags = objcflags ,
387
388
});
388
389
},
390
+ .sdl2 = > {
391
+ if (b .lazyDependency ("zsdl" , .{})) | zsdl | {
392
+ imgui .addIncludePath (zsdl .path ("libs/sdl2/include" ));
393
+ }
394
+ imgui .addCSourceFiles (.{
395
+ .files = &.{
396
+ "libs/imgui/backends/imgui_impl_sdl2.cpp" ,
397
+ },
398
+ .flags = cflags ,
399
+ });
400
+ },
389
401
.sdl3_gpu = > {
390
402
if (b .lazyDependency ("zsdl" , .{})) | zsdl | {
391
403
imgui .addIncludePath (zsdl .path ("libs/sdl3/include" ));
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
138
138
extern " C" {
139
139
140
140
bool ImGui_ImplSDL2_InitForOpenGL (SDL_Window* window, void * sdl_gl_context);
141
+ bool ImGui_ImplSDL2_InitForOther (SDL_Window* window);
141
142
void ImGui_ImplSDL2_Shutdown ();
142
143
void ImGui_ImplSDL2_NewFrame ();
143
144
bool ImGui_ImplSDL2_ProcessEvent (const SDL_Event* event);
Original file line number Diff line number Diff line change 1
1
const gui = @import ("gui.zig" );
2
2
3
+ pub fn init (
4
+ window : * const anyopaque , // SDL_Window
5
+ ) void {
6
+ if (! ImGui_ImplSDL2_InitForOther (window )) {
7
+ unreachable ;
8
+ }
9
+ }
10
+
3
11
pub fn initOpenGL (
4
12
window : * const anyopaque , // SDL_Window
5
13
context : * const anyopaque , // SDL_GL_Context
@@ -24,6 +32,7 @@ pub fn newFrame() void {
24
32
}
25
33
26
34
// These functions are defined in `imgui_impl_sdl2.cpp`
35
+ extern fn ImGui_ImplSDL2_InitForOther (window : * const anyopaque ) bool ;
27
36
extern fn ImGui_ImplSDL2_InitForOpenGL (window : * const anyopaque , sdl_gl_context : * const anyopaque ) bool ;
28
37
extern fn ImGui_ImplSDL2_ProcessEvent (event : * const anyopaque ) bool ;
29
38
extern 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) {
18
18
.win32_dx12 = > @import ("backend_win32_dx12.zig" ),
19
19
.sdl2_opengl3 = > @import ("backend_sdl2_opengl.zig" ),
20
20
.osx_metal = > @import ("backend_osx_metal.zig" ),
21
+ .sdl2 = > @import ("backend_sdl2.zig" ),
21
22
.sdl3_gpu = > @import ("backend_sdl3_gpu.zig" ),
22
23
.no_backend = > .{},
23
24
};
You can’t perform that action at this time.
0 commit comments