diff options
Diffstat (limited to 'src/Window.zig')
| -rw-r--r-- | src/Window.zig | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Window.zig b/src/Window.zig index 0c8bacb..bc3b8bd 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -17,38 +17,41 @@ // along with gfz. If not, see <https://www.gnu.org/licenses/>. usingnamespace @import("cimport.zig"); -const gfz = @import("gfz.zig"); +const Error = gfz.Error; const Monitor = @import("Monitor.zig"); -const Window = @This(); +const checkError = gfz.checkError; +const getError = gfz.getError; +const gfz = @import("gfz.zig"); +const Window = @This(); pimpl: *GLFWwindow, /// Create a window and its associated context. pub fn create(width: c_int, height: c_int, title: []const u8, - monitor: ?Monitor, share: ?Window) gfz.Error!Window { + monitor: ?Monitor, share: ?Window) Error!Window { const pmonitor = if (monitor) |box| box.pimpl else null; const pshare = if (share) |box| box.pimpl else null; const ptr = glfwCreateWindow(width, height, title.ptr, pmonitor, pshare); return if (ptr) |pimpl| Window{ .pimpl = pimpl } else - gfz.getError(); + getError(); } /// Make the context current for the calling thread. -pub fn makeCurrent(self: Window) gfz.Error!void { +pub fn makeCurrent(self: Window) Error!void { glfwMakeContextCurrent(self.pimpl); - try gfz.checkError(); + try checkError(); } /// Check the close flag. -pub fn shouldClose(self: Window) gfz.Error!bool { +pub fn shouldClose(self: Window) Error!bool { const flag = glfwWindowShouldClose(self.pimpl); - try gfz.checkError(); + try checkError(); return flag == GLFW_TRUE; } -pub fn swapBuffers(self: Window) gfz.Error!void { +pub fn swapBuffers(self: Window) Error!void { glfwSwapBuffers(self.pimpl); - try gfz.checkError(); + try checkError(); } |
