first working render!
s-ol
3 years ago
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 | } |
422 | 422 | [_]f32{ 0.0, 0.0, -1.0, 0.0 }, |
423 | 423 | [_]f32{ (R+L)/(L-R), (T+B)/(B-T), 0.0, 1.0 }, |
424 | 424 | }; |
425 | c.glUseProgram(g_ShaderHandle); | |
425 | 426 | c.glUniform1i(g_AttribLocationTex, 0); |
426 | 427 | c.glUniformMatrix4fv(g_AttribLocationProjMtx, 1, c.GL_FALSE, &ortho_projection[0][0]); |
427 | 428 | if (@hasField(c, "GL_SAMPLER_BINDING")) |
3 | 3 | const math = @import("std").math; |
4 | 4 | |
5 | 5 | pub const ClientApi = enum { |
6 | Unknown, | |
7 | OpenGL, | |
8 | Vulkan, | |
6 | Unknown, | |
7 | OpenGL, | |
8 | Vulkan, | |
9 | 9 | }; |
10 | 10 | |
11 | 11 | // Data |
144 | 144 | } |
145 | 145 | |
146 | 146 | 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; | |
148 | 181 | } |
149 | 182 | |
150 | 183 | fn UpdateMousePosAndButtons() void { |
0 | 0 | const c = @import("c.zig"); |
1 | 1 | const std = @import("std"); |
2 | 2 | const panic = std.debug.panic; |
3 | const debug_gl = @import("debug_gl.zig"); | |
3 | 4 | const glfw_impl = @import("glfw_impl.zig"); |
4 | 5 | const gl3_impl = @import("gl3_impl.zig"); |
5 | 6 | |
20 | 21 | c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MAJOR, 3); |
21 | 22 | c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MINOR, 2); |
22 | 23 | c.glfwWindowHint(c.GLFW_OPENGL_FORWARD_COMPAT, c.GL_TRUE); |
24 | c.glfwWindowHint(c.GLFW_OPENGL_DEBUG_CONTEXT, debug_gl.is_on); | |
23 | 25 | c.glfwWindowHint(c.GLFW_OPENGL_PROFILE, c.GLFW_OPENGL_CORE_PROFILE); |
24 | ||
25 | // c.glfwWindowHint(c.GLFW_OPENGL_DEBUG_CONTEXT, debug_gl.is_on); | |
26 | 26 | // c.glfwWindowHint(c.GLFW_DEPTH_BITS, 0); |
27 | 27 | // c.glfwWindowHint(c.GLFW_STENCIL_BITS, 8); |
28 | 28 | c.glfwWindowHint(c.GLFW_RESIZABLE, c.GL_TRUE); |