-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_base_code.zig
53 lines (41 loc) · 1.13 KB
/
00_base_code.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const std = @import("std");
const glfw = @import("glfw");
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
const HelloTriangleApplication = struct {
const Self = @This();
window: ?glfw.Window = null,
pub fn init() Self {
return Self{};
}
pub fn run(self: *Self) !void {
try self.initWindow();
try self.initVulkan();
try self.mainLoop();
}
fn initWindow(self: *Self) !void {
try glfw.init(.{});
self.window = try glfw.Window.create(WIDTH, HEIGHT, "Vulkan", null, null, .{
.client_api = .no_api,
.resizable = false,
});
}
fn initVulkan(_: *Self) !void {}
fn mainLoop(self: *Self) !void {
while (!self.window.?.shouldClose()) {
try glfw.pollEvents();
}
}
pub fn deinit(self: *Self) void {
if (self.window != null) self.window.?.destroy();
glfw.terminate();
}
};
pub fn main() void {
var app = HelloTriangleApplication.init();
defer app.deinit();
app.run() catch |err| {
std.log.err("application exited with error: {any}", .{err});
return;
};
}