newFrame framebuffer scale#105
Open
hazeycode wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the various platform/renderer backend entrypoints so callers can supply Dear ImGui’s framebuffer scale each frame, enabling correct DPI scaling behavior across backends (per the earlier GLFW DPI-scaling efforts referenced in #42 and #102).
Changes:
- Extend backend
newFramefunctions to acceptfb_sx/fb_syand pass them toio.setDisplayFramebufferScale. - Keep setting
io.setDisplaySize(...)from the provided width/height parameters, now paired with the caller-provided framebuffer scale. - Minor formatting/whitespace cleanup in a few backend wrappers.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/backend_win32_dx12.zig | Extends newFrame to accept framebuffer scale and forwards it to ImGui IO. |
| src/backend_sdl3_vulkan.zig | Extends newFrame to accept framebuffer scale; minor formatting cleanup. |
| src/backend_sdl3_renderer.zig | Extends newFrame to accept framebuffer scale; minor formatting cleanup. |
| src/backend_sdl3_opengl.zig | Extends newFrame to accept framebuffer scale. |
| src/backend_sdl3_gpu.zig | Changes newFrame from single uniform scale to separate X/Y scale. |
| src/backend_sdl2_renderer.zig | Extends newFrame to accept framebuffer scale; minor formatting cleanup. |
| src/backend_sdl2_opengl.zig | Extends newFrame to accept framebuffer scale. |
| src/backend_osx_metal.zig | Extends newFrame signature to accept framebuffer scale; formatting tweaks. |
| src/backend_glfw_wgpu.zig | Extends newFrame to accept framebuffer scale. |
| src/backend_glfw_vulkan.zig | Extends newFrame to accept framebuffer scale. |
| src/backend_glfw_opengl.zig | Extends newFrame to accept framebuffer scale. |
| src/backend_glfw_dx12.zig | Extends newFrame to accept framebuffer scale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+23
to
27
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| ImGui_ImplWin32_NewFrame(); | ||
| backend_dx12.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); |
Comment on lines
+33
to
37
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| ImGui_ImplWGPU_NewFrame(); | ||
| backend_glfw.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@floatFromInt(fb_width), @floatFromInt(fb_height)); |
Comment on lines
+27
to
33
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| backend_glfw.newFrame(); | ||
| backend_vulkan.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); | ||
| gui.io.setDisplayFramebufferScale(1.0, 1.0); | ||
| gui.io.setDisplayFramebufferScale(fb_sx, fb_sy); | ||
|
|
Comment on lines
+24
to
30
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| backend_glfw.newFrame(); | ||
| ImGui_ImplOpenGL3_NewFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); | ||
| gui.io.setDisplayFramebufferScale(1.0, 1.0); | ||
| gui.io.setDisplayFramebufferScale(fb_sx, fb_sy); | ||
|
|
Comment on lines
+22
to
26
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| backend_glfw.newFrame(); | ||
| backend_dx12.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); |
Comment on lines
+32
to
36
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| ImGui_ImplOpenGL3_NewFrame(); | ||
| backend_sdl3.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); |
Comment on lines
+30
to
34
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| ImGui_ImplSDLGPU3_NewFrame(); | ||
| backend_sdl3.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); |
Comment on lines
+25
to
31
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| ImGui_ImplSDLRenderer2_NewFrame(); | ||
| backend_sdl2.newFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); | ||
| gui.io.setDisplayFramebufferScale(1.0, 1.0); | ||
| gui.io.setDisplayFramebufferScale(fb_sx, fb_sy); | ||
|
|
Comment on lines
+32
to
38
| pub fn newFrame(fb_width: u32, fb_height: u32, fb_sx: f32, fb_sy: f32) void { | ||
| backend_sdl2.newFrame(); | ||
| ImGui_ImplOpenGL3_NewFrame(); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); | ||
| gui.io.setDisplayFramebufferScale(1.0, 1.0); | ||
| gui.io.setDisplayFramebufferScale(fb_sx, fb_sy); | ||
|
|
Comment on lines
19
to
32
| pub fn newFrame( | ||
| fb_width: u32, | ||
| fb_height: u32, | ||
| fb_sx: f32, | ||
| fb_sy: f32, | ||
| view: *const anyopaque, // NSView* | ||
| render_pass_descriptor: *const anyopaque // MTL::RenderPassDescriptor* | ||
| render_pass_descriptor: *const anyopaque, // MTL::RenderPassDescriptor* | ||
| ) void { | ||
| backend_osx.newFrame(view); | ||
| ImGui_ImplMetal_NewFrame(render_pass_descriptor); | ||
|
|
||
| gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); | ||
| gui.io.setDisplayFramebufferScale(1.0, 1.0); | ||
| gui.io.setDisplayFramebufferScale(fb_sx, fb_sy); | ||
|
|
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.
Relates to #42 and #102