git.s-ol.nu zig-imgui / 7a22973
first working render! s-ol 2 years ago
5 changed file(s) with 83 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
0 {
1 "rdocCaptureSettings": 1,
2 "settings": {
3 "autoStart": false,
4 "commandLine": "",
5 "environment": [
6 ],
7 "executable": "/home/s-ol/zig/zig-cache/bin/test",
8 "inject": false,
9 "numQueuedFrames": 0,
10 "options": {
11 "allowFullscreen": true,
12 "allowVSync": true,
13 "apiValidation": false,
14 "captureAllCmdLists": false,
15 "captureCallstacks": false,
16 "captureCallstacksOnlyDraws": false,
17 "debugOutputMute": true,
18 "delayForDebugger": 0,
19 "hookIntoChildren": false,
20 "refAllResources": false,
21 "verifyBufferAccess": false
22 },
23 "queuedFrameCap": 0,
24 "workingDir": "/home/s-ol/zig"
25 }
26 }
0 const c = @import("c.zig");
1 const std = @import("std");
2 const os = std.os;
3 const panic = std.debug.panic;
4 const builtin = @import("builtin");
5
6 pub const is_on = if (builtin.mode == builtin.Mode.ReleaseFast) c.GL_FALSE else c.GL_TRUE;
7
8 pub fn assertNoError() void {
9 if (builtin.mode != builtin.Mode.ReleaseFast) {
10 const err = c.glGetError();
11 if (err != c.GL_NO_ERROR) {
12 panic("GL error: {}\n", err);
13 }
14 }
15 }
422422 [_]f32{ 0.0, 0.0, -1.0, 0.0 },
423423 [_]f32{ (R+L)/(L-R), (T+B)/(B-T), 0.0, 1.0 },
424424 };
425 c.glUseProgram(g_ShaderHandle);
425426 c.glUniform1i(g_AttribLocationTex, 0);
426427 c.glUniformMatrix4fv(g_AttribLocationProjMtx, 1, c.GL_FALSE, &ortho_projection[0][0]);
427428 if (@hasField(c, "GL_SAMPLER_BINDING"))
33 const math = @import("std").math;
44
55 pub const ClientApi = enum {
6 Unknown,
7 OpenGL,
8 Vulkan,
6 Unknown,
7 OpenGL,
8 Vulkan,
99 };
1010
1111 // Data
144144 }
145145
146146 fn UpdateMonitors() void {
147 // @TODO
147 const platform_io = c.igGetPlatformIO();
148 var monitors_count : c_int = 0;
149 const glfw_monitors = c.glfwGetMonitors(&monitors_count)[0..@intCast(usize, monitors_count)];
150
151 c.ImVector_ImGuiPlatformMonitor_Resize(&platform_io.*.Monitors, monitors_count);
152 for (glfw_monitors) |glfw_monitor, n| {
153 var monitor = &platform_io.*.Monitors.Data[n];
154 var x : c_int = undefined;
155 var y : c_int = undefined;
156 c.glfwGetMonitorPos(glfw_monitor, &x, &y);
157 const vid_mode = c.glfwGetVideoMode(glfw_monitor); // glfw_monitors[n]);
158
159 monitor.*.MainPos = c.ImVec2{ .x = @intToFloat(f32, x), .y = @intToFloat(f32, y) };
160 monitor.*.MainSize = c.ImVec2{
161 .x = @intToFloat(f32, vid_mode.*.width),
162 .y = @intToFloat(f32, vid_mode.*.height),
163 };
164 if (false and c.GLFW_HAS_MONITOR_WORK_AREA) {
165 var w : c_int = undefined;
166 var h : c_int = undefined;
167 c.glfwGetMonitorWorkarea(glfw_monitor, &x, &y, &w, &h);
168 monitor.*.WorkPos = ImVec2{ .x = @intToFloat(f32, x), .y = @intToFloat(f32, y) };
169 monitor.*.WorkSize = ImVec2{ .x = @intToFloat(f32, w), .y = @intToFloat(f32, h) };
170 }
171 if (false and c.GLFW_HAS_PER_MONITOR_DPI) {
172 // Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings,
173 // which generally needs to be set in the manifest or at runtime.
174 var x_scale : f32 = undefined;
175 var y_scale : f32 = undefined;
176 c.glfwGetMonitorContentScale(glfw_monitor, &x_scale, &y_scale);
177 monitor.*.DpiScale = x_scale;
178 }
179 }
180 g_WantUpdateMonitors = false;
148181 }
149182
150183 fn UpdateMousePosAndButtons() void {
00 const c = @import("c.zig");
11 const std = @import("std");
22 const panic = std.debug.panic;
3 const debug_gl = @import("debug_gl.zig");
34 const glfw_impl = @import("glfw_impl.zig");
45 const gl3_impl = @import("gl3_impl.zig");
56
2021 c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MAJOR, 3);
2122 c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MINOR, 2);
2223 c.glfwWindowHint(c.GLFW_OPENGL_FORWARD_COMPAT, c.GL_TRUE);
24 c.glfwWindowHint(c.GLFW_OPENGL_DEBUG_CONTEXT, debug_gl.is_on);
2325 c.glfwWindowHint(c.GLFW_OPENGL_PROFILE, c.GLFW_OPENGL_CORE_PROFILE);
24
25 // c.glfwWindowHint(c.GLFW_OPENGL_DEBUG_CONTEXT, debug_gl.is_on);
2626 // c.glfwWindowHint(c.GLFW_DEPTH_BITS, 0);
2727 // c.glfwWindowHint(c.GLFW_STENCIL_BITS, 8);
2828 c.glfwWindowHint(c.GLFW_RESIZABLE, c.GL_TRUE);