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