//帧率控制
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);//设置渲染模式为主动渲染
final TimerTask task = new TimerTask() {
@Override
public void run() {
requestRender();
}
};
ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
pool.scheduleAtFixedRate(task, 0, 16, TimeUnit.MILLISECONDS);
//帧率计算
double framesPerSecond;
double lastTime;
private void CalculateFrameRate() {
double currentTime = System.currentTimeMillis();
++framesPerSecond;
if (currentTime - lastTime > 1000) {
Log.e("fps", "----fps-->" + framesPerSecond);
lastTime = currentTime;
framesPerSecond = 0;
}
}