Skip to content
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

[DRAFT] SDL3_renderer and SDL_gpu support #772

Closed
wants to merge 4 commits into from

Conversation

zoogies
Copy link

@zoogies zoogies commented Feb 6, 2025

I plan on starting SDL_gpu soon, but I've fully implemented the SDL3_renderer backend.

Main changes:

Considerations:

  • I've had to #include <stddef.h> for offsetof, but the sdl2_renderer backend doesn't do this. I'm assuming that @RobLoach knows where these Nuklear backend definitions are

Relevant:

@zoogies zoogies marked this pull request as draft February 6, 2025 23:20
@zoogies
Copy link
Author

zoogies commented Feb 6, 2025

It's worth mentioning that the default text input event behavior has changed from SDL2 to SDL3.

In SDL2 the events were fired on keypresses by default on desktop, but not mobile. In SDL3, these events are never fired until SDL_StartTextInput() is called. This function will also force showing the on-screen keyboard on devices that support it, so if this demo is adapted for other platforms the call to SDL_StartTextInput() should be moved out of SDL_AppInit()

@RobLoach
Copy link
Contributor

RobLoach commented Feb 8, 2025

Looking great! Both demos worked well here. Couple questions...

  1. Do you think we should move the demos to an sdl3 folder or something to help consolidate them? Could save on CMake definitions then.

  2. I've had to #include <stddef.h> for offsetof, but the sdl2_renderer backend doesn't do this. I'm assuming that @RobLoach knows where these Nuklear backend definitions are

    That seems fine with me. If an NK_OFFSETOF doesn't exist, we could introduce one.

  3. In SDL3, these events are never fired until SDL_StartTextInput() is called

    Think that's worth avoiding a merge? Or just do it?

@zoogies
Copy link
Author

zoogies commented Feb 8, 2025

Currently, the SDL_gpu backend is just using sdl_renderer, but I'm going to switch it over (hopefully tomorrow) and I'll convert this PR from a draft into a regular PR when I finish 😄

Do you think we should move the demos to an sdl3 folder or something to help consolidate them? Could save on CMake definitions then.

Personally, I like the current setup of each backend having its own folder in demo/

That seems fine with me. If an NK_OFFSETOF doesn't exist, we could introduce one.

For some reason, offsetof is properly defined in the existing SDL2 renderer backend without stddef.h. Maybe there already is a Nuklear version floating around?

Think that's worth avoiding a merge? Or just do it?

What do you mean by merge? In this case, I think the only change worth making is adding a big comment above the SDL_StartTextInput() call to explain it, since it's relevant for any developers using the demo as a reference

Also, I had to link both demos against libm due to a linker error about a missing floor implementation. Not sure if you have any ideas? (I've put TODO comments around anything like this that I think deserves review)

@RobLoach
Copy link
Contributor

RobLoach commented Feb 8, 2025

I like the current setup of each backend having its own folder in demo/

We do adopt that pattern for the rawfb ones. It's kind of nice having a consolidated one, could possibly save some code:
https://github.com/Immediate-Mode-UI/Nuklear/tree/master/demo/rawfb

We could in theory have a nuklear_sdl3.h that contains the input handling, and then calls either the GPU or renderer functions depending on which is picked.

What do you mean by merge?

Apologies. I meant merge the pull request as is. But sounds like we should wait off.

@zoogies
Copy link
Author

zoogies commented Feb 20, 2025

I've gotten pretty busy lately, but this PR is still on my mind. Pretty soon I hope to get back around to implementing the SDL_gpu backend, but it will likely take me a while as I've never worked with it before.

We could in theory have a nuklear_sdl3.h that contains the input handling, and then calls either the GPU or renderer functions depending on which is picked.

This is a good point. Personally I think it makes the most sense to keep them separate, but we can see what the overlap looks like once the SDL_gpu backend is ready.

Apologies. I meant merge the pull request as is. But sounds like we should wait off.

@RobLoach if you would like, I can split the unfinished SDL_gpu work into a separate PR, and clean this one up for merge. Let me know what you'd prefer 😄

@RobLoach
Copy link
Contributor

No worries. I can clean this up and get things in place. Thanks so much for the push forwards here 👀

@RobLoach
Copy link
Contributor

#779

@RobLoach RobLoach closed this Feb 22, 2025
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