|
|
|
|
@@ -62,10 +62,17 @@ osg::Timer_t g_initTime;
|
|
|
|
|
//static GLenum polymodes [] = { GL_FILL, GL_LINE, GL_POINT };
|
|
|
|
|
static osg::PolygonMode::Mode polymodes [] = { osg::PolygonMode::FILL, osg::PolygonMode::LINE, osg::PolygonMode::POINT };
|
|
|
|
|
|
|
|
|
|
// forward declare functions to be used in stats.
|
|
|
|
|
GLuint makeRasterFont(void);
|
|
|
|
|
void displaytext(int x, int y, char *s);
|
|
|
|
|
void writePrims( const int ypos, osg::Statistics& stats);
|
|
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
using namespace osgUtil;
|
|
|
|
|
using namespace osgGLUT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Viewer* Viewer::s_theViewer = 0;
|
|
|
|
|
|
|
|
|
|
Viewer::Viewer()
|
|
|
|
|
@@ -435,148 +442,16 @@ void Viewer::keyboardCB(unsigned char key, int x, int y)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLuint makeRasterFont(void)
|
|
|
|
|
{ // GWM creates a set of display lists which may be used to render a character string on the screen
|
|
|
|
|
// data from GWM's reading of the Windows ASCII_FIXED_FONT.
|
|
|
|
|
GLubyte rasters[][12] = { // ascii symbols 32-127, small font
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x14, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x28, 0x28, 0x7e, 0x14, 0x14, 0x14, 0x3f, 0x0a, 0x0a, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x1c, 0x22, 0x02, 0x1c, 0x20, 0x22, 0x1c, 0x08, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x02, 0x45, 0x22, 0x10, 0x08, 0x04, 0x22, 0x51, 0x20, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3b, 0x44, 0x4a, 0x49, 0x30, 0x10, 0x20, 0x20, 0x18, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x00},
|
|
|
|
|
{0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00},
|
|
|
|
|
{0x10, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x10, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x36, 0x1c, 0x7f, 0x1c, 0x36, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x08, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x20, 0x10, 0x08, 0x04, 0x02, 0x02, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x02, 0x02, 0x0c, 0x02, 0x02, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x0e, 0x04, 0x3e, 0x24, 0x14, 0x14, 0x0c, 0x0c, 0x04, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x02, 0x02, 0x3c, 0x20, 0x20, 0x20, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x10, 0x0c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x22, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x18, 0x04, 0x02, 0x02, 0x1e, 0x22, 0x22, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x04, 0x02, 0x02, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x20, 0x4e, 0x55, 0x55, 0x55, 0x4d, 0x21, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x3e, 0x22, 0x14, 0x14, 0x08, 0x08, 0x18, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7e, 0x21, 0x21, 0x21, 0x3e, 0x21, 0x21, 0x21, 0x7e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1e, 0x21, 0x40, 0x40, 0x40, 0x40, 0x40, 0x21, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7c, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x7c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7f, 0x21, 0x20, 0x24, 0x3c, 0x24, 0x20, 0x21, 0x7f, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x78, 0x20, 0x20, 0x24, 0x3c, 0x24, 0x20, 0x21, 0x7f, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1e, 0x21, 0x41, 0x47, 0x40, 0x40, 0x40, 0x21, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x38, 0x44, 0x44, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x73, 0x22, 0x24, 0x38, 0x28, 0x24, 0x24, 0x22, 0x73, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7f, 0x11, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x2a, 0x2a, 0x36, 0x36, 0x22, 0x63, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x72, 0x22, 0x26, 0x26, 0x2a, 0x32, 0x32, 0x22, 0x67, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x78, 0x20, 0x20, 0x20, 0x3e, 0x21, 0x21, 0x21, 0x7e, 0x00},
|
|
|
|
|
{0x00, 0x1b, 0x1c, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x73, 0x22, 0x24, 0x24, 0x3e, 0x21, 0x21, 0x21, 0x7e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x01, 0x01, 0x3e, 0x40, 0x40, 0x41, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x49, 0x7f, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x08, 0x14, 0x14, 0x14, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x14, 0x14, 0x2a, 0x2a, 0x2a, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x14, 0x14, 0x08, 0x14, 0x14, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x08, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7f, 0x21, 0x10, 0x10, 0x08, 0x04, 0x04, 0x42, 0x7f, 0x00},
|
|
|
|
|
{0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00},
|
|
|
|
|
{0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x14, 0x08},
|
|
|
|
|
{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3d, 0x42, 0x42, 0x3e, 0x02, 0x3c, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7e, 0x21, 0x21, 0x21, 0x21, 0x3e, 0x20, 0x20, 0x60, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x40, 0x40, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3f, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x06, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x40, 0x7f, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3c, 0x10, 0x10, 0x10, 0x10, 0x3c, 0x10, 0x10, 0x0c, 0x00},
|
|
|
|
|
{0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x3f, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x22, 0x32, 0x2c, 0x20, 0x20, 0x60, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x08, 0x00},
|
|
|
|
|
{0x38, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x3c, 0x00, 0x00, 0x04, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x63, 0x24, 0x38, 0x28, 0x24, 0x26, 0x20, 0x20, 0x60, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x6b, 0x2a, 0x2a, 0x2a, 0x2a, 0x74, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x22, 0x32, 0x6c, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x41, 0x41, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x70, 0x20, 0x3e, 0x21, 0x21, 0x21, 0x21, 0x7e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x07, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x3f, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7c, 0x10, 0x10, 0x10, 0x19, 0x76, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x06, 0x38, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x0c, 0x12, 0x10, 0x10, 0x10, 0x3c, 0x10, 0x10, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1b, 0x26, 0x22, 0x22, 0x22, 0x66, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x14, 0x14, 0x22, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x14, 0x14, 0x2a, 0x2a, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x1c, 0x1c, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x30, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7e, 0x22, 0x10, 0x08, 0x44, 0x7e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x06, 0x08, 0x08, 0x08, 0x08, 0x30, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00},
|
|
|
|
|
{0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08},
|
|
|
|
|
{0x30, 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x08, 0x08, 0x30, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x49, 0x31, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x00, 0x00}
|
|
|
|
|
};
|
|
|
|
|
// the remaining lines of this routine are similar to code developed and published in the
|
|
|
|
|
// OPENGL big red book. However I have modified the code slightly, and
|
|
|
|
|
// SGI are not responsible for any errors, omissions etc.
|
|
|
|
|
static GLuint fontOffset; // first display list
|
|
|
|
|
if (!fontOffset) { // then make the raster fonts
|
|
|
|
|
GLuint i;
|
|
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
|
|
|
|
|
|
fontOffset = glGenLists (128);
|
|
|
|
|
for (i = 32; i < 127; i++) {
|
|
|
|
|
glNewList(i+fontOffset, GL_COMPILE);
|
|
|
|
|
glBitmap(8, 12, 0.0, 2.0, 10.0, 0.0, rasters[i-32]);
|
|
|
|
|
glEndList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fontOffset;
|
|
|
|
|
}
|
|
|
|
|
void displaytext(int x, int y, char *s)
|
|
|
|
|
{ // GWM July 2001 statistics text display at xy text S
|
|
|
|
|
GLuint fontOffset=makeRasterFont(); // first display list
|
|
|
|
|
glRasterPos2i(x,y);
|
|
|
|
|
// glPushAttrib (GL_LIST_BIT);
|
|
|
|
|
glListBase(fontOffset);
|
|
|
|
|
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
|
|
|
|
|
glListBase(0);
|
|
|
|
|
// glPopAttrib ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GWM July 2001 - add Statistics structure, and related RenderBin
|
|
|
|
|
#include <osgUtil/RenderBin>
|
|
|
|
|
#include <osg/Statistics>
|
|
|
|
|
|
|
|
|
|
void Viewer::showStats()
|
|
|
|
|
{
|
|
|
|
|
// GWM July 2001 - moved all draw stats to Statistics structure, and related RenderBin
|
|
|
|
|
// GWM Sept 2001 - all draw stats now calculated by calls to <Drawable>->getStats(Statistic..)
|
|
|
|
|
|
|
|
|
|
void Viewer::showStats(const unsigned int viewport)
|
|
|
|
|
{ // collect stats for viewport
|
|
|
|
|
static GLfloat tmax=100;
|
|
|
|
|
glViewport(0,0,ww,wh);
|
|
|
|
|
float vh = wh;
|
|
|
|
|
|
|
|
|
|
//glPushAttrib (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_LIGHTING_BIT | GL_ENABLE_BIT | GL_STENCIL_BUFFER_BIT);
|
|
|
|
|
|
|
|
|
|
glDisable( GL_DEPTH_TEST ); // to see the stats always
|
|
|
|
|
glDisable( GL_ALPHA_TEST );
|
|
|
|
|
glDisable( GL_LIGHTING );
|
|
|
|
|
@@ -586,6 +461,7 @@ void Viewer::showStats()
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
// set tmax using hysteresis to prevent flip-flopping between two values of tmax
|
|
|
|
|
// tmax is the scale for the stage timing graph
|
|
|
|
|
if (times[2].timeFrame>360.0f && tmax<1600) tmax=1600;
|
|
|
|
|
else if (times[2].timeFrame<300.0f && tmax>800) tmax=800;
|
|
|
|
|
else if (times[2].timeFrame>180.0f && tmax<800) tmax=800;
|
|
|
|
|
@@ -595,6 +471,7 @@ void Viewer::showStats()
|
|
|
|
|
else if (times[2].timeFrame>45.0f && tmax<200) tmax=200;
|
|
|
|
|
else if (times[2].timeFrame<36.0f && tmax>100) tmax=100;
|
|
|
|
|
glOrtho(-0.1f*tmax, tmax*1.1f,0,vh,0,500);
|
|
|
|
|
glDepthRange(0,1);
|
|
|
|
|
|
|
|
|
|
glMatrixMode( GL_MODELVIEW );
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
@@ -618,7 +495,7 @@ void Viewer::showStats()
|
|
|
|
|
displaytext(0,(int)(0.98f*vh),clin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_printStats>1) { // more stats - graphs this time
|
|
|
|
|
if (_printStats>=Statistics::STAT_GRAPHS && _printStats!=Statistics::STAT_PRIMSPERVIEW) { // more stats - graphs this time
|
|
|
|
|
|
|
|
|
|
int sampleIndex = 2;
|
|
|
|
|
float timeApp=times[sampleIndex].timeApp;
|
|
|
|
|
@@ -634,15 +511,15 @@ void Viewer::showStats()
|
|
|
|
|
|
|
|
|
|
char clin[72]; // buffer to print
|
|
|
|
|
glColor4fv((GLfloat * )&app_color);
|
|
|
|
|
sprintf(clin,"App %.2f ms.", timeApp);
|
|
|
|
|
sprintf(clin,"App %.1f ms.", timeApp);
|
|
|
|
|
displaytext((int)(.15f*tmax),(int)(0.98f*vh),clin);
|
|
|
|
|
|
|
|
|
|
glColor4fv((GLfloat * )&cull_color);
|
|
|
|
|
sprintf(clin,"Cull %.2f ms.", timeCull);
|
|
|
|
|
sprintf(clin,"Cull %.1f ms.", timeCull);
|
|
|
|
|
displaytext((int)(.35*tmax),(int)(0.98f*vh),clin);
|
|
|
|
|
|
|
|
|
|
glColor4fv((GLfloat * )&draw_color);
|
|
|
|
|
sprintf(clin,"Draw %.2f ms.", timeDraw);
|
|
|
|
|
sprintf(clin,"Draw %.1f ms.", timeDraw);
|
|
|
|
|
displaytext((int)(.55*tmax),(int)(0.98f*vh),clin);
|
|
|
|
|
|
|
|
|
|
glColor4fv((GLfloat * )&frame_color);
|
|
|
|
|
@@ -693,21 +570,13 @@ void Viewer::showStats()
|
|
|
|
|
glEnd();
|
|
|
|
|
glLineWidth(1.0f);
|
|
|
|
|
}
|
|
|
|
|
if (_printStats==3) { // yet more stats - add triangles, number of strips...
|
|
|
|
|
if (_printStats==Statistics::STAT_PRIMS) { // yet more stats - add triangles, number of strips...
|
|
|
|
|
/*
|
|
|
|
|
* Use the new renderStage. Required mods to RenderBin.cpp, and RenderStage.cpp (add getPrims)
|
|
|
|
|
* also needed to define a new class called Statistic (see osgUtil/Statistic).
|
|
|
|
|
* RO, July 2001.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
char clin[100]; // buffer to print
|
|
|
|
|
char ctmp[12];
|
|
|
|
|
int i; // a counter
|
|
|
|
|
static char *prtypes[]={"Total",
|
|
|
|
|
" Pt", " Ln", " Lstr", " LSTf", " Llop", // 1- 5
|
|
|
|
|
" Tris", " TStr", " TSfl", " TFan", " TFnf", // 6-10
|
|
|
|
|
" Quad", " QStr", " Pols", "", "", // 11-15
|
|
|
|
|
"", "", "", "", ""};
|
|
|
|
|
ViewportList::iterator itr;
|
|
|
|
|
Statistics primStats;
|
|
|
|
|
for(itr=_viewportList.begin();
|
|
|
|
|
@@ -715,59 +584,16 @@ void Viewer::showStats()
|
|
|
|
|
++itr)
|
|
|
|
|
{
|
|
|
|
|
osgUtil::RenderStage *stage = itr->sceneView->getRenderStage();
|
|
|
|
|
stage->getPrims(&primStats);
|
|
|
|
|
stage->getStats(primStats);
|
|
|
|
|
}
|
|
|
|
|
glColor3f(.9f,.9f,0.0f);
|
|
|
|
|
|
|
|
|
|
sprintf(clin,"%d Prims %d Matrices %d nGsets %d nlights %d bins", primStats.nprims,
|
|
|
|
|
primStats.nummat, primStats.numOpaque, primStats.nlights, primStats.nbins);
|
|
|
|
|
displaytext(0,(int)(0.86f*vh),clin);
|
|
|
|
|
strcpy(clin," ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (i==0 || primStats.primtypes[i]) {
|
|
|
|
|
strcat(clin, prtypes[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,(int)(0.82f*vh),clin);
|
|
|
|
|
strcpy(clin,"GSet type: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (primStats.primtypes[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", primStats.primtypes[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,(int)(0.80f*vh),clin);
|
|
|
|
|
strcpy(clin,"Prims: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (primStats.numprimtypes[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", primStats.numprimtypes[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,(int)(0.78f*vh),clin);
|
|
|
|
|
strcpy(clin,"Triangles: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (primStats.primlens[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", primStats.primlens[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,(int)(0.76f*vh),clin);
|
|
|
|
|
strcpy(clin,"Vertices: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (primStats.primlens[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", primStats.primverts[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,(int)(0.74f*vh),clin);
|
|
|
|
|
writePrims((int)(0.86f*vh),primStats);
|
|
|
|
|
}
|
|
|
|
|
if (_printStats==4) { // yet more stats - read the depth complexity
|
|
|
|
|
if (_printStats==Statistics::STAT_DC) { // yet more stats - read the depth complexity
|
|
|
|
|
int wid=ww, ht=wh; // temporary local screen size - must change during this section
|
|
|
|
|
if (wid>0 && ht>0) {
|
|
|
|
|
const int blsize=16;
|
|
|
|
|
char *clin=new char[wid/blsize+2]; // buffer to print dc
|
|
|
|
|
char *ctext=new char[128]; // buffer to print details
|
|
|
|
|
char ctext[128]; // buffer to print details
|
|
|
|
|
float mdc=0;
|
|
|
|
|
GLubyte *buffer=new GLubyte[wid*ht];
|
|
|
|
|
if (buffer) {
|
|
|
|
|
@@ -797,13 +623,12 @@ void Viewer::showStats()
|
|
|
|
|
displaytext(0,(int)(0.84f*vh-(j*12)/blsize),clin); // display average DC over the blsize box
|
|
|
|
|
}
|
|
|
|
|
sprintf(ctext, "Pixels hit %.1f Mean DC %.2f: %4d by %4d pixels.", mdc, mdc/(wid*ht), wid, ht);
|
|
|
|
|
displaytext(0,(int)(0.86f*vh),clin);
|
|
|
|
|
displaytext(0,(int)(0.86f*vh),ctext);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_STENCIL_TEST); // re-enable stencil buffer counting
|
|
|
|
|
delete [] buffer;
|
|
|
|
|
}
|
|
|
|
|
delete [] clin;
|
|
|
|
|
delete [] ctext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -812,11 +637,9 @@ void Viewer::showStats()
|
|
|
|
|
|
|
|
|
|
glMatrixMode( GL_PROJECTION );
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
|
|
//glPopAttrib ();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Viewer::display()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@@ -842,6 +665,11 @@ void Viewer::display()
|
|
|
|
|
|
|
|
|
|
// draw traverasal.
|
|
|
|
|
times[2].timeDraw+=draw(i);
|
|
|
|
|
if (_printStats==Statistics::STAT_PRIMSPERVIEW)
|
|
|
|
|
{ // gwm - get and show stats in each window
|
|
|
|
|
showStats(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -851,14 +679,12 @@ void Viewer::display()
|
|
|
|
|
|
|
|
|
|
times[2].timeFrame=frameSeconds()*1000;
|
|
|
|
|
|
|
|
|
|
if (_printStats)
|
|
|
|
|
{ // gwm output selected stats at this point - convert to a graph.
|
|
|
|
|
showStats();
|
|
|
|
|
times[0]=times[1];
|
|
|
|
|
if (_printStats) {
|
|
|
|
|
showStats(0); // output selected stats at this point - timing graph.
|
|
|
|
|
times[0]=times[1]; // move the times buffers down
|
|
|
|
|
times[1]=times[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glutSwapBuffers(); // moved after draw of stats & glFinish() to get accurate timing (excluding stat draw!)
|
|
|
|
|
// cout << "Time elapsed "<<_timer.delta_s(_initialTick,_timer.tick())<<endl;
|
|
|
|
|
|
|
|
|
|
@@ -1048,12 +874,13 @@ void Viewer::keyboard(unsigned char key, int x, int y)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'p' :
|
|
|
|
|
if (_printStats==4) glDisable(GL_STENCIL_TEST); // switch off stencil counting
|
|
|
|
|
if (_printStats==Statistics::STAT_DC) glDisable(GL_STENCIL_TEST); // switch off stencil counting
|
|
|
|
|
_printStats++; //gwm jul 2001 range of possible outputs, 0-4 = !_printStats;
|
|
|
|
|
if (_printStats>4) _printStats=0;
|
|
|
|
|
if (_printStats==4) { // count depth complexity by incrementing the stencil buffer every
|
|
|
|
|
if (_printStats>=Statistics::STAT_RESTART) _printStats=0;
|
|
|
|
|
if (getNumViewports()<=1 && _printStats==Statistics::STAT_PRIMSPERVIEW) _printStats++; // no need for these stats as only one view
|
|
|
|
|
if (_printStats==Statistics::STAT_DC) { // count depth complexity by incrementing the stencil buffer every
|
|
|
|
|
// time a pixel is hit
|
|
|
|
|
GLint nsten=0; // Number of stencil planes available
|
|
|
|
|
int nsten=0; // Number of stencil planes available
|
|
|
|
|
glGetIntegerv(GL_STENCIL_BITS , &nsten);
|
|
|
|
|
if (nsten>0) {
|
|
|
|
|
glEnable(GL_STENCIL_TEST);
|
|
|
|
|
@@ -1448,3 +1275,192 @@ void Viewer::init(osg::Node* rootnode)
|
|
|
|
|
osg::notify(osg::WARN)<<" Automatically mapping init to addViewport."<<endl;
|
|
|
|
|
addViewport(rootnode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
GLuint makeRasterFont(void)
|
|
|
|
|
{ // GWM creates a set of display lists which may be used to render a character string on the screen
|
|
|
|
|
// data from GWM's reading of the Windows ASCII_FIXED_FONT.
|
|
|
|
|
GLubyte rasters[][12] = { // ascii symbols 32-127, small font
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x14, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x28, 0x28, 0x7e, 0x14, 0x14, 0x14, 0x3f, 0x0a, 0x0a, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x1c, 0x22, 0x02, 0x1c, 0x20, 0x22, 0x1c, 0x08, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x02, 0x45, 0x22, 0x10, 0x08, 0x04, 0x22, 0x51, 0x20, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3b, 0x44, 0x4a, 0x49, 0x30, 0x10, 0x20, 0x20, 0x18, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x00},
|
|
|
|
|
{0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00},
|
|
|
|
|
{0x10, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x10, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x36, 0x1c, 0x7f, 0x1c, 0x36, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x08, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x20, 0x10, 0x08, 0x04, 0x02, 0x02, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x02, 0x02, 0x0c, 0x02, 0x02, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x0e, 0x04, 0x3e, 0x24, 0x14, 0x14, 0x0c, 0x0c, 0x04, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x02, 0x02, 0x3c, 0x20, 0x20, 0x20, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x10, 0x0c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x22, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x18, 0x04, 0x02, 0x02, 0x1e, 0x22, 0x22, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x04, 0x02, 0x02, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x20, 0x4e, 0x55, 0x55, 0x55, 0x4d, 0x21, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x3e, 0x22, 0x14, 0x14, 0x08, 0x08, 0x18, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7e, 0x21, 0x21, 0x21, 0x3e, 0x21, 0x21, 0x21, 0x7e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1e, 0x21, 0x40, 0x40, 0x40, 0x40, 0x40, 0x21, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7c, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x7c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7f, 0x21, 0x20, 0x24, 0x3c, 0x24, 0x20, 0x21, 0x7f, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x78, 0x20, 0x20, 0x24, 0x3c, 0x24, 0x20, 0x21, 0x7f, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1e, 0x21, 0x41, 0x47, 0x40, 0x40, 0x40, 0x21, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x38, 0x44, 0x44, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x73, 0x22, 0x24, 0x38, 0x28, 0x24, 0x24, 0x22, 0x73, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7f, 0x11, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x2a, 0x2a, 0x36, 0x36, 0x22, 0x63, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x72, 0x22, 0x26, 0x26, 0x2a, 0x32, 0x32, 0x22, 0x67, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x78, 0x20, 0x20, 0x20, 0x3e, 0x21, 0x21, 0x21, 0x7e, 0x00},
|
|
|
|
|
{0x00, 0x1b, 0x1c, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x73, 0x22, 0x24, 0x24, 0x3e, 0x21, 0x21, 0x21, 0x7e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x01, 0x01, 0x3e, 0x40, 0x40, 0x41, 0x3e, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x49, 0x7f, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x08, 0x14, 0x14, 0x14, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x14, 0x14, 0x2a, 0x2a, 0x2a, 0x22, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x14, 0x14, 0x08, 0x14, 0x14, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1c, 0x08, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x77, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7f, 0x21, 0x10, 0x10, 0x08, 0x04, 0x04, 0x42, 0x7f, 0x00},
|
|
|
|
|
{0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00},
|
|
|
|
|
{0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x14, 0x08},
|
|
|
|
|
{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3d, 0x42, 0x42, 0x3e, 0x02, 0x3c, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7e, 0x21, 0x21, 0x21, 0x21, 0x3e, 0x20, 0x20, 0x60, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x40, 0x40, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3f, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x06, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x40, 0x7f, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3c, 0x10, 0x10, 0x10, 0x10, 0x3c, 0x10, 0x10, 0x0c, 0x00},
|
|
|
|
|
{0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x3f, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x22, 0x32, 0x2c, 0x20, 0x20, 0x60, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x08, 0x00},
|
|
|
|
|
{0x38, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x3c, 0x00, 0x00, 0x04, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x63, 0x24, 0x38, 0x28, 0x24, 0x26, 0x20, 0x20, 0x60, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x6b, 0x2a, 0x2a, 0x2a, 0x2a, 0x74, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x22, 0x22, 0x32, 0x6c, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x41, 0x41, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x70, 0x20, 0x3e, 0x21, 0x21, 0x21, 0x21, 0x7e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x07, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x3f, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7c, 0x10, 0x10, 0x10, 0x19, 0x76, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x3e, 0x41, 0x06, 0x38, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x0c, 0x12, 0x10, 0x10, 0x10, 0x3c, 0x10, 0x10, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x1b, 0x26, 0x22, 0x22, 0x22, 0x66, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x08, 0x14, 0x14, 0x22, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x14, 0x14, 0x2a, 0x2a, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x77, 0x22, 0x1c, 0x1c, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x30, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x77, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x7e, 0x22, 0x10, 0x08, 0x44, 0x7e, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
|
{0x06, 0x08, 0x08, 0x08, 0x08, 0x30, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00},
|
|
|
|
|
{0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08},
|
|
|
|
|
{0x30, 0x08, 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x08, 0x08, 0x30, 0x00},
|
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x49, 0x31, 0x00, 0x00},
|
|
|
|
|
{0x00, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x00, 0x00}
|
|
|
|
|
};
|
|
|
|
|
// the remaining lines of this routine are similar to code developed and published in the
|
|
|
|
|
// OPENGL big red book. However I have modified the code slightly, and
|
|
|
|
|
// SGI are not responsible for any errors, omissions etc.
|
|
|
|
|
static GLuint fontOffset=0; // first display list
|
|
|
|
|
if (!fontOffset) { // then make the raster fonts
|
|
|
|
|
GLuint i;
|
|
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
|
|
|
|
|
|
fontOffset = glGenLists (128);
|
|
|
|
|
for (i = 32; i < 127; i++) {
|
|
|
|
|
glNewList(i+fontOffset, GL_COMPILE);
|
|
|
|
|
glBitmap(8, 12, 0.0, 2.0, 10.0, 0.0, rasters[i-32]);
|
|
|
|
|
glEndList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fontOffset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void displaytext(int x, int y, char *s)
|
|
|
|
|
{ // GWM July 2001 statistics text display at xy text S
|
|
|
|
|
GLuint fontOffset=makeRasterFont(); // first display list
|
|
|
|
|
glRasterPos2i(x,y);
|
|
|
|
|
glListBase(fontOffset);
|
|
|
|
|
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
|
|
|
|
|
glListBase(0);
|
|
|
|
|
// glPopAttrib ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void writePrims( const int ypos, osg::Statistics& stats)
|
|
|
|
|
{
|
|
|
|
|
char clin[100]; // buffer to print
|
|
|
|
|
char ctmp[12];
|
|
|
|
|
int i; // a counter
|
|
|
|
|
static char *prtypes[]={"Total",
|
|
|
|
|
" Pt", " Ln", " Lstr", " LSTf", " Llop", // 1- 5
|
|
|
|
|
" Tris", " TStr", " TSfl", " TFan", " TFnf", // 6-10
|
|
|
|
|
" Quad", " QStr", " Pols", "", "", // 11-15
|
|
|
|
|
"", "", "", "", ""};
|
|
|
|
|
glColor3f(.9f,.9f,0.0f);
|
|
|
|
|
|
|
|
|
|
sprintf(clin,"%d Prims %d Matxs %d Gsets %d nlts %d bins %d imps",
|
|
|
|
|
stats.nprims, stats.nummat, stats.numOpaque, stats.nlights, stats.nbins, stats.nimpostor);
|
|
|
|
|
displaytext(0,ypos,clin);
|
|
|
|
|
strcpy(clin," ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (i==0 || stats.primtypes[i]) {
|
|
|
|
|
strcat(clin, prtypes[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,ypos-12,clin);
|
|
|
|
|
strcpy(clin,"GSet type: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (stats.primtypes[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", stats.primtypes[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,ypos-24,clin);
|
|
|
|
|
strcpy(clin,"Prims: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (stats.primtypes[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", stats.numprimtypes[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,ypos-36,clin);
|
|
|
|
|
strcpy(clin,"Triangles: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (stats.primtypes[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", stats.primlens[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,ypos-48,clin);
|
|
|
|
|
strcpy(clin,"Vertices: ");
|
|
|
|
|
for (i=0; i<15; i++) {
|
|
|
|
|
if (stats.primtypes[i]) {
|
|
|
|
|
sprintf(ctmp,"%5d", stats.primverts[i]);
|
|
|
|
|
strcat(clin, ctmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
displaytext(0,ypos-60,clin);
|
|
|
|
|
}
|
|
|
|
|
|