How to disable vsync in SDL 2?

Started by
3 comments, last by Trevor Williams 9 years, 1 month ago

I need it for development mostly (see real FPS). Preferably crossplatform but I could live with Windows only.

I tried to google it but got confused what's for SDL 2 and what's for SDL1.2 (not sure which code work where, since people not always mention it)...

Note: I'm using SDL2 + OpenGL (no SDL blitting of any kind, SDL just opens the screen for me and handles keyboard/mouse).

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement

SDL_GL_SetSwapInterval should do the trick. It takes an int parameter, 1 to activate VSync, 0 to disable it.

SDL_GL_SetSwapInterval should do the trick. It takes an int parameter, 1 to activate VSync, 0 to disable it.

Works perfectly, thanks :)

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

As I understand the docs you can also pass the SDL_RENDERER_PRESENTVSYNC flag when creating the renderer.

https://wiki.libsdl.org/SDL_CreateRenderer

As I understand the docs you can also pass the SDL_RENDERER_PRESENTVSYNC flag when creating the renderer.

https://wiki.libsdl.org/SDL_CreateRenderer

If, as you've said, you're using OpenGL with SDL, don't try using SDL_RENDERER_PRESENTVSYNC. You won't create an SDL_Renderer when using SDL with OpenGL, and you only use that flag when do.

"You all look like lions to me. Lets be rabbits again."

Request for Comments => https://github.com/ts-williams

This topic is closed to new replies.

Advertisement