Making application time-based

Hello.

I’m looking for a way to make my JOGL application time-based instead of CPU-based using FPSAnimator. Any suggestion on how I do this?

Thank you

What do you mean exactly? Rather use the vertical synchronisation than the FPSAnimator.

not related to JOGL too but usually I use something similar to the following :


	
	
private long gameLogicLastTime=-1;
	
//Logic update rate = 10 ms
private long gameLogicRate=10;


//Your main rendering Thread
public void run()
{
	//Uncontrolled FPS loop
	while(this.mustRun)
	{
		this.doLogic();	
		this.diplay();
		Thread.yield();
	}
}

//Perform game logic for elapsed time
public void doLogic()
{
	long time=System.currentTimeMillis()
	
	//First call ?
	if(this.gameLogicLastTime==-1)
	{
		this.gameLogicLastTime=time;
		return;
	}
	
	//Compute elapsed time since last game logic
	long elapsedTime=time-this.gameLogicLastTime;
	
	
	//If elapsed time lower than logic rate return
	if(elapsedTime<this.gameLogicRate)
		return;
		
	
	//Compute number of game logics to perform	
	int nbGameLogic=(int)(elapsedTime/this.gameLogicRate);


	for(int gameLogicCount=0;gameLogicCount<nbGameLogic;gameLogicCount++)		
		this.doLogicOnce();	
	
	this.gameLogicLastTime+=nbGameLogic*this.gameLogicRate;		
}

//Perform game logic for 10 ms (gameLogicRate)
public void doLogicOnce()
{

}	

//Render game graphics
public void display()
{

}