Ginto8 wrote:SDL_GL_SetAttribute is in the right place, it's usually best to have it before SetVideoMode (I dunno if it works otherwise). However, you don't need screen. Keeping a reference to the screen surface is really only necessary when blitting, which you shouldn't be doing if you're using opengl. As for the clearing, it looks like it should work, but maybe you should try making it glClearColor(0,0,0,1) instead (the last number is the alpha, and 0 is transparent). I don't know if it will work for sure, but it may solve your problem.
Well I doubt glClearColor() will make a diffrence, I know what he means as I've encounted this problem before. If you're asking for a OpenGL context without initializing it correctly then the buffer fucks with the desktop.
try
Code: Select all
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
buffer = SDL_SetVideoMode(640,480,32,SDL_OPENGL);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glClearColor(0,0,0,0);
glOrtho(0,640,480,0-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
Also in your main loop make sure you're calling "SDL_GL_SwapBuffers()"
NOT SDL_Flip() or glFlush() Also you still have to poll for events. It could be somthing in your main loop aswell I'm not sure.