sokol-playground/src/main.zig

49 lines
1.1 KiB
Zig
Raw Normal View History

2024-06-08 22:48:23 +00:00
const std = @import("std");
2024-06-08 23:15:52 +00:00
const sokol = @import("sokol");
const sg = sokol.gfx;
2024-06-08 22:48:23 +00:00
2024-06-08 23:15:52 +00:00
const state = struct {
var bind: sg.Bindings = .{};
var pip: sg.Pipeline = .{};
};
2024-06-08 22:48:23 +00:00
2024-06-09 17:28:42 +00:00
var pass_action: sg.PassAction = .{};
2024-06-08 22:48:23 +00:00
2024-06-09 17:28:42 +00:00
export fn init() void {
sg.setup(.{
.logger = .{ .func = sokol.log.func },
.environment = sokol.glue.environment(),
});
pass_action.colors[0] = .{
.load_action = .CLEAR,
.clear_value = .{ .r = 0.2, .g = 1, .b = 1, .a = 1 },
};
std.debug.print("Backend: {}\n", .{sg.queryBackend()});
}
export fn frame() void {
//const g = pass_action.colors[0].clear_value.g + 0.01;
sg.beginPass(.{ .action = pass_action, .swapchain = sokol.glue.swapchain() });
sg.endPass();
sg.commit();
}
2024-06-08 22:48:23 +00:00
2024-06-08 23:15:52 +00:00
export fn cleanup() void {}
pub fn main() !void {
sokol.app.run(.{
.init_cb = init,
.frame_cb = frame,
.cleanup_cb = cleanup,
.width = 800,
.height = 600,
.icon = .{ .sokol_default = true },
.window_title = "sokol hello",
.logger = .{ .func = sokol.log.func },
});
2024-06-08 22:48:23 +00:00
}