[SDL] yet another primitive 3d game engine

Douglas Jerome jerome at globalcrossing.net
Mon Nov 24 08:58:01 PST 2003


Bob Pendleton wrote:
> On Sun, 2003-11-23 at 20:29, Douglas Jerome wrote:
> 
>>Douglas Jerome wrote:
>>
>>>Hi.
>>>
[snip]
>>I have this sequence of code:
>>
>>    vidinfo = SDL_GetVideoInfo();
>>    if (vidinfo == NULL)
>>       {
>>       (void)fprintf (
>>                     stderr,
>>                     "Can't query SDL video for %s: %s.\n",
>>                     a_client, SDL_GetError()
>>                     );
>>       return NULL;
>>       }
>>
>>    bpp  = vidinfo->vfmt->BitsPerPixel;
>>    nbpp = SDL_VideoModeOK (x, y, bpp, a_flags);
>>
>>    if (nbpp == 0)
>>       {
>>       (void)fprintf (
>>                     stderr,
>>                     "Can't set SDL video mode for %s [%dx%dx%d]: %s.\n",
>>                     a_client, a_screenX, a_screenY, bpp, SDL_GetError()
>>                     );
>>       return NULL;
>>       }
>>
>>And someone is getting nbpp == 0 and this message:
Actually, nbpp == 32. I blew it here.

>>Can't set SDL video mode for Splash Screen [640x480x32]: Couldn't find 
>>matching GLX visual.
> 
> This is a puzzle, isn't it? The problem I see is that the error message 
> doesn't print the values that are passed to SDL_VideoModeOK() so we, the
> readers, can't know for sure what parameters are actually causing the
> error. :-) For example, you pass x, but print out screenX. I would
> verify the values of the variables you are passing to SDL_VideoModeOK().
> 
> I would take a close look at the value of a_flags because that is the
> only value you haven't listed here. And, it could be what is messing you
> up. 
> 		Bob Pendleton
> 
>>What is the best way to manage this problem? Try several times with a
>>decreasing bpp?

I was on #sdl last night, and with some guys that know what
they are doing, I discovered the problem.

The X11 server was running 32 bpp, but the only GLX visuals
were 24 bpp. SDL_VideoModeOK() was returning 32, even when I
passed 24 to it (for bpp). Since the flags to SDL_VideoModeOK()
were SDL_OPENGL, I would've thought that it would return
only GLX visuals that work, but it doesn't. I don't know the SDL
version; it wasn't my machine and I didn't check. This is
on a recent SuSE Linux, btw. And with proprietary nVidia drivers,
maybe the problem is there, I dunno. I may investigate SDL_VideoModeOK()
because I don't want to use glx functions directly. I presume that
some machines can properly have 32 returned from SDL_VideoModeOK() and
then used in SDL_SetVideoMode() which was returning NULL.

Thanks for the help though Bob, and the guys on #sdl.

-- 
Douglas Jerome <jerome at globalcrossing.net>
http://www.backstep.org
http://www.globalcrossing.net/~jerome
http://hackerlabs.sourceforge.net





More information about the SDL mailing list