summaryrefslogtreecommitdiffstats
path: root/src/main.zig
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-10-20 18:11:41 +0000
committers-ol <s-ol@users.noreply.github.com>2019-10-20 18:11:41 +0000
commit883688f3009291b9e5d2baa121cf8a3da8ac9d0e (patch)
tree97cf4aae9c7be3333b0f2430b7e8bda85ffb5179 /src/main.zig
parentinitial commit (diff)
downloadzig-imgui-883688f3009291b9e5d2baa121cf8a3da8ac9d0e.tar.gz
zig-imgui-883688f3009291b9e5d2baa121cf8a3da8ac9d0e.zip
finish GLFW impl
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/main.zig b/src/main.zig
index 42fa152..08f5bea 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -4,7 +4,7 @@ const panic = std.debug.panic;
const glfw_impl = @import("glfw_impl.zig");
extern fn errorCallback(err: c_int, description: [*c]const u8) void {
- panic("Error: {}\n", description);
+ panic("Error: {}\n", description);
}
var window: *c.GLFWwindow = undefined;
@@ -13,7 +13,7 @@ pub fn main() void {
_ = c.glfwSetErrorCallback(errorCallback);
if (c.glfwInit() == c.GL_FALSE) {
- panic("GLFW init failure\n");
+ panic("GLFW init failure\n");
}
defer c.glfwTerminate();
@@ -30,7 +30,7 @@ pub fn main() void {
const window_width = 640;
const window_height = 480;
window = c.glfwCreateWindow(window_width, window_height, c"ImGUI Test", null, null) orelse {
- panic("unable to create window\n");
+ panic("unable to create window\n");
};
defer c.glfwDestroyWindow(window);
@@ -54,24 +54,38 @@ pub fn main() void {
}
glfw_impl.Init(window, true, glfw_impl.ClientApi.OpenGL);
- // ImGui_InitForOpenGL(window, true);
+ defer glfw_impl.Shutdown();
+
// ImGui_ImplOpenGL3_Init(glsl_version);
const start_time = c.glfwGetTime();
var prev_time = start_time;
while (c.glfwWindowShouldClose(window) == c.GL_FALSE) {
- // c.glClear(c.GL_COLOR_BUFFER_BIT | c.GL_DEPTH_BUFFER_BIT | c.GL_STENCIL_BUFFER_BIT);
-
- const now_time = c.glfwGetTime();
- const elapsed = now_time - prev_time;
- prev_time = now_time;
+ c.glfwPollEvents();
+ glfw_impl.NewFrame();
+ // gl3_impl.NewFrame();
+ c.igNewFrame();
+
+ // main part
+ c.igShowDemoWindow(null);
+
+ c.igRender();
+ var w: c_int = undefined;
+ var h: c_int = undefined;
+ c.glfwGetFramebufferSize(window, &w, &h);
+ c.glViewport(0, 0, w, h);
+ c.glClearColor(0.0, 0.0, 0.0, 0.0);
+ c.glClear(c.GL_COLOR_BUFFER_BIT);
+ // gl3_impl.RenderDrawData(c.igGetDrawData());
+
+ // const now_time = c.glfwGetTime();
+ // const elapsed = now_time - prev_time;
+ // prev_time = now_time;
// nextFrame(t, elapsed);
-
// draw(t, @This());
+
c.glfwSwapBuffers(window);
-
- c.glfwPollEvents();
}
}