summaryrefslogtreecommitdiff
path: root/src/rendering/window.zig
diff options
context:
space:
mode:
authorLorenzo Torres <torres@sideros.org>2025-03-27 21:42:46 +0100
committerLorenzo Torres <torres@sideros.org>2025-03-27 21:42:46 +0100
commit1730f1e2980bfa2819c541d9b8a3bc0301b8334e (patch)
treeb4acfaf7fbd7d6f3344155c251c1d1b1d6f7a431 /src/rendering/window.zig
parent09691ec4d93cda6ab31d28d6e478257209fe625e (diff)
Made Renderer a separate module
Diffstat (limited to 'src/rendering/window.zig')
-rw-r--r--src/rendering/window.zig64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/rendering/window.zig b/src/rendering/window.zig
deleted file mode 100644
index 28c22d1..0000000
--- a/src/rendering/window.zig
+++ /dev/null
@@ -1,64 +0,0 @@
-const c = @import("../c.zig");
-const std = @import("std");
-
-pub const Error = error{
- platform_unavailable,
- platform_error,
-};
-
-pub fn getExtensions() [][*c]const u8 {
- var extension_count: u32 = undefined;
- const raw: [*c][*c]const u8 = c.glfwGetRequiredInstanceExtensions(&extension_count);
- const extensions = raw[0..extension_count];
-
- return extensions;
-}
-
-pub const Window = struct {
- title: []const u8,
- width: usize,
- height: usize,
- raw: *c.GLFWwindow,
-
- pub fn create(width: usize, height: usize, title: []const u8) !Window {
- if (c.glfwInit() != c.GLFW_TRUE) {
- const status = c.glfwGetError(null);
-
- return switch (status) {
- c.GLFW_PLATFORM_UNAVAILABLE => Error.platform_unavailable,
- c.GLFW_PLATFORM_ERROR => Error.platform_error,
- else => unreachable,
- };
- }
-
- c.glfwWindowHint(c.GLFW_RESIZABLE, c.GLFW_FALSE);
- c.glfwWindowHint(c.GLFW_CLIENT_API, c.GLFW_NO_API);
- const raw = c.glfwCreateWindow(@intCast(width), @intCast(height), title.ptr, null, null);
- c.glfwShowWindow(raw);
-
- return Window{
- .title = title,
- .width = width,
- .height = height,
- .raw = raw.?,
- };
- }
-
- pub fn shouldClose(self: Window) bool {
- return c.glfwWindowShouldClose(self.raw) == c.GLFW_TRUE;
- }
-
- pub fn size(self: Window) struct { usize, usize } {
- var width: u32 = undefined;
- var height: u32 = undefined;
-
- c.glfwGetFramebufferSize(self.raw, @ptrCast(&width), @ptrCast(&height));
-
- return .{ @intCast(width), @intCast(height) };
- }
-
- pub fn destroy(self: Window) void {
- c.glfwDestroyWindow(self.raw);
- c.glfwTerminate();
- }
-};