6

I have compiled my SDL game on the PI. I used apt to install the SDL 1.2 dev package. When I call SDL_SetVideoMode, it fails and this is the SDL error string.

couldn't find matching glx visual

What I have tried so far was changing my bits per pixel parameter from 32 down to 24 and 16 with no change. I have also googled similar problems but it's getting me nowhere. I would like to understand this from first principles. It is the last function call that fails and returns null.

if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
  return false;

const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
if (!videoInfo) {
  fprintf(stderr, "Video query failed: %s\n",
     SDL_GetError());
  return false;
}

/* the flags to pass to SDL_SetVideoMode */
videoFlags = SDL_OPENGL;       /* Enable OpenGL in SDL */
videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */

/* This checks to see if surfaces can be stored in memory */
if (videoInfo->hw_available)
  videoFlags |= SDL_HWSURFACE;
else
  videoFlags |= SDL_SWSURFACE;

widthViewport = videoInfo->current_w;
heightViewport = videoInfo->current_h;
videoFlags |= SDL_FULLSCREEN;

/* This checks if hardware blits can be done */
if (videoInfo->blit_hw)
  videoFlags |= SDL_HWACCEL;

/* Sets up OpenGL double buffering */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

/* get a SDL surface */
TRACE("SDL_SetVideoMode\n");
surface = SDL_SetVideoMode(widthViewport, heightViewport, 
  32, videoFlags);

/* Verify there is a surface */

if (!surface) {
  fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError());
  return false;
}
ScrollerBlaster
  • 489
  • 1
  • 5
  • 12

1 Answers1

5

I had the same problem in this question. To fix it:

sudo apt-get install libgl1-mesa-swx11

Be warned though, GLX is not hardware accelerated as of answering this question, so things will probably run very slow.

syb0rg
  • 8,178
  • 4
  • 38
  • 51