Skip to content

Commit

Permalink
Third parameter of SDL_CreateRenderer was removed in SDL3
Browse files Browse the repository at this point in the history
  • Loading branch information
texus committed May 14, 2024
1 parent 60c4357 commit 7f47636
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions examples/android/SDL_RENDERER/app/jni/src/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@
#include <TGUI/TGUI.hpp>
#include <TGUI/Backend/SDL-Renderer.hpp>

// Make some defines to keep the code below compatible with both SDL2 and SDL3
#if SDL_MAJOR_VERSION >= 3
#include <SDL3/SDL_main.h>
#define DEFAULT_RENDERING_DRIVER nullptr
#define SDL_WINDOW_SHOWN 0
#define SDL_RENDERER_ACCELERATED 0
#define SDL_CreateWindow SDL_CreateWindowWithPosition
#else
#define DEFAULT_RENDERING_DRIVER -1
#endif

// The background image will rotate with the screen
Expand Down Expand Up @@ -105,11 +98,18 @@ int main(int, char**)

// TGUI requires a window created with the SDL_WINDOW_OPENGL flag and an OpenGL context.
// SDL_WINDOW_RESIZABLE is needed to support screen rotations.
#if SDL_MAJOR_VERSION >= 3
SDL_Window* window = SDL_CreateWindow("TGUI window with SDL",
800, 600, // ignored because of SDL_WINDOW_FULLSCREEN_DESKTOP flag
SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_RESIZABLE);
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
#else
SDL_Window* window = SDL_CreateWindow("TGUI window with SDL",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
800, 600, // ignored because of SDL_WINDOW_FULLSCREEN_DESKTOP flag
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_RESIZABLE);
SDL_Renderer* renderer = SDL_CreateRenderer(window, DEFAULT_RENDERING_DRIVER, SDL_RENDERER_ACCELERATED);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
#endif

SDL_SetRenderDrawColor(renderer, 240, 240, 240, 255);

Expand Down
2 changes: 1 addition & 1 deletion examples/main-SDL_RENDERER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(int, char **)

#if SDL_MAJOR_VERSION >= 3
SDL_Window* window = SDL_CreateWindow("TGUI example (SDL-Renderer)", 800, 600, 0);
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr, 0);
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
#else
SDL_Window* window = SDL_CreateWindow("TGUI example (SDL-Renderer)",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultBackendWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace tgui

#if TGUI_HAS_BACKEND_SDL_RENDERER
#if SDL_MAJOR_VERSION >= 3
m_renderer = SDL_CreateRenderer(m_window, nullptr, 0);
m_renderer = SDL_CreateRenderer(m_window, nullptr);
#else
m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED);
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct TestsWindowDefault : public TestsWindowBase
window = SDL_CreateWindow(windowTitle,
windowWidth, windowHeight,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
renderer = SDL_CreateRenderer(window, nullptr, 0);
renderer = SDL_CreateRenderer(window, nullptr);
#else
window = SDL_CreateWindow(windowTitle,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
Expand Down

0 comments on commit 7f47636

Please sign in to comment.