Skip to content

Commit

Permalink
Add SDL 3 support to all SDL backends
Browse files Browse the repository at this point in the history
Improvements to both SDL 2 and SDL 3:
- Keyboard is activated and deactivated when focusing text input fields.
- Text input events are only submitted when text input fields are focused.

SDL 3-specific improvements:
- Enables positioning of the input method editor (IME) to the text cursor.

SDL_GL2-specific improvements:
- Use OpenGL directly instead of the SDL renderer, just like the SDL_GL3 renderer.
- GLEW is no longer required, stop linking to it.

By default, CMake will now first look for SDL 3, and only if that is not found, it will look for SDL 2. To override the automatic selection, set `RMLUI_SDL_VERSION_MAJOR` to the desired version (2 or 3). Here, an empty value means default (automatic) behavior.
  • Loading branch information
mikke89 committed Dec 28, 2024
1 parent b261d16 commit 01fc3c4
Show file tree
Hide file tree
Showing 11 changed files with 811 additions and 337 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install Dependencies
run: |-
sudo apt-get update
sudo apt-get install cmake ninja-build libsdl2-dev libsdl2-image-dev libfreetype6-dev libharfbuzz-dev libglew-dev liblua5.2-dev libsfml-dev librlottie-dev libglfw3-dev
sudo apt-get install cmake ninja-build libsdl2-dev libsdl2-image-dev libfreetype6-dev libharfbuzz-dev liblua5.2-dev libsfml-dev librlottie-dev libglfw3-dev
- name: Configure CMake
run: >-
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Install Dependencies
run: |-
sudo apt-get update
sudo apt-get install cmake ninja-build libsdl2-dev libsdl2-image-dev libfreetype6-dev libharfbuzz-dev libglew-dev liblua5.2-dev libglfw3-dev
sudo apt-get install cmake ninja-build libsdl2-dev libsdl2-image-dev libfreetype6-dev libharfbuzz-dev liblua5.2-dev libglfw3-dev
- name: Configure CMake
run: >-
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
run: |-
C:\msys64\usr\bin\bash -lc ("pacman --needed --noconfirm --sync " +
"mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-freetype mingw-w64-x86_64-lua " +
"mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-glew")
"mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image")
- name: Configure CMake
run: |-
Expand Down
8 changes: 4 additions & 4 deletions Backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ target_sources(rmlui_backend_SDL_GL2 INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Platform_SDL.h"
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_GL2.h"
)
target_link_libraries(rmlui_backend_SDL_GL2 INTERFACE rmlui_backend_common_headers OpenGL::GL SDL2::SDL2 GLEW::GLEW SDL2_image::SDL2_image)
target_link_libraries(rmlui_backend_SDL_GL2 INTERFACE rmlui_backend_common_headers OpenGL::GL SDL::SDL SDL_image::SDL_image)

add_library(rmlui_backend_SDL_GL3 INTERFACE)
target_sources(rmlui_backend_SDL_GL3 INTERFACE
Expand All @@ -70,7 +70,7 @@ target_sources(rmlui_backend_SDL_GL3 INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_GL3.h"
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Include_GL3.h"
)
target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE rmlui_backend_common_headers SDL2::SDL2 SDL2_image::SDL2_image)
target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE rmlui_backend_common_headers SDL::SDL SDL_image::SDL_image)
if(UNIX)
# The OpenGL 3 renderer implementation uses dlopen/dlclose
# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
Expand All @@ -91,7 +91,7 @@ target_sources(rmlui_backend_SDL_VK INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Include_Vulkan.h"
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Vulkan/ShadersCompiledSPV.h"
)
target_link_libraries(rmlui_backend_SDL_VK INTERFACE rmlui_backend_common_headers SDL2::SDL2)
target_link_libraries(rmlui_backend_SDL_VK INTERFACE rmlui_backend_common_headers SDL::SDL)
if(UNIX)
# The Vulkan renderer implementation uses dlopen/dlclose
# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
Expand All @@ -106,7 +106,7 @@ target_sources(rmlui_backend_SDL_SDLrenderer INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Platform_SDL.h"
"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_SDL.h"
)
target_link_libraries(rmlui_backend_SDL_SDLrenderer INTERFACE rmlui_backend_common_headers SDL2::SDL2 SDL2_image::SDL2_image)
target_link_libraries(rmlui_backend_SDL_SDLrenderer INTERFACE rmlui_backend_common_headers SDL::SDL SDL_image::SDL_image)

add_library(rmlui_backend_SFML_GL2 INTERFACE)
target_sources(rmlui_backend_SFML_GL2 INTERFACE
Expand Down
Loading

0 comments on commit 01fc3c4

Please sign in to comment.