Jump to content

  • Log In with Google      Sign In   
  • Create Account

SDL 1.2 Engine - vsync issues in ubuntu


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 I put on my robe and...   Members   -  Reputation: 105

Like
0Likes
Like

Posted 30 August 2013 - 04:31 PM

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
 

SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);

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:
 

if((1000/FPS)>(SDL_GetTicks()-start_time))
{
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:

SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL | SDL_RESIZABLE);

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

 

The following is just standard setup for 2d opengl

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

glMatrixMode( GL_MODELVIEW );
glEnable( GL_TEXTURE_2D );
glLoadIdentity();

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

glShadeModel(GL_SMOOTH);

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..., 30 August 2013 - 04:33 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS