Free FPS

Hi all, thanks in advance for the answers.

when I create a window its fps are locked at 60, they can not rise above the value 60.

Code:

gWindow = SDL_CreateWindow(“My Window”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE);

how do I unlock them?

Sounds like your renderer is being created with VSync enabled, which means that it ensures that you can’t render any faster than your monitor can refresh itself.

Don’t worry about it. There’s no point to rendering faster than you can display; instead, use the surplus milliseconds to handle non-graphical processing.? Any good game timer class should allow you to manage the two sets of calculations independently.

MasonOn Wednesday, October 9, 2013 8:39 AM, XaBerr <fede.berra at hotmail.it> wrote:

Hi all, thanks in advance for the answers.

when I create a window its fps are locked at 60, they can not rise above the value 60.

Code:

gWindow = SDL_CreateWindow(“My Window”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE);

how do I unlock them?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

60Hz…sounds like vsync is enabled.

the strange thing is that I do not have vsync active! or fraps it is wrong to read or is some setting OpenGL … you can think of other variables that could affect the framerate?

the strange thing is that I do not have vsync active! or fraps it is wrong to read or is some setting OpenGL … there may be other variables that affect fps?

Code:

//Uso OpenGL 2.1
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);


gWindow = SDL_CreateWindow("SPACE hATEr", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE);
if (gWindow != NULL)
{
	gMouseFocus = true;
	gKeyboardFocus = true;
	gWidth = SCREEN_WIDTH;
	gHeight = SCREEN_HEIGHT;

	//Create renderer for window
	gContext = SDL_GL_CreateContext(gWindow);
	if (gContext == NULL)
	{
		printf("> Errore SDL_GL_CreateContext():\n%s\n", SDL_GetError());
		SDL_DestroyWindow(gWindow);
		gWindow = NULL;
	}
	else
	{
		printf("Context creato.\n");

		//Grab window identifier
		gWindowID = SDL_GetWindowID(gWindow);
		printf("Finestra creata GAME.\n");
		//Flag as opened
		gShown = false;
	}
}
else
{
	printf("> Errore SDL_CreateWindow():\n%s\n", SDL_GetError());
}
//printf("_____________________________ \n");
success =  (gWindow != NULL && gContext != NULL);

//Inizializzazione OpenGL
if (!initGL())
{
	printf("> OpenGL non inizializzato.\n");
	success = false;
}
else printf("OpenGL Inizializzato.\n");

2013/10/10 XaBerr <fede.berra at hotmail.it>

**
the strange thing is that I do not have vsync active! or fraps it is wrong
to read or is some setting OpenGL … there may be other variables that
affect fps?

You might not even have requested it in your app, the desktop
settings might simply be forcing vsync on all running apps
(you can do that in eg. Catalyst Control Center on AMD).

Jonas

Jonas Kulla wrote:

You might not even have requested it in your app, the desktop
settings might simply be forcing vsync on all running apps
(you can do that in eg. Catalyst Control Center on AMD).

Jonas

I investigate, ty

I found that using sdl with opengl the vsync is automatically activated, so thank you guys were right :D!, the problem is that nn I think I have found a simple way to turn it off as “SDL_Disable (vsync);” …

I find this code:

Code:

typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;

void setVSync(int interval=1)
{
const char *extensions = glGetString( GL_EXTENSIONS );

if( strstr( extensions, “WGL_EXT_swap_control” ) == 0 )
return; // Error: WGL_EXT_swap_control extension not supported on your computer.\n");
else
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( “wglSwapIntervalEXT” );

if( wglSwapIntervalEXT )
  wglSwapIntervalEXT(interval);

}
}

for disable vsync but glGetString is for opengl 4.0… you think I can replace it with something for version 2.0?

for disable vsync but glGetString is for opengl 4.0… you think I can
replace it with something for version 2.0?

That code should work with OpenGL 2.0, too, but it does the same thing
that SDL_GL_SetSwapInterval() does anyhow. Why not just use that?

–ryan.

Uhh, glGetString is OpenGL 1.0. That is how you get things like
GL_VENDOR, GL_RENDERER, GL_VERSION, and GL_EXTENSIONS.

JosephOn Sun, Oct 13, 2013 at 09:10:45PM +0000, XaBerr wrote:

for disable vsync but glGetString is for opengl 4.0… you think I can replace it with something for version 2.0?

my bad sorry i wrong read code line. the problem is a conversion problem xD: const GLubyte* to const char *