glfw_live: --no-hdpi-framebuffer flag for matching framebuffer to logical size#2704
Merged
Conversation
…ical size
Adds a lazy-parsed CLI flag `--no-hdpi-framebuffer` (after the daslang
`--` separator) that asks live_create_window to open a window whose
framebuffer matches the requested logical dimensions even on high-DPI
displays. Sets two GLFW window hints before glfwCreateWindow:
- GLFW_COCOA_RETINA_FRAMEBUFFER = 0 (macOS: disable retina backing)
- GLFW_SCALE_TO_MONITOR = 0 (Windows: don't auto-scale by
monitor DPI, even if a caller
set the hint to 1 earlier)
Linux is unaffected — X11 doesn't apply scaling at the GLFW level; on
Wayland the compositor reports framebuffer == window size for normal
windows already.
Use case: APNG-recording tools (dasImgui's `with_recording_app`) pass
both `--imgui-content-scale=1.0` (style scaling on the ImGui side) and
`--no-hdpi-framebuffer` (framebuffer size on the GLFW side) so
glReadPixels-based capture stays at logical pixel count. Without this,
a 640x320-logical window on retina produces a 1280x640 framebuffer,
quadrupling capture work + APNG file size.
Tutorial users running daslang-live directly pass neither flag and
keep their native HDPI experience.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a lazy-parsed --no-hdpi-framebuffer CLI flag (after the daslang -- separator) to glfw_live. When set, live_create_window issues two GLFW hints before window creation (GLFW_COCOA_RETINA_FRAMEBUFFER=0 and GLFW_SCALE_TO_MONITOR=0) so the framebuffer matches the logical window size, primarily to keep APNG recording captures small.
Changes:
- Adds
daslib/clargsimport and lazy parse helpers (g_no_hdpi_parsed,g_no_hdpi,ensure_no_hdpi_parsed). - In
live_create_window, afterglfwInitOpenGLand beforeglfwCreateWindow, applies the two GLFW hints when the flag is set. - Documents the new flag in the function's
//!block.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a lazy-parsed CLI flag
--no-hdpi-framebuffer(after the daslang--separator) tomodules/dasGlfw/dasglfw/glfw_live.das. When set,live_create_windowsets two GLFW hints beforeglfwCreateWindow:GLFW_COCOA_RETINA_FRAMEBUFFER = 0— macOS: disable retina backing, framebuffer == window size in physical pixelsGLFW_SCALE_TO_MONITOR = 0— Windows: don't auto-scale by monitor DPI (overrides any caller-set=1hint)Linux is unaffected — X11 doesn't apply scaling at the GLFW level; on Wayland the compositor reports framebuffer == window size for normal windows already.
Why
Companion to dasImgui's
with_recording_apphelper (PR borisbat/dasImgui#TBD). The recording helper passes BOTH--imgui-content-scale=1.0(ImGui-side style scaling) and--no-hdpi-framebuffer(GLFW-side framebuffer size) soglReadPixels-based APNG capture stays at logical pixel count.Without this flag: a 640×320-logical recording window opens at 1280×640 framebuffer on retina, quadrupling capture pixel count + PNG encoder workload. The APNG file size balloons (~28 MB vs ~8 MB) and the encoder can't keep up with the GL output rate (frames drop, recording lags).
Tutorial users running
daslang-livedirectly pass neither flag and keep their native HDPI experience.Test plan
mcp__daslang__compile_check/mcp__daslang__lint)daslang record_boost_basics.das(which spawns daslang-live with both flags) produces a640×320APNG (~7.8 MB) instead of1280×640(~28 MB)🤖 Generated with Claude Code