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"));
|
exe.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
||||||
|
|
||||||
// Set this to hide console
|
|
||||||
//exe.subsystem = .Windows;
|
|
||||||
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(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] = .{
|
pass_action.colors[0] = .{
|
||||||
.load_action = .CLEAR,
|
.load_action = .CLEAR,
|
||||||
.clear_value = .{},
|
.clear_value = .{ .r = 0, .g = 1, .b = 0, .a = 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
std.log.info("Backend: {}\n", .{sg.queryBackend()});
|
std.log.info("Backend: {}\n", .{sg.queryBackend()});
|
||||||
|
|
||||||
sokol.app.showMouse(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timef() f32 {
|
fn timef() f32 {
|
||||||
return @floatCast(sokol.time.sec(sokol.time.now()));
|
return @floatCast(sokol.time.sec(sokol.time.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
var time: f32 = 0;
|
|
||||||
|
|
||||||
export fn frame() void {
|
export fn frame() void {
|
||||||
const dt: f32 = @floatCast(sokol.app.frameDuration());
|
|
||||||
time += dt;
|
|
||||||
|
|
||||||
const col = &pass_action.colors[0].clear_value;
|
const col = &pass_action.colors[0].clear_value;
|
||||||
col.g = @abs(@sin(time));
|
col.g = @abs(@sin(timef()));
|
||||||
col.r = @abs(@cos(time));
|
col.r = @abs(@cos(timef()));
|
||||||
|
|
||||||
state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();
|
state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();
|
||||||
|
|
||||||
@ -140,29 +133,13 @@ export fn frame() void {
|
|||||||
sg.commit();
|
sg.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn cleanup() void {
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
sokol.app.run(.{
|
sokol.app.run(.{
|
||||||
.init_cb = init,
|
.init_cb = init,
|
||||||
.frame_cb = frame,
|
.frame_cb = frame,
|
||||||
.cleanup_cb = cleanup,
|
.cleanup_cb = cleanup,
|
||||||
.event_cb = event,
|
|
||||||
.width = 800,
|
.width = 800,
|
||||||
.height = 600,
|
.height = 600,
|
||||||
.fullscreen = true,
|
.fullscreen = true,
|
||||||
|
Loading…
Reference in New Issue
Block a user