feat: add backend impl for glfw+opengl3
This commit is contained in:
parent
d62422b771
commit
bd384d64ba
|
@ -0,0 +1,38 @@
|
||||||
|
const zgui = @import("gui.zig");
|
||||||
|
|
||||||
|
pub fn init(window: *anyopaque, glsl_version: []const u8) void {
|
||||||
|
if (!ImGui_ImplGlfw_InitForOpenGL(window, true)) unreachable;
|
||||||
|
if (!ImGui_ImplOpenGL3_Init(glsl_version.ptr)) unreachable;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit() void {
|
||||||
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn newFrame(width: f32, height: f32) void {
|
||||||
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
ImGui_ImplGlfw_NewFrame();
|
||||||
|
|
||||||
|
zgui.io.setDisplaySize(width, height);
|
||||||
|
zgui.io.setDisplayFramebufferScale(1.0, 1.0);
|
||||||
|
|
||||||
|
zgui.newFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render() void {
|
||||||
|
zgui.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn draw() void {
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(zgui.getDrawData());
|
||||||
|
}
|
||||||
|
|
||||||
|
extern fn ImGui_ImplGlfw_InitForOpenGL(window: *anyopaque, install_callbacks: bool) bool;
|
||||||
|
extern fn ImGui_ImplGlfw_Shutdown() void;
|
||||||
|
extern fn ImGui_ImplGlfw_NewFrame() void;
|
||||||
|
|
||||||
|
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; // ImDrawData
|
|
@ -10,6 +10,7 @@ pub usingnamespace @import("gui.zig");
|
||||||
pub const plot = @import("plot.zig");
|
pub const plot = @import("plot.zig");
|
||||||
pub const backend = switch (@import("zgui_options").backend) {
|
pub const backend = switch (@import("zgui_options").backend) {
|
||||||
.glfw_wgpu => @import("backend_glfw_wgpu.zig"),
|
.glfw_wgpu => @import("backend_glfw_wgpu.zig"),
|
||||||
|
.glfw_opengl3 => @import("backend_glfw_opengl3.zig"),
|
||||||
.win32_dx12 => .{}, // TODO:
|
.win32_dx12 => .{}, // TODO:
|
||||||
.no_backend => .{},
|
.no_backend => .{},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue