Skip to content

Conversation

suboyar
Copy link

@suboyar suboyar commented Aug 9, 2025

I have ported sdl_renderer to SDL3.

Changes from sdl_renderer to sdl3_renderer:

  • Update function names and types for SDL3 API changes
  • Remove deprecated flags (e.g. SDL_WINDOW_SHOWN)
  • Use the new SDL_PropertiesID system
  • Remove legacy Metal cliprect workaround (no longer needed)
  • Switch vertex colors from byte values (0-255) to floating point (0-1)

sleeptightAnsiC added a commit to sleeptightAnsiC/Nuklear that referenced this pull request Sep 1, 2025
Apply 825.diff from:
Immediate-Mode-UI#825
which adds updated backend for SDL3 Renderer
Hopefully, it will work just fine (untested)
Big thanks to github.com/suboyar
@sleeptightAnsiC
Copy link

There is already an advanced PR for SDL3 demo which uses SDL_renderer, see #779
Does this PR have any advantages over the other one? or is it just a duplicate?

@suboyar
Copy link
Author

suboyar commented Sep 7, 2025

I skimmed through #779, nuklear_sdl3_renderer.h seem quite similar, while their nuklear_sdl3_renderer.c (compared to my main.c) is missing some initialization property and uses SDL's own main callback. While I tried to make a 1:1 implementation of the provided sdl2 demo.

As for why I made this PR, I searched for "SLD3 renderer demo" which didn't yield any results.

@sleeptightAnsiC
Copy link

sleeptightAnsiC commented Sep 9, 2025

their nuklear_sdl3_renderer.c (compared to my main.c) is missing some initialization property

Is there anything important/critical in those properties? If not, this isn't really a problem since *.c files are more of an example. Having less code in them would be even preferable.

[their nuklear_sdl3_renderer.c] uses SDL's own main callback

It is now preferred to use those callbacks in SDL3, see https://wiki.libsdl.org/SDL3/README-main-functions

I tried to make a 1:1 implementation of the provided sdl2 demo.

Actually, the other PR is missing nk_sdl_handle_grab which I mentioned here #779 (comment) It also does not have Makefile (uses Cmake for some reason) and doesn't follow naming conventions for it's folders/files (compared to other demos).

As for why I made this PR, I searched for "SLD3 renderer demo" which didn't yield any results.

Yea, I also had this issue. I started working with your PR, then realized that #779 exists. IMO, the other PR has really misleading name...

@suboyar Anyway, I'm currently working on #779 since there are more people involved there, but would love to know if the other PR misses anything that your PR solves better.


Uint64 now = SDL_GetTicks();
sdl.ctx.delta_time_seconds = (float)(now - sdl.time_of_last_frame) / 1000;
sdl.time_of_last_frame = now;
Copy link

@sleeptightAnsiC sleeptightAnsiC Sep 9, 2025

Choose a reason for hiding this comment

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

Is sdl.ctx.delta_time_seconds being used anywhere? I think that #779 is missing this one. I was also wondering, if we could use delta time for proper double-click (mentioned here)

EDIT: ahh, now I understand, Nuklear needs this for hiding scroll bar!

/tmp/Nuklear/src $ grep -rn 'delta_time_seconds' .
./nuklear_panel.c:493:            window->scrollbar_hiding_timer += ctx->delta_time_seconds;
./nuklear.h:5737:    float delta_time_seconds;

@sleeptightAnsiC sleeptightAnsiC mentioned this pull request Sep 9, 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