BACKENDS: Add SDL3 backend + update imgui#6312
Conversation
|
Since there are a lot of repeated |
Thanks for your advice. Here is an example with static functions: Before: #if SDL_VERSION_ATLEAST(3, 0, 0)
if (!SDL_AddGamepadMappingsFromFile(file.getPath().toString(Common::Path::kNativeSeparator).c_str()))
#else
if (SDL_GameControllerAddMappingsFromFile(file.getPath().toString(Common::Path::kNativeSeparator).c_str()) < 0)
#endif
error("File %s not valid: %s", file.getPath().toString(Common::Path::kNativeSeparator).c_str(), SDL_GetError());After with static functions: static bool gameControllerAddMappingsFromFile(const char *file) {
#if SDL_VERSION_ATLEAST(3, 0, 0)
return SDL_AddGamepadMappingsFromFile(file);
#else
return SDL_GameControllerAddMappingsFromFile(file) >= 0;
#endif
}
...
if (!gameControllerAddMappingsFromFile(file.getPath().toString(Common::Path::kNativeSeparator).c_str()))
error("File %s not valid: %s", file.getPath().toString(Common::Path::kNativeSeparator).c_str(), SDL_GetError());
|
|
Regarding the imgui update, did you add the files from the matching git commit as rest of the code? |
Yes I used the commit ocornut/imgui@cb16568 corresponding to the tag https://github.com/ocornut/imgui/releases/tag/v1.91.3 About this, I see that there is a |
Tell me if it's OK now or did you think something different? |
26a395e to
117ab44
Compare
|
d0f76eb to
fbd5a5a
Compare
I updated the patch file, but I have a lot more changes than the previous one, can you have a look @sev- please? |
There is no definite answer here... use whatever makes the code easier to read and maintain. From the three options you provided:
So, from the options above, we could either use a C-style implementation (static wrapper functions) or a C++-style implementation (different class per SDL version, inherited from a common parent class, with member functions). I personally like the C++ approach better, but function wrappers would also work just fine :) |
I made my choice already, sorry I'm not a huge fan of inheritance and I don't see the benefit of creating 1 class by version. |
That's fine :) Nice implementation! |
|
Thank you for looking into this! I wanted to give it a try on Mingw64, and currently it seems that Win32 isn't fully supported yet: I quickly went through the release notes and indeed it looks like |
That's nice of you, thank you. |
sev-
left a comment
There was a problem hiding this comment.
Colossal work, thank you!
Have number of comments, mainly on formatting and suggestion to add more wrappers.
I am concerned that the code now becomes much harder to maintain with this amount of ifdefs, so maybe splitting files/adding more wrappers could make it easier to read and less fragile?
Sorry I've been sick for a few days, as soon as I feel better I'll take care of it. |
sev-
left a comment
There was a problem hiding this comment.
It is much cleaner now, thank you for the split of sdl-events.cpp file.
My recommendation to add a configure key --use-sdl3, so then you give preference/try to it, otherwise, put it at the end of the detection list until we perform a thorough testing.
I like the sdl-events.cpp splut, the code looks much much cleaner, though, of course, somebody has to modify it in three places if any enhancements are added (relatively unlikely).
I wonder, does it make sense to do[sdl-graphics.cpp file? or it will be way too much?
I left a few small comments here and there, mostly on the formatting. as the code is pretty clean.
Also, did you test the backend with testbed? And also, perhaps testbed needs to be enhanced with test for the multifinger taps?
I feel that the code is less clean after the split because of the amount of duplication that could be avoided by simply using defines for the renamed functions, similarly to what we did when we first moved to SDL2 in commit 8530997. |
c61c064 to
199537a
Compare
I need to do the test with SDL1, then SDL2, then SDL3, right ? Another bug: the ImGui window can't be moved outside the main window.
I'm not sure I'm the best person to do that, but I can give a try if you want. |
|
amigaos4 has just gotten an sdl3 rc not tested and i won't be able to do it anymore, but i guess sdl3 support will be possible |
500cff7 to
d365f34
Compare
So it could be useful to do these changes for amigaos, I did the changes, I have no way to test it ;) |
|
thank you very much |
This one is fixed now! |
|
@scemino any plans to regenerate the patch so it shows less diff? |
|
I would like to merge it, so I could subsequently update ImGui, and the patch stays in the way. |
For me it seems correct, the only big differences is the addition of |
I can drop my modifications on the patch, you want me to do that? |
No, it is not correct. You did not provide the paths exactly as it was before, as a result, we have a lot of noise like: - diff --color -rbu ./backends/imgui_impl_opengl3.cpp - ../scummvm/scummvm/backends/imgui/backends/imgui_impl_opengl3.cpp
- --- ./backends/imgui_impl_opengl3.cpp 2024-10-07 18:21:01
- +++ ../scummvm/scummvm/backends/imgui/backends/imgui_impl_opengl3.cpp 2024-10-07 18:30:56
+ diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp
+ index 770f85f4..b363ba07 100644
+ --- a/backends/imgui_impl_opengl3.cpp
+ +++ b/backends/imgui_impl_opengl3.cpp
@@ -114,7 +114,7 @@
#define _CRT_SECURE_NO_WARNINGS
#endif
-
+I am asking to do this for conistency, otherwise we end up with changing it every time. |
Sorry I'm not able to do it: I removed the modifications on the patch. |
because it is NOT git. it is plain Quoting my early reply:
Also, there are conflicts now, so the thing has to be rebased. |
I am using the patch for applying the changes on the ImGui upgrade. What is your proposed solution to this? |
OK I understand now, sorry about that. |
|
Thank you, merging. |
| if test -z "$_sdlconfig"; then | ||
| echo "none found!" | ||
| exit 1 | ||
| _sdlconfig="pkg-config sdl3" |
There was a problem hiding this comment.
Ugh, I did not realize, that this breaks completely systems without pkg-config. Like mine....
|
Thank you! Do you plan to add it also for create_project? |
This PR modifies the current SDL backend to add SDL3 support.
There are a lot of combinations so don't hesitate to read it carefully and/or test it.
I didn't test the SDL3_net library.
This is the first time I modify the configure file, so have a look and tell me if I need to do some changes (I'm sure you will ;)).
And maybe the way I handled all the
#ifdefare not at your taste, so feel free to give some advice.To do this PR I used these recommendations: https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md and of course https://wiki.libsdl.org/SDL3/CategoryAPI