Skip to content

glfw_live: --no-hdpi-framebuffer flag for matching framebuffer to logical size#2704

Merged
borisbat merged 1 commit into
masterfrom
bbatkin/no-hdpi-framebuffer-flag
May 17, 2026
Merged

glfw_live: --no-hdpi-framebuffer flag for matching framebuffer to logical size#2704
borisbat merged 1 commit into
masterfrom
bbatkin/no-hdpi-framebuffer-flag

Conversation

@borisbat
Copy link
Copy Markdown
Collaborator

Summary

Adds a lazy-parsed CLI flag --no-hdpi-framebuffer (after the daslang -- separator) to modules/dasGlfw/dasglfw/glfw_live.das. When set, live_create_window sets two GLFW hints before glfwCreateWindow:

  • GLFW_COCOA_RETINA_FRAMEBUFFER = 0 — macOS: disable retina backing, framebuffer == window size in physical pixels
  • GLFW_SCALE_TO_MONITOR = 0 — Windows: don't auto-scale by monitor DPI (overrides any caller-set =1 hint)

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_app helper (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) so glReadPixels-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-live directly pass neither flag and keep their native HDPI experience.

Test plan

  • Compile + lint clean (mcp__daslang__compile_check / mcp__daslang__lint)
  • Verified end-to-end on retina mac: daslang record_boost_basics.das (which spawns daslang-live with both flags) produces a 640×320 APNG (~7.8 MB) instead of 1280×640 (~28 MB)
  • Daslang-live launched WITHOUT the flag still opens retina-backed framebuffer (HDPI tutorials unchanged)
  • CI: cross-platform matrix green

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings May 17, 2026 09:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/clargs import and lazy parse helpers (g_no_hdpi_parsed, g_no_hdpi, ensure_no_hdpi_parsed).
  • In live_create_window, after glfwInitOpenGL and before glfwCreateWindow, 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.

@borisbat borisbat merged commit c36f14c into master May 17, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants