-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL3 Platform Support #59
base: main
Are you sure you want to change the base?
Conversation
26c2ad5
to
1e750b9
Compare
SDL Window ahoy... It's looking kinda messy behind the scenes, but it was just to get to this point. Now I can walk some stuff back or clean some things up. Screencast_20240930_155527.mp4 |
Whoah, that is great progress! |
Ok, so now you can freely use either backend:
Please excuse the wide overreach in the current diff. I tried something, and didn't want to push something that didn't build. I'll reverse a lot of the platform module restructure. I found the platform/app.zig situation to be pretty confusing. I thought that the platform module itself already provided the public api so there was no need for It also made things a bit easier to reckon with in terms of the build time selection of the backend and simplified some of the imports else where in the platform files. I still think that there can be a better name for I'll noodle a bit and start reverting the changes to the examples. :D |
Yeah, is a bit confusing right now. The top level I like the idea of the platform layer holding the common code, and then the actual backends just needing to implement a small set of functions instead of there being a bunch of copy+paste between backends, but this is the first time this has been tried so I'm sure some changes will shake out of it. |
Yep, that's the right way to go. I've reverted things so the diff is readable again. |
I added github actions that build things with both backends. Windows and Linux are working (I haven't tested windows binaries yet... need to find a machine to set windows up on) and I've fixed the build so that SDL is only actually built when you select that backend. I'm going to base the imgui event handling on what I see with sokol app, I believe another keyboard map will be needed, but I think otherwise it's fairly simple. That will mean there needs to be more considerations for swapping out the RHI (if this is the right way to think of sokol vs SDL_gpu vs ). But this definitely makes it clear that working on the platform stuff first while maintaining sokol was the right idea. :D I believe emscripten could be supported with SDL3. Unfortunately it's not part of the emsdk yet so I'll try to build it. It would be sweet to have gamepads for that target. Also, I plan to rebase and squash all my garbage commits soon. |
Ok, ImGUI hooked back up. Need to try and seal the deal on building for each platform now. trying to line up some way to actually test them |
This is some serious progress! Making the builds only include SDL3 when needed is huge, that's exactly the kind of thing I've been thinking about as it makes cross platform builds way easier when the dependency list is smaller. This seems really close to having a new app layer backend. |
😮💨 realized I was running sokol_app unintentionally lol |
Ok, build of SDL for emscripten is working. The mainloop is still not set up correctly though. This is more what I expected originally. I also just realized that even for the sokol backend, the windows builds aren't initializing sokol_gfx correctly. So I'll figure out what I broke. :D Obviously there shouldn't be any change in behavior or results for that backend! |
- Select backend using `-Dplatform_backend=X` where X is 'sdl' or 'sokol' - Default backend is sokol - Adds SDL build to 3rdparty - SDL is only built when selected - Add GitHub actions to ensure the build works for supported targets - Renamed AppBackendConfig => PlatformHooks - Linux and Emscripten Ahoy! (Windows and MacOS pending) - sokol_gfx swapchain parameters initialized differently for SDL
21407ef
to
621f01f
Compare
Alright, so SDL builds and runs under emscripten, but I'm learning that sokol_app definitely handles a lot of details regarding the viewport and surface under emscripten. |
I'd believe that, looking through the Sokol source they seem to have a lot of checks for the web build case. |
In this case the window resizes but not the viewport being rendered into. It maintains the initially requested dimensions. If I make the window resizeable for a desktop build everything is working as expected. But for the web you end up needing to manage some things for the webgl surface to stay in sync with the canvas. On the desktop front, for windows, the combination of sokol_gfx and SDL isn’t quite done because at the beginning of the frame we need to provide a pointer to a directx device which the glue lib uses sokol_app to do. Either way, slowly getting there. :) |
Resizing isn't handled yet by the Delve Framework, so that behavior at least matches the current Sokol implementation. This is on my radar to flesh out though |
As discussed in #40, this PR is the WIP for having SDL3 support.
My expectation is that this will get a bit messy, but ultimately a squash before merging will trim any of the missteps and so on.
Current Goals: