Skip to content

Adding backend sdl3 + opengl3 #44

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 10, 2025
Merged

Adding backend sdl3 + opengl3 #44

merged 1 commit into from
May 10, 2025

Conversation

tonitch
Copy link
Contributor

@tonitch tonitch commented May 9, 2025

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?

Copy link
Member

@hazeycode hazeycode left a comment

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
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
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.

Copy link
Member

@hazeycode hazeycode May 10, 2025

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
Member

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants