Recommand · May 30, 2021 0

How to get FPS in JOGL?

I currently trying to output my FPS using JOGL, to no avail. I have tried many things such as
glAutoDrawable.getAnimator().getLastFPS() but it returns 0.0. I have also tried using glAutoDrawable.getAnimator().setUpdateFPSFrames(3, System.out); but it never logs the FPS. I am trying to get the FPS of the ENTIRE application, not a animation.

Here is the code that I am using:

package ***;

import com.jogamp.opengl.*;
import com.jogamp.opengl.util.Animator;
import ***.log.Log;
import ***.tests.utils.GameTestMethods;

public class GameCanvas implements GLEventListener{
    public void display(GLAutoDrawable glAutoDrawable) {
        GL2 glDraw = glAutoDrawable.getGL().getGL2();

        gameTestMethods.onRender(glDraw); // Draws a rectangle, not the issue.
        Log.log(Log.LogLevel.DEBUG, "FPS: "+glAutoDrawable.getAnimator().getLastFPS());//Trying to log FPS, returns 0.0 every time.

    public void init(GLAutoDrawable glAutoDrawable) {
        glAutoDrawable.setAnimator(new Animator()); // No clue what i'm doing here...
        glAutoDrawable.getAnimator().setUpdateFPSFrames(3, System.out); // NEVER logs FPS...


Would this be possible, or would I need my own FPS counter?