Limited frame count?

Hello community,

as you can see I’m new here and hope that this is the right place to address my issue :smiley:
I recently implemented an FPS counter and was curious if the number it shows is correct, because it seems like the frame count is bound to the configured display refresh rate, even though vertical synchronization is disabled in my graphics driver. Is there some kind of limitation inside JOGL that prevents me from seeing the maximum possible number of frames that can be rendered per second or am I doing something wrong? :smiley:

Here is my code:



//declarations

private long time = -1;
private int frames = 0;
private int framesToShow = 0;

// fps calculation inside the display() method:

	frames++;
	long currentTime = System.currentTimeMillis(); 
	if((currentTime - time) >= 1000){	
		time = currentTime;
		framesToShow = frames;
		frames = 0;
		
		// Neuen Anpasswert fürs TBM setzen
		dt = 1 / framesToShow;
	}

// other opengl relevant calls and fps display etc.


I’m missing the correct number, because it might be a good performance indicator. If you only see the refresh rate, you don’t know how far you can go or if some performance tuning may be necessary.

Thanks in advance :slight_smile:

Br
MrCastle


private long time = System.currentTimeMillis();

...

		time += 1000;

...

                dt = 1.0 / framesToShow;

Other than that, you might want to change it to:
System.nanoTime() / 1000000L
for more accurate results.

Thanks for your fast answer :slight_smile:
But I fear I can’t follow, this actually doesn’t change anything, except for the things you mentioned (accuracy).
I’m still getting 75fps with a refresh rate of 75 Hz. ???
edit: by the way, the time based movement variable (dt) is not used yet, I first wanted to solve this issue.

This changes a lot. You were leaking time. What if the diff between time and System.currentTimeMillis() is 1030ms, with your code you’re lose 30ms, with my code you wouldn’t lose any time.

Just change what’s actually rendered (to nothing, for example) and watch the framerate. If it’s still 75fps you might have setup your OpenGL drivers to be vsynced regardless of what the application specified.

OK that sounds reasonable.
I will do the changes and then see what happens.

Thanks again

For all of those who are interested in the “solution”, there is a a limitation in jogl or openGL itself, that limits the frames per second to the monitor refresh rate.

With

gl.setSwapInterval(0);

you can turn it off to get the maximum possible number of fps, with the parameter 1 you can set it back to limit the frame rate, this is also the default value.

Br
MrCastle