Skip to content

newFrame framebuffer scale#105

Open
hazeycode wants to merge 1 commit into
mainfrom
framebuffer-scale
Open

newFrame framebuffer scale#105
hazeycode wants to merge 1 commit into
mainfrom
framebuffer-scale

Conversation

@hazeycode
Copy link
Copy Markdown
Member

Relates to #42 and #102

Copy link
Copy Markdown

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

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 newFrame functions to accept fb_sx/fb_sy and pass them to io.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 thread src/backend_glfw_wgpu.zig
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 thread src/backend_glfw_dx12.zig
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 thread src/backend_sdl3_gpu.zig
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 thread src/backend_osx_metal.zig
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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants