News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

SDL 3

Started by Matei, November 01, 2025, 09:49:04 AM

Previous topic - Next topic

Matei

Quote from: Matei on November 21, 2025, 11:03:44 PMfullscr=0 - the controls didn't work,

Actually they did but the image doesn't update. Edited file graphics/graph2d.c, lines 276...:

#elif SDLVER==2
  if(RGLOB_initgr==0){printf("display(): Screen not initialized\r\n"); exit(1);}
  if(SDL_UpdateWindowSurface(RGLOB_window)<0){
    printf("%s",SDL_GetError());
    exit(1);
  }
#else

Error:

QuoteWindow surface is invalid, please call SDL_GetWindowSurface() to get a new surface

Which version of xMOn@D do you have? I have 0.18.0.

Matei

https://disenchant.net/tyrquake/

Tyrquake works, but it uses "SDL_CreateRenderer()" instead of "SDL_GetWindowSurface()".

https://wiki.libsdl.org/SDL2/SDL_CreateRenderer

https://gamedev.stackexchange.com/questions/180077/in-sdl-what-is-the-difference-between-using-a-surfaces-and-a-renderer

However, unlike my game, tyrquake with SDL 2 had a very low framerate on this laptop with Fedora 14, although it worked well with X11:

https://www.miniputer.com/Acer/Aspire_3000.html

https://matei.one/gnxfed14.html

Duplode

Quote from: Matei on November 23, 2025, 05:03:16 PMWhich version of xMOn@D do you have? I have 0.18.0.

0.18.0 here as well.

Anyway, I found a reasonable workaround for me on the XMonad side: remove the borders of Simcar windows upon window creation. If I were to insist on having the borders, it would also have been possible to fix it by growing the window to account for the border, along the lines of what's described in this issue tracker comment.

Matei

Those red borders bother me when I try to view a video with MPlayer at full screen, but for the game just leave them:

https://wiki.libsdl.org/SDL3/SDL_GetWindowSizeInPixels

I will post the fixed graphics/forsdl3/graph2d.c file for you to test it (I can't), but I just found out there might be other problems:

https://wiki.libsdl.org/SDL2/SDL_GetWindowSizeInPixels

"This function is available since SDL 2.26.0."

So for SDL 2 I'll have to use this:

https://wiki.libsdl.org/SDL2/SDL_GetWindowSize

So I will also post file graphics/graph2d.c which I also can't test, so you should, because as mentioned above, my problems with SDL 2 in xMoNad are others - the pointer given by SDL_GetWindowSurface() and the size of the window change after the rendering starts (function display()).

Matei

Attached file graphics.tar.gz. First set the settings in xmoNAd back to where they were and try version from simcarstunts-6.2.0:

https://matei.one/idxscr.html#download

If the problems still occur, then download file attached here, put files graph2d.c from it in the game source, recompile and see what happens. You can also try with various resolutions in full screen (fullscr=1), with both SDL 3 and SDL 2 (ex.: 960x720).

Matei

https://xmonad.org/news/2023/10/06/wayland.html

QuoteWe think we now have enough contributions coming in monthly to pay for someone to work with us on it.

Problem is, we have no idea who can do this.

Matei

Updated game, file simcarstunts-6.2.1.tar.gz:

https://matei.one/idxscr.html#download

Xm0NaD aside, you pointed out a problem which could occur with SDL3 even with a graphical window manager that doesn't have bugs:

https://wiki.libsdl.org/SDL3/SDL_GetWindowSize

QuoteThe window pixel size may differ from its window coordinate size if the window is on a high pixel density display. Use SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to get the real client area size in pixels.

https://wiki.libsdl.org/SDL3/SDL_CreateWindow

QuoteThe window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.

Solved that, but int SDL 2 there are a few differences:

https://wiki.libsdl.org/SDL2/SDL_CreateWindow

QuoteIf the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size in pixels may differ from its size in screen coordinates on platforms with high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the client area's size in screen coordinates,

I didn't create the window with the SDL_WINDOW_ALLOW_HIGHDPI flag, so here I could get the width and height in pixels with SDL_GetWindowSize(). I still have problems with SDL 2 because of some bug(s) in xm0Nad, but I ~solved those too, details in file SDL.txt from the archive mentioned above.