terraspace
Posts: 76
Joined: Mon Dec 03, 2018 3:56 pm

SDL2 issues

Tue Dec 11, 2018 9:32 am

Hi,

So I followed the guide here:
https://choccyhobnob.com/raspberry-pi/s ... pberry-pi/

And tweaked slightly based on https://github.com/FrankBau/raspi-repo- ... /wiki/SDL2

To try and get an SDL2 install that works from console.

SDL2 builds and installs perfectly. However, no matter what I do when I try to use it

SDL_Init(SDL_INIT_VIDEO) always errors with no video device available.

I've tried using int driverCount = SDL_GetNumVideoDrivers(); which is reporting a list available dummy, wayland and x11.

Has anyone else had this problem or have any suggestions ?
In addition I've also seen posts that even for those who have this working it won't work via GDB / remote debugging, is that the case ?

Thanks,
John

terraspace
Posts: 76
Joined: Mon Dec 03, 2018 3:56 pm

Re: SDL2 issues

Wed Dec 12, 2018 10:46 am

So I re-followed all the steps and create a new simple test application which is now all working. So SDL2 2.0.9 is working perfectly on the pi from the console.

Now I have another problem :) I'm running all the code and debugging from Visual Studio 2017 (on pc), I've tried using GDB and GDBServer but neither option will allow SDL_Init to work.. All my other graphics related code using omx/dispmanx etc has worked fine via this remote debugging and all it's output is directed to the pi's actual connected hdmi display. This is not the case for SDL. It seems that whatever SDL init does internally needs to obtain a display which it can't via the remote debugging.

Any ideas? (Apart from migrating the entire project into VisualGDB which seems like a far more capable tool).

jdonald
Posts: 385
Joined: Fri Nov 03, 2017 4:36 pm

Re: SDL2 issues

Sun Jul 28, 2019 6:40 pm

The linked guide does not look entirely correct. To build SDL2 without X11 support you need to explicitly add —disable-video-x11. Or if you build it with both X11 and dispman support, you’ll need to to specify SDL_VIDEODRIVER=rpi at runtime.

The above is for the legacy driver. For rendering from the console on a Pi 4 you’ll need to sudo apt install libdrm-dev libgbm-dev and check SDL’s ./configure --enable-video-kmsdrm --disable-video-x11 --disable-video-rpi output to ensure it builds with the kmsdrm video mode.

Return to “Graphics programming”