Jump to content
  • Advertisement
Sign in to follow this  

SDL 1.2 Engine - vsync issues in ubuntu

This topic is 2145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a game using SDL 1.2 for the cross-platform benefits. I use openGL calls for all the rendering.

I have called


before setting SDL video mode, and when I call get_attribute after everything is set up, a "1" is returned for success. In addition, if I manually configure the environment variable via an "export" of the vsync variable, then SDL properly says that the environment variable has overridden SDL settings and that Vsync is on.

Everything says that vsync is on and works, but my game still stutters in Linux...
In Windows, the game also stuttered until I added the swap_control and it became smooth as butter.


This made me believe that something was wrong fundamentally with my loop, as I read that
"A good game loop will provide the delays necessary to make Vsync unnecessary"
So I offer to you my delay method:

SDL_Delay((1000/FPS)-(SDL_GetTicks()-start_time)); //Yay stable framerate!

I had a different one, but clipped this from the internet thinking maybe that was my problem. It changed nothing.
the start_time is at the beginning of the while loop, and the FPS is set to 50 or 60, tried both.

Below is the code I use to set up my SDL video mode:


I have also tried using HW_ACCEL, SWSURFACE, and several other settings.


The following is just standard setup for 2d opengl

glMatrixMode( GL_PROJECTION );
glOrtho(0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -1.0f, 1.0f);

glMatrixMode( GL_MODELVIEW );
glEnable( GL_TEXTURE_2D );

glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );


glViewport( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );

This is pretty much all the code that goes into setup. Again, it works beautifully in windows now that I have added the vsync, but it behaves the same in Linux (Ubuntu 12.10) regardless of the vSync being set.

Also, I have gone through compiz settings to try enabling vsync, triple buffering, and other opengl options. The enabling and disabling of these options ALL had no effect on my game's small stutter.


I'm going to ask this as an aside, but it isn't the main focus of what I want from this post - so please only contribute to this part of the question if you have substantial knowledge of both versions of SDL and can offer an appropriate opinion for a 2d game (platformer)....
With the recent release of sdl 2, should I upgrade to it? My engine is set up so that I can replace it without too much trouble and I am at the beginning stages of making my game still. I know nothing at all of SDL2, but am decently familiar with 1.2. I wouldn't even use SDL were it not for the fact that I don't want to deal with wrapping OpenGL for cross platform call. I use SDL right now for event handling, image loading of PNGs and converting them to 32bit ints for gl textures, and I will eventually use it for music.

Edited by I put on my robe and...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!