views:

189

answers:

2
+3  A: 

Try setting some GL attributes before your SDL_SetVideoMode() call:

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_ALPHA_SIZE,   5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,   16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

Also, pass in SDL_OPENGL instead of SDL_HWSURFACE | SDL_DOUBLEBUF:

if (!(surf = SDL_SetVideoMode(sx, sy, bpp, SDL_OPENGL)))
genpfault
Thanks very much for the tips. I modified my question so I could post a version that works. The SDL_OPENGL was definitely an issue. In the working version, if I put SDL_HWSURFACE|SDL_DOUBLEBUF back in there, it would go black again. But replacing them with SDL_OPENGL in the original code doesn't help. Also, the working code works fine without the SDL_GL_SetAttribute() calls, although it's probably a good idea to make those calls.
Lococo
+4  A: 

In the first code block, change your glColor3b() call to glColor3ub(). Or pass in 127 instead of 255.

genpfault
OMIGOSH! That's it! Thanks a million, sir, you are a genius. :)
Lococo