Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  An FPS counter  (Read 1344 times)
0 Members and 1 Guest are viewing this topic.
Offline Java Cool Dude

JGO Ninja
***

Posts: 680


Java forever


« on: 2003-08-04 23:32:28 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
  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 Grin

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 Shocked
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 :p
At this point I might as well drop college, gf, and work and focus mainly on doing jog....j/k  Embarrassed
Awesome   Cool
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.436 seconds with 21 queries.