Hello,
I have to develop a SDL2 application on RaspberryPi.
So, I first tried to install everything based on this tuto.
But building SDL2 library cause some problems.
First, the build is normally based on SDL2-2.0.5.tar.gz (wget http://www.libsdl.org/release/SDL2-2.0.5.tar.gz).
But make install create a /usr/local/lib/libSDL2-2.0.so.0.4.1 library. Seems not normal, right?
In this tuto, SDL2 is configured to not use libPulseAudio:
./configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-opengl --host=arm-raspberry-linux-gnueabihf
But when I launch my app, I see a window flickering, then it complains for a missing libPulse configuration file:
W: [pulseAudio] core-util.c Failed to open configuration file "/home/pi/......."
Then, I get a renderer creation problem.
Falied to create renderer : couldn’t matching render driver
Finally, I tried to download RaspberryPi prebuilt lib from buildbot libsd .org … sdl-raspberrypi-2166.tar.xz (2017-08-25)
And I still get the same errors about libPulse and renderer creation fail.
Info: I try to launch my app from a bash in X11 Raspbian desktop. (Linux 4.4.34-v7+ #930 armv71)
Hardware: BCM2709
Revision : a01041
How can I get SDL2 working please?
My code is:
int main(int argc, char** argv)
{
if (SDL_Init(SDL_INIT_VIDEO) != 0 )
{
fprintf(stdout,"Fail to initalize SDL (%s)\n",SDL_GetError());
return -1;
}
if(TTF_Init()==-1)
{
printf("TTF_Init: %s\n", TTF_GetError());
exit(2);
}
SDL_Window* pWindow = NULL;
pWindow = SDL_CreateWindow("Test SDL2",100,
100,
800,
600,
SDL_WINDOW_SHOWN);
if( pWindow )
{
SDL_Renderer *pRenderer = SDL_CreateRenderer(pWindow,-1,SDL_RENDERER_ACCELERATED);
if ( pRenderer )
{
SDL_RendererInfo info;
SDL_GetRendererInfo(pRenderer, &info);
fprintf(stderr, "name : %s\n", info.name);
fprintf(stderr, "flags : ");
if (info.flags & SDL_RENDERER_SOFTWARE) fprintf(stderr, "SDL_RENDERER_SOFTWARE");
if (info.flags & SDL_RENDERER_ACCELERATED) fprintf(stderr, "SDL_RENDERER_ACCELERATED ");
if (info.flags & SDL_RENDERER_PRESENTVSYNC) fprintf(stderr, "SDL_RENDERER_PRESENTVSYNC ");
if (info.flags & SDL_RENDERER_TARGETTEXTURE) fprintf(stderr, "SDL_RENDERER_TARGETTEXTURE ");
fprintf(stderr, "\nnb textures max : %d\n", info.num_texture_formats);
fprintf(stderr, "texture size max : %d x %d \n", info.max_texture_width, info.max_texture_height);
int numDrivers = SDL_GetNumVideoDrivers();
fprintf(stderr, "num Drivers %d\n", numDrivers);
for (int i = 0; i < numDrivers; i++)
{
fprintf(stderr, "possible driver : %s\n", SDL_GetVideoDriver(i));
}
fprintf(stderr, "current driver : %s\n", SDL_GetCurrentVideoDriver());
SDL_SetRenderDrawBlendMode(pRenderer, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(pRenderer,0,0,0,255);
SDL_RenderClear(pRenderer);
SDL_RenderPresent(pRenderer); // Affichage
while (1) sleep(1);
SDL_DestroyRenderer(pRenderer);
}
else
{
fprintf(stdout,"fail to createrenderer (%s)\n",SDL_GetError());
}
SDL_DestroyWindow(pWindow);
}
else
{
fprintf(stderr,"Fail to create window: %s\n",SDL_GetError());
}
SDL_Quit();
return 0;
}