Okay, so I was having this problem earlier, qv.
Significance of exit()
and now I am kind of curious about some things. SDL requires you to set the video mode.
SDL_SetVideoMode(WIDTH, HEIGHT, BPP, flags);
(And yes, I am error checking this.) When I used OGL with glut, there was no setting of video modes -- you just pick a window size, any window size, and away you go. So with my first couple of experiments using SDL (without GL), I just set WIDTH and HEIGHT to anything, or maybe the exact dimensions of my monitor if I was using SDL_FULLSCREEN. No problems.
But with GL, if I set the video mode above 640x480, I run a significant chance of crashing the windowing system right after the program exits. Otherwise it seems to work (but I haven't done much yet). Working with example 2.8 from the SDL Guide, BPP in a GL setting is determined this way:
which it's 32, and then there's also this which is necessary:Code:const SDL_VideoInfo *info = SDL_GetVideoInfo(); int BPP= info->vfmt->BitsPerPixel;
I have searched the API docs and googled around a bit, and there is no explanation at all of what all this means. There is one note to the effect that you want the r,g, and b size to be "at least 5". So is this 5+5+5+16=31? Or is this unrelated to BPP? Or, if it means 15 or 16, does this actually mismatch with the depth set using SetVideoMode (32)?Code:SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
I'm kind of familiar with GL's interface and AFAIK this is not part of it -- this is for SDL's interface to GL, I guess. Which makes it kind of crappy they can't be bothered to explain this better (or at all), since the docs seem decent otherwise, so far.
The reason I'm asking is presumably the seg fault (which occurs in libglx.so, part of X windows) is because of this. I do not have a very good video card -- it's an onboard via chrome -- but with glut, the video mode or whatever always matched the window size. Now it seems I am stuck with a 640x480 window (or fullscreen in 640x480 mode) which sucks.
I guess this won't make much difference to the design of the app itself, etc, since video modes are system dependent. But does anyone have any insight here, like
- what is a valid video mode?
- how can I get better than 640x480?