From 5bbe2204f1d30e99ee442e287167ef14ad51af75 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 28 Jan 2026 02:06:05 +0100 Subject: fix(gpu): Add aspect ratio correction to shader Implements aspect ratio correction to prevent the pulsating heptagon from being distorted when the window is resized. - The main loop now queries the framebuffer size and calculates the aspect ratio each frame. - This aspect ratio is passed to the GPU via an updated uniform buffer. - The vertex shader in shader.wgsl now uses the aspect ratio to correctly scale the X coordinates of the vertices, ensuring the shape remains proportional. --- src/main.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index ef48f21..e46468f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -3,7 +3,9 @@ #include "gpu/gpu.h" #include "platform.h" #include "util/math.h" +#include #include +#include #include #define DEMO_BPM 120.0f @@ -75,7 +77,12 @@ int main(int argc, char **argv) { } } - gpu_draw(synth_get_output_peak()); + int width, height; + glfwGetFramebufferSize(platform_get_window(), &width, &height); + float aspect_ratio = (float)width / (float)height; + + float visual_peak = fminf(synth_get_output_peak() * 80.0f, 1.0f); + gpu_draw(visual_peak, aspect_ratio); audio_update(); } -- cgit v1.2.3