summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-28 02:06:05 +0100
committerskal <pascal.massimino@gmail.com>2026-01-28 02:06:05 +0100
commit5bbe2204f1d30e99ee442e287167ef14ad51af75 (patch)
treeed4a30ef91ed9e928bda0af07f44c8ecd0a9d76a /src/main.cc
parent164c471fb9488f7013be0bcaef7f790020aee916 (diff)
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.
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc9
1 files changed, 8 insertions, 1 deletions
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 <GLFW/glfw3.h>
#include <math.h>
+#include <stdio.h>
#include <string.h>
#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();
}