Compare commits
No commits in common. "2524dbf2061fc1e7417f63f5b6f55da95e0d83a8" and "1c49ffa07ff510e21b87a6c910db395a7e9ba4f0" have entirely different histories.
2524dbf206
...
1c49ffa07f
@ -15,9 +15,6 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
exe.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
||||
|
||||
// Set this to hide console
|
||||
//exe.subsystem = .Windows;
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
|
31
src/main.zig
31
src/main.zig
@ -104,27 +104,20 @@ export fn init() void {
|
||||
|
||||
pass_action.colors[0] = .{
|
||||
.load_action = .CLEAR,
|
||||
.clear_value = .{},
|
||||
.clear_value = .{ .r = 0, .g = 1, .b = 0, .a = 1 },
|
||||
};
|
||||
|
||||
std.log.info("Backend: {}\n", .{sg.queryBackend()});
|
||||
|
||||
sokol.app.showMouse(false);
|
||||
}
|
||||
|
||||
fn timef() f32 {
|
||||
return @floatCast(sokol.time.sec(sokol.time.now()));
|
||||
}
|
||||
|
||||
var time: f32 = 0;
|
||||
|
||||
export fn frame() void {
|
||||
const dt: f32 = @floatCast(sokol.app.frameDuration());
|
||||
time += dt;
|
||||
|
||||
const col = &pass_action.colors[0].clear_value;
|
||||
col.g = @abs(@sin(time));
|
||||
col.r = @abs(@cos(time));
|
||||
col.g = @abs(@sin(timef()));
|
||||
col.r = @abs(@cos(timef()));
|
||||
|
||||
state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();
|
||||
|
||||
@ -140,29 +133,13 @@ export fn frame() void {
|
||||
sg.commit();
|
||||
}
|
||||
|
||||
export fn cleanup() void {
|
||||
std.log.info("Ended", .{});
|
||||
}
|
||||
|
||||
const Event = sokol.app.Event;
|
||||
|
||||
export fn event(eptr: [*c]const Event) void {
|
||||
const e: *const Event = @ptrCast(eptr);
|
||||
|
||||
const buttonPressed = e.type == .MOUSE_DOWN or e.type == .KEY_DOWN;
|
||||
const mouseMoved = e.type == .MOUSE_MOVE and (@abs(e.mouse_dx) > 2 or @abs(e.mouse_dy) > 2);
|
||||
|
||||
if (buttonPressed or mouseMoved) {
|
||||
sokol.app.quit();
|
||||
}
|
||||
}
|
||||
export fn cleanup() void {}
|
||||
|
||||
pub fn main() !void {
|
||||
sokol.app.run(.{
|
||||
.init_cb = init,
|
||||
.frame_cb = frame,
|
||||
.cleanup_cb = cleanup,
|
||||
.event_cb = event,
|
||||
.width = 800,
|
||||
.height = 600,
|
||||
.fullscreen = true,
|
||||
|
Loading…
Reference in New Issue
Block a user