[SDL] Enabling V-Sync

Started by
0 comments, last by Koshmaar 17 years, 10 months ago
Hi guys - I'm using SDL to acquire a rendering context for my OpenGL apps, and I've been wanting to enable V-Sync'ing since I dev on a laptop. Anyway, as you probably know, this functionality has to be enabled through the windowing system you're using (SDL, WGL, whatever) and not through OpenGL. Thankfully, SDL added this kind of functionality with its latest release, 1.2.10, with the GL attribute SDL_GL_SWAP_CONTROL, which must be set to a non-zero value before the call to SDL_SetVideoMode. The code, roughly, looks like this - int check1 = SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ); // check1 is 0, signifying success. SDL_SetVideoMode( ... ); // blah. int check2 = 0; // variable to put the returned value into. int check3 = SDL_GL_GetAttribute( SDL_GL_SWAP_CONTROL, &check2 ); // check3 is -1, meaning an error was encountered char* error = SDL_GetError(); // error == "" ... So at this point I'm stumped. I don't see why the hell SDL_GL_GetAttribute would return an error; there isn't much in the documentation other than "-1 means error" (link), and SDL_GetError returns an empty string. The documentation I read said that all calls to SDL_GL_SetAttribute had to be made before the call to SDL_SetVideoMode. This messsage chain suggests setting it after. This had no effect on my problem - the flag was not set (as shown by 100% CPU usage) and SDL_GL_GetAttribute still returned an unknown error. Does anyone know why this isn't working? Because at this point, I'm completely stumped...
Advertisement
Dunno, maybe your graphics card doesn't support this "extension" (search glGetString(GL_EXTENSIONS) for WGL_EXT_swap_control)? Have you tried running this code on other computers? What platform are you using (I assumed WinXP)?

This topic is closed to new replies.

Advertisement