Skip to content

Adding backend sdl3 + opengl3#44

Merged
hazeycode merged 1 commit into
zig-gamedev:mainfrom
tonitch:main
May 10, 2025
Merged

Adding backend sdl3 + opengl3#44
hazeycode merged 1 commit into
zig-gamedev:mainfrom
tonitch:main

Conversation

@tonitch

@tonitch tonitch commented May 9, 2025

Copy link
Copy Markdown
Contributor

I needed it, so might as well share it.

Hopefully, it's in the required codestyle.

PS: I really like zig-gamedev. Is there any place where we could discuss? irc/discord/forum?

@hazeycode hazeycode left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good other than the one comment. Thanks!

backend_sdl3.newFrame();

gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height)));
gui.io.setDisplayFramebufferScale(1.0, 1.0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the order of things here is wrong. But we can come back to it. See the open PR re DPI scaling.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I based this on the sdl2_opengl backend ^^. except that I do the opengl newframe before sdl3 newframe.
I seen that here:
https://github.com/ocornut/imgui/blob/f484af34c2014e98a64410e6cd81e1a5ab434bfd/examples/example_sdl3_opengl3/main.cpp#L162C12-L165C1
But tbh I think the order has no importance as the init before that is in the reverse order.

@hazeycode hazeycode May 10, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, fractional scaling is broken for (I think) all backends. We should fix the OpenGL backends (and others) in the same fashion as the wgpu one. See issue #3 and PRs #42 and #34.

@hazeycode hazeycode merged commit 21dcc28 into zig-gamedev:main May 10, 2025
3 checks passed
@hazeycode

Copy link
Copy Markdown
Member

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