void print_fps(){
int viewport[] = new int[4];
if(start == 0)
start = System.currentTimeMillis();
if(System.currentTimeMillis() - start >=500){
fps = count_fps<<1;
start = 0;
count_fps = 0;
}
count_fps++;
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(gl.GL_PROJECTION);
gl.glPushMatrix ();
gl.glLoadIdentity();
gl.glGetIntegerv (gl.GL_VIEWPORT, viewport);
glu.gluOrtho2D(0,viewport[2], viewport[3], 0);
gl.glDepthFunc(gl.GL_ALWAYS);
gl.glColor3f (1,1,1);
gl.glRasterPos2f(15, 15);
glut.glutBitmapString(gl,glut.BITMAP_HELVETICA_18, "FPS: " + fps);
gl.glDepthFunc(gl.GL_LESS);
gl.glPopMatrix();
gl.glMatrixMode(gl.GL_MODELVIEW);
gl.glPopMatrix ();
}
Enjoy ;D
PS; I was working on my stencil shadows demo and I realized how freaking awesome display lists are, check these two screens out:
http://www.realityflux.com/abba/no_display_list.jpg
http://www.realityflux.com/abba/with_display_list.jpg
DOH :o
Knowing that the dragon loaded into the demo counts no less than 6775 triangles, it’s a quite a good thing to know that the cpu load that used to go “wasted” on drawing that many polyons in every frame could be put into good use somewhere else
At this point I might as well drop college, gf, and work and focus mainly on doing jog…j/k :-[
Awesome 8)