43 lines
1.3 KiB
Zig
43 lines
1.3 KiB
Zig
const zgui = @import("gui.zig");
|
|
|
|
const SDL_GL_Context = *anyopaque;
|
|
|
|
pub fn init(window: *anyopaque, context: SDL_GL_Context, glsl_version: []const u8) void {
|
|
if (!ImGui_ImplSDL2_InitForOpenGL(window, context)) unreachable;
|
|
if (!ImGui_ImplOpenGL3_Init(glsl_version.ptr)) unreachable;
|
|
}
|
|
|
|
pub fn deinit() void {
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
ImGui_ImplSDL2_Shutdown();
|
|
}
|
|
|
|
pub fn newFrame(width: f32, height: f32) void {
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
ImGui_ImplSDL2_NewFrame();
|
|
|
|
zgui.io.setDisplaySize(width, height);
|
|
zgui.io.setDisplayFramebufferScale(1.0, 1.0);
|
|
|
|
zgui.newFrame();
|
|
}
|
|
|
|
pub fn draw() void {
|
|
zgui.render();
|
|
ImGui_ImplOpenGL3_RenderDrawData(zgui.getDrawData());
|
|
}
|
|
|
|
pub fn processEvent(event: *anyopaque) bool {
|
|
return ImGui_ImplSDL2_ProcessEvent(event);
|
|
}
|
|
|
|
extern fn ImGui_ImplSDL2_InitForOpenGL(window: *anyopaque, sdl_gl_context: SDL_GL_Context) bool;
|
|
extern fn ImGui_ImplSDL2_Shutdown() void;
|
|
extern fn ImGui_ImplSDL2_NewFrame() void;
|
|
extern fn ImGui_ImplSDL2_ProcessEvent(event: *anyopaque) bool;
|
|
|
|
extern fn ImGui_ImplOpenGL3_Init(glsl_version: [*]const u8) bool;
|
|
extern fn ImGui_ImplOpenGL3_Shutdown() void;
|
|
extern fn ImGui_ImplOpenGL3_NewFrame() void;
|
|
extern fn ImGui_ImplOpenGL3_RenderDrawData(draw_data: *anyopaque) void;
|