Sign in to follow this  

[SDL]Framerate limited to 60.

This topic is 2056 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

Ever since i got a new pc with nvidia's gpu, framerate in sdl has always been limited to 60(which is also my monitor's refresh rate).
My first guess was that my drivers are forcing vsync onto SDL so i tried forcing it off in nvidia's control panel and then the framerate wasnt limited but was over 5000 frames per second.
I don't have that problem in other games, but i suppose they might do something to disable vsync.
I just wonder if there is a way to remove this limit so i would have framerate higher than my refresh rate.
My old gpu never had this problem with very same code i posted below.

ScreenShot: [url="http://localhostr.com/file/pZ5xZ2i/sdl.jpg"]http://localhostr.co...pZ5xZ2i/sdl.jpg[/url]

Code:
[CODE]
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
int WINDOW_OPT[3] = {800, 600, 32};
void InitGL()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, WINDOW_OPT[0], WINDOW_OPT[1], 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glDisable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glCullFace(GL_FRONT);

}
int main(int argc, char** argv)
{
SDL_Surface* window = SDL_SetVideoMode(WINDOW_OPT[0], WINDOW_OPT[1], WINDOW_OPT[2], SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER);
SDL_Event event;
SDL_WM_SetCaption("TEST", NULL);

InitGL();

bool run = true;
while(run)
{
while(SDL_PollEvent(&event))
{
if(event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE)
{
run = false;
}
}
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();

glBegin(GL_QUADS);
glVertex2f(100, 100);
glVertex2f(200, 100);
glVertex2f(200, 200);
glVertex2f(100, 200);
glEnd();

SDL_GL_SwapBuffers();
}

SDL_Quit();
return 0;
}
[/CODE]

Share this post


Link to post
Share on other sites
Hello.

Since you are using openGL for graphics and refreshing the screen I'd say the problem is related to that rather then SDL.
I have no experience of openGL but I googled it for you and found this.. not sure if it helps you but it's a start atealst.

[url="http://www.gamedev.net/topic/317721-opengl-c-vsync/"]http://www.gamedev.n...opengl-c-vsync/[/url]

*Edit: spelling Edited by AlanSmithee

Share this post


Link to post
Share on other sites
VSync can be forced On/Off in the video card driver config panel but it's preferable to let it to "Application settings", which allow programmers to set it on/off in their code. In your case, using SDL and OpenGL you can use SDL_GLattr() with the SDL_GL_SWAP_CONTROL flag. In any way, I actually think have vsync enabled 100% of the time is preferable, otherwise you get screen tearing and getting more FPS than 60 is useless.

Share this post


Link to post
Share on other sites
Yeah this is because VSync is enabled, not necessarily a bad thing but if you are really looking to disable it you should look at the SGI SwapControl extension (and the same from EXT, because sometimes only one or the other is supported .. yay vendor fragmentation)

Share this post


Link to post
Share on other sites

This topic is 2056 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this