diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-02 09:19:17 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-02 09:19:17 +0100 |
| commit | 0b0067cb0a8db5ea5178501a12aacdef436a9845 (patch) | |
| tree | 362322b45ffde32346351dfa0710d3a470dd6e88 /src/main.cc | |
| parent | 275fe655fd7272edd9fa49439d47f449231ce445 (diff) | |
feat(platform): Fix high-DPI scaling and add resolution option
- Fixed a 'squished' viewport bug on high-DPI (Retina) displays by querying the framebuffer size in pixels instead of using the window size in points.
- Centralized window dimension management within the platform layer.
- Added a '--resolution WxH' command-line option to allow specifying a custom window size at startup. This option is stripped in STRIP_ALL builds.
- Updated all test and tool executables to use the new platform API.
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main.cc b/src/main.cc index 8cedfce..f7136ef 100644 --- a/src/main.cc +++ b/src/main.cc @@ -130,7 +130,10 @@ float* generate_tone(float* buffer, float freq) { int main(int argc, char** argv) { bool fullscreen_enabled = false; - double seek_time = 0.0; + float seek_time = 0.0f; + int* width_ptr = nullptr; + int* height_ptr = nullptr; + int custom_width, custom_height; #if !defined(STRIP_ALL) for (int i = 1; i < argc; ++i) { @@ -139,6 +142,12 @@ int main(int argc, char** argv) { } else if (strcmp(argv[i], "--seek") == 0 && i + 1 < argc) { seek_time = atof(argv[i + 1]); ++i; + } else if (strcmp(argv[i], "--resolution") == 0 && i + 1 < argc) { + const char* res_str = argv[++i]; + if (sscanf(res_str, "%dx%d", &custom_width, &custom_height) == 2) { + width_ptr = &custom_width; + height_ptr = &custom_height; + } } } #else @@ -147,10 +156,8 @@ int main(int argc, char** argv) { fullscreen_enabled = true; #endif /* STRIP_ALL */ - platform_init_window(fullscreen_enabled); - int width, height; - glfwGetFramebufferSize(platform_get_window(), &width, &height); - gpu_init(platform_get_window(), width, height); + platform_init_window(fullscreen_enabled, width_ptr, height_ptr); + gpu_init(platform_get_window(), platform_get_width(), platform_get_height()); audio_init(); // Register drum assets @@ -234,9 +241,7 @@ int main(int argc, char** argv) { update_game_logic(current_time); - int width, height; - glfwGetFramebufferSize(platform_get_window(), &width, &height); - float aspect_ratio = (float)width / (float)height; + float aspect_ratio = platform_get_aspect_ratio(); // Adjusted multiplier for visuals (preventing constant 1.0 saturation) float raw_peak = synth_get_output_peak(); |
