Skip to content

Port Window.c and crt.c from SDL2 to SDL3 - #137

Open
Grosama wants to merge 1 commit into
megamarc:masterfrom
Grosama:master
Open

Port Window.c and crt.c from SDL2 to SDL3#137
Grosama wants to merge 1 commit into
megamarc:masterfrom
Grosama:master

Conversation

@Grosama

@Grosama Grosama commented Apr 14, 2026

Copy link
Copy Markdown

Changes in Window.c and crt.c:

  • Replace SDL_WINDOW_FULLSCREEN_DESKTOP with SDL_WINDOW_FULLSCREEN
  • Replace SDL_CreateWindow signature (removed x/y position params)
  • Replace SDL_CreateRenderer (removed index and flags params)
  • Add SDL_SetRenderVSync for vsync control
  • Replace SDL_RenderCopy with SDL_RenderTexture
  • Replace SDL_ShowCursor with SDL_HideCursor
  • Replace SDL_PRESSED/SDL_RELEASED with bool down in events
  • Replace SDL_QUIT/SDL_KEYDOWN etc with SDL_EVENT_* equivalents
  • Replace keysym.sym/mod with key/mod in SDL_KeyboardEvent
  • Replace SDL_JoystickGetAttached with SDL_JoystickConnected
  • Replace SDL_JoystickClose with SDL_CloseJoystick
  • Replace SDL_NumJoysticks with SDL_HasJoystick
  • Replace SDL_QueryTexture with SDL_GetTextureSize
  • Replace SDL_CreateRGBSurface with SDL_CreateSurface
  • Replace SDL_HINT_RENDER_SCALE_QUALITY with SDL_SetTextureScaleMode
  • Fix SDL_Init return type (bool in SDL3)
  • Use SDL_FRect instead of SDL_Rect for render destination

Tested on Windows with MSYS2 MinGW64 toolchain and SDL3 3.4.2.
Note: CMakeLists.txt may need adjustments depending on how SDL3 is installed on your platform.

- Replace SDL_WINDOW_FULLSCREEN_DESKTOP with SDL_WINDOW_FULLSCREEN
- Replace SDL_CreateWindow signature (removed x/y position params)
- Replace SDL_CreateRenderer (removed index and flags params)
- Add SDL_SetRenderVSync for vsync control
- Replace SDL_RenderCopy with SDL_RenderTexture
- Replace SDL_ShowCursor with SDL_HideCursor
- Replace SDL_PRESSED/SDL_RELEASED with bool down in events
- Replace SDL_QUIT/SDL_KEYDOWN etc with SDL_EVENT_* equivalents
- Replace keysym.sym/mod with key/mod in SDL_KeyboardEvent
- Replace SDL_JoystickGetAttached with SDL_JoystickConnected
- Replace SDL_JoystickClose with SDL_CloseJoystick
- Replace SDL_NumJoysticks with SDL_HasJoystick
- Replace SDL_QueryTexture with SDL_GetTextureSize
- Replace SDL_CreateRGBSurface with SDL_CreateSurface
- Replace SDL_HINT_RENDER_SCALE_QUALITY with SDL_SetTextureScaleMode
- Fix SDL_Init return type (bool in SDL3)
- Use SDL_FRect instead of SDL_Rect for render destination
@daltomi

daltomi commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR.
A quick test, just out of curiosity, how SDL3 works on my hardware, without any compiler flag changes or anything.
I don't know any other way to test so I used the program that Tilengine comes with: ./benchmark
I didn't have to adjust anything for CMake, it works perfect.

On my low-end hardware.

gcc (GCC) 15.2.1 20260209 
Artix Linux - Kernel 7.0.0-x64v3-xanmod1
Mesa 1:26.0.5-1 
AMD Ryzen 3 3200G with Radeon Vega Graphics (Integrated graphics)
Captura de pantalla_2026-04-22_02-38-44

Edit:

WYSIWYG, IANARS ICUDK
My test is useless.
I have the sdl2-compat package installed, which uses the SDL3 library behind the scenes.

Arch Linux replaced their SDL2 package with sdl2-compat
LOL

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