Circle that doesnt stretch

This commit is contained in:
nothke
2024-06-12 02:04:37 +02:00
parent 7c97adabbe
commit 27528c754c
4 changed files with 234 additions and 135 deletions

View File

@@ -10,7 +10,8 @@ var pass_action: sg.PassAction = .{};
const state = struct {
var bind: sg.Bindings = .{};
var pip: sg.Pipeline = .{};
var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
var vsParams: shader.VsParams = .{ .aspectRatio = 0.5 };
var fsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
var indexCount: u16 = 0;
};
@@ -24,7 +25,7 @@ export fn init() void {
std.log.info("Vertex buffers len: {}", .{state.bind.vertex_buffers.len});
const vertexCount = 8;
const vertexCount = 100;
const radius: f32 = 0.7;
const cX: f32 = 0;
@@ -118,10 +119,13 @@ export fn frame() void {
col.g = @abs(@sin(timef()));
col.r = @abs(@cos(timef()));
state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();
sg.beginPass(.{ .action = pass_action, .swapchain = sokol.glue.swapchain() });
sg.applyPipeline(state.pip);
state.vsParams.offset[0] = col.r;
sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams));
state.fsParams.offset[0] = col.r;
sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.fsParams));
sg.applyUniforms(.VS, shader.SLOT_vs_params, sg.asRange(&state.vsParams));
sg.applyBindings(state.bind);
sg.draw(0, state.indexCount, 1);
sg.endPass();
@@ -138,6 +142,7 @@ pub fn main() !void {
.cleanup_cb = cleanup,
.width = 800,
.height = 600,
.fullscreen = true,
.icon = .{ .sokol_default = true },
.window_title = "sokol hello",
.logger = .{ .func = sokol.log.func },