diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-05-12 19:16:27 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-05-12 19:16:27 +0000 |
| commit | b4a08278815a17dc6582d32c3f2409e8e47404fb (patch) | |
| tree | 13134baf7e771ecbb26b46f5c6e497fde2674ecd /test | |
| parent | 743b0f984e517dc199864fd2597def360957d7ce (diff) | |
Resizing of OpenGL subwindows was broken on OSX (STR #804)
Added a FPS indicator to the fractals demo for testing purposes.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4342 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/fractals.cxx | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/test/fractals.cxx b/test/fractals.cxx index 89e609f64..65869eef8 100644 --- a/test/fractals.cxx +++ b/test/fractals.cxx @@ -612,25 +612,30 @@ void myGLInit(void) /************************ GLUT STUFF ***************************/ /***************************************************************/ +int winwidth = 1; +int winheight = 1; + void reshape(int w, int h) { glViewport(0,0,w,h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (GLdouble)w/h, 0.01, 100); - glPushMatrix(); - glMatrixMode(GL_MODELVIEW); - glFlush(); + + winwidth = w; + winheight = h; } void display(void) -{ +{ + time_t curtime; + char buf[255]; + static time_t fpstime = 0; + static int fpscount = 0; + static int fps = 0; + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glPushMatrix(); /* clear of last viewing xform, leaving perspective */ - + glLoadIdentity(); + gluPerspective(60.0, (GLdouble)winwidth/winheight, 0.01, 100); agvViewTransform(); glMatrixMode(GL_MODELVIEW); @@ -646,12 +651,31 @@ void display(void) if (DrawAxes) glCallList(AXES); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0.0, winwidth, 0.0, winheight); + + sprintf(buf, "FPS=%d", fps); + glColor3f(1.0f, 1.0f, 1.0f); + gl_font(FL_HELVETICA, 12); + gl_draw(buf, 10, 10); + // // Use glFinish() instead of glFlush() to avoid getting many frames // ahead of the display (problem with some Linux OpenGL implementations...) // glFinish(); + + // Update frames-per-second + fpscount ++; + curtime = time(NULL); + if ((curtime - fpstime) >= 2) + { + fps = (fps + fpscount / (curtime - fpstime)) / 2; + fpstime = curtime; + fpscount = 0; + } } void visible(int v) |
