Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1130 - in trunk: Engine/Display fox/dm_demo
- Date: Tue, 27 Jun 2006 15:29:58 -0600 (MDT)
Author: bigler
Date: Tue Jun 27 15:29:56 2006
New Revision: 1130
Modified:
trunk/Engine/Display/OpenGLDisplay.cc
trunk/Engine/Display/OpenGLDisplay.h
trunk/fox/dm_demo/dm_demo.cc
Log:
Engine/Display/OpenGLDisplay.cc
Engine/Display/OpenGLDisplay.h
Made it possible to select the corner you want your framerate to
display in.
fox/dm_demo/dm_demo.cc
Place the frame rate display in the upper corner. Still doesn't
show up, because the render window is behind the menu bar.
Modified: trunk/Engine/Display/OpenGLDisplay.cc
==============================================================================
--- trunk/Engine/Display/OpenGLDisplay.cc (original)
+++ trunk/Engine/Display/OpenGLDisplay.cc Tue Jun 27 15:29:56 2006
@@ -91,6 +91,7 @@
displayFrameRate = true;
mode = "texture";
verbose = false;
+ fpsDisplayLocation = LowerLeft;
}
void OpenGLDisplay::setup()
@@ -303,7 +304,7 @@
gluOrtho2D(0, xres, 0, yres);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- display_frame_rate(1.0/(currentTime-last_frame_time));
+ display_frame_rate(1.0/(currentTime-last_frame_time), xres, yres);
}
last_frame_time = currentTime;
@@ -317,7 +318,7 @@
}
}
-void OpenGLDisplay::display_frame_rate(double framerate)
+void OpenGLDisplay::display_frame_rate(double framerate, int xres, int yres)
{
// Display textual information on the screen:
char buf[200];
@@ -331,9 +332,25 @@
glEnable(GL_BLEND);
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glColor4f(0.5,0.5,0.5,0.5);
- glRecti(8,3-fontInfo->descent-2,12+width,fontInfo->ascent+3);
+ int yoffset = 3;
+ int xoffset = 8;
+ switch (fpsDisplayLocation) {
+ case LowerRight:
+ xoffset = xres-width-14;
+ break;
+ case UpperLeft:
+ yoffset = yres - fontInfo->ascent - 3;
+ break;
+ case UpperRight:
+ yoffset = yres - fontInfo->ascent - 3;
+ xoffset = xres-width-14;
+ break;
+ // Default and LowerLeft cases don't need to do anything
+ }
+ glRecti(xoffset, yoffset-fontInfo->descent-2,
+ xoffset+6+width, yoffset+fontInfo->ascent);
glDisable(GL_BLEND);
- XHelper::printString(fontbase, 10, 3, buf, RGBColor(1,1,1));
+ XHelper::printString(fontbase, xoffset+2, yoffset+1, buf, RGBColor(1,1,1));
}
void OpenGLDisplay::gl_print_error(const char *file, int line)
Modified: trunk/Engine/Display/OpenGLDisplay.h
==============================================================================
--- trunk/Engine/Display/OpenGLDisplay.h (original)
+++ trunk/Engine/Display/OpenGLDisplay.h Tue Jun 27 15:29:56 2006
@@ -31,6 +31,17 @@
bool getDisplayFrameRate() const { return displayFrameRate; }
void setDisplayFrameRate( bool b ) { displayFrameRate = b; }
+ // The location of the fps display.
+ enum {
+ LowerLeft = 0,
+ LowerRight = 1,
+ UpperLeft = 2,
+ UpperRight = 3
+ };
+
+ int getFPSDisplayLocation() const { return fpsDisplayLocation; }
+ void setFPSDisplayLocation( int new_loc ) { fpsDisplayLocation =
new_loc; }
+
private:
OpenGLDisplay(const OpenGLDisplay&);
OpenGLDisplay& operator=(const OpenGLDisplay&);
@@ -79,13 +90,14 @@
#endif
bool displayFrameRate;
+ int fpsDisplayLocation;
// This is when the last frame started displaying. Use it to
// compute the framerate.
double last_frame_time;
// Used to display the frame rate on the screen
- void display_frame_rate(double framerate);
+ void display_frame_rate(double framerate, int xres, int yres);
void gl_print_error(const char *file, int line);
Modified: trunk/fox/dm_demo/dm_demo.cc
==============================================================================
--- trunk/fox/dm_demo/dm_demo.cc (original)
+++ trunk/fox/dm_demo/dm_demo.cc Tue Jun 27 15:29:56 2006
@@ -172,6 +172,7 @@
glx_image_display =
new OpenGLDisplay( (XVisualInfo *)manta_frame->getVisual()->getInfo(),
(Window) manta_frame->id() );
+ glx_image_display->setFPSDisplayLocation(OpenGLDisplay::UpperLeft);
// std::cout << "X Window id: " << manta_frame->id() << std::endl;
- [MANTA] r1130 - in trunk: Engine/Display fox/dm_demo, bigler, 06/27/2006
Archive powered by MHonArc 2.6.16.