Integrated Geoff Michel's updates to Stats code, whilest move all text rendering

back in the viewer from the Statistics header.

Added a osg::State::captureCurrentState(StateSet&) method and a copy constructor
to osg::StateSet.
This commit is contained in:
Robert Osfield
2001-10-22 22:02:47 +00:00
parent aac507e119
commit 25c8b05914
16 changed files with 453 additions and 345 deletions

View File

@@ -8,6 +8,7 @@
#include <osg/GeoSet>
#include <osg/Notify>
#include <osg/Statistics>
//#include <osg/mem_ptr>
@@ -682,3 +683,108 @@ Drawable::AttributeBitMask GeoSet::applyAttributeOperation(AttributeFunctor& auf
return ramb;
}
bool GeoSet::getStats(Statistics &stat)
{ // analyse the drawable GeoSet
const int np=getNumPrims(); // number of primitives in this geoset
stat.nprims += np;
const int type=getPrimType();
switch (type) {
case osg::GeoSet::POINTS:
case osg::GeoSet::LINES:
case osg::GeoSet::LINE_STRIP:
case osg::GeoSet::FLAT_LINE_STRIP:
case osg::GeoSet::LINE_LOOP:
case osg::GeoSet::TRIANGLE_STRIP:
case osg::GeoSet::FLAT_TRIANGLE_STRIP:
case osg::GeoSet::TRIANGLE_FAN:
case osg::GeoSet::FLAT_TRIANGLE_FAN:
case osg::GeoSet::QUAD_STRIP:
case osg::GeoSet::POLYGON:
stat.primtypes[type]++;
stat.primtypes[0]++;
break;
case osg::GeoSet::TRIANGLES: // should not have any lengths for tris & quads
stat.primtypes[type]++;
stat.primtypes[0]++;
stat.primlens[0]+=np;
stat.primlens[type]+=np;
stat.numprimtypes[type]+=np;
stat.primverts[type]+=3*np;
stat.primverts[0]+=3*np;
break;
case osg::GeoSet::QUADS:
stat.primtypes[type]++;
stat.primtypes[0]++;
stat.primlens[0]+=np*2;
stat.primlens[type]+=np*2; // quad is equiv to 2 triangles
stat.numprimtypes[type]+=np;
stat.primverts[type]+=4*np;
stat.primverts[0]+=4*np;
break;
case osg::GeoSet::NO_TYPE:
default:
break;
}
// now count the lengths, ie efficiency of triangulation
const int *lens=getPrimLengths(); // primitive lengths
if (lens) {
for (int i=0; i<np; i++) {
switch (type) {
case osg::GeoSet::POINTS:
case osg::GeoSet::LINES:
case osg::GeoSet::LINE_STRIP:
case osg::GeoSet::FLAT_LINE_STRIP:
case osg::GeoSet::LINE_LOOP:
case osg::GeoSet::TRIANGLES: // should not have any lengths for tris & quads
case osg::GeoSet::QUADS:
case osg::GeoSet::QUAD_STRIP:
case osg::GeoSet::POLYGON:
stat.primlens[0]+=lens[i];
stat.primlens[type]+=lens[i];
break;
case osg::GeoSet::TRIANGLE_STRIP:
case osg::GeoSet::FLAT_TRIANGLE_STRIP:
case osg::GeoSet::TRIANGLE_FAN:
case osg::GeoSet::FLAT_TRIANGLE_FAN:
stat.primlens[0]+=lens[i]-2;
stat.primlens[type]+=lens[i]-2; // tri strips & fans create lens[i]-2 triangles
break;
case osg::GeoSet::NO_TYPE:
default:
break;
}
switch (type) {
case osg::GeoSet::POINTS:
case osg::GeoSet::LINES:
case osg::GeoSet::LINE_STRIP:
case osg::GeoSet::FLAT_LINE_STRIP:
case osg::GeoSet::LINE_LOOP:
case osg::GeoSet::TRIANGLES:
case osg::GeoSet::QUADS:
case osg::GeoSet::TRIANGLE_STRIP:
case osg::GeoSet::FLAT_TRIANGLE_STRIP:
case osg::GeoSet::TRIANGLE_FAN:
case osg::GeoSet::FLAT_TRIANGLE_FAN:
case osg::GeoSet::QUAD_STRIP:
case osg::GeoSet::POLYGON:
stat.numprimtypes[0]++;
stat.numprimtypes[type]++;
stat.primverts[type]+=lens[i];
stat.primverts[0]+=lens[i];
break;
case osg::GeoSet::NO_TYPE:
default:
break;
}
}
} else { // no lengths - num prims is the length of a point set
switch (type) {
case osg::GeoSet::POINTS:
stat.numprimtypes[0]++;
stat.numprimtypes[type]++;
stat.primverts[type]+=np;
break;
}
}
return true;
}

View File

@@ -6,11 +6,13 @@
#include <math.h>
#include <float.h>
#include <osg/GeoSet>
#include <osg/ImpostorSprite>
#include <osg/Texture>
#include <osg/TexEnv>
#include <osg/AlphaFunc>
#include <osg/Notify>
#include <osg/Statistics>
using namespace osg;
@@ -283,3 +285,16 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i
return is;
}
bool ImpostorSprite::getStats(Statistics &stat)
{ // analyse the drawable Impostor Sprite
stat.primtypes[0]++;
stat.primtypes[GeoSet::QUADS]++;
stat.primlens[GeoSet::QUADS]+=2; // 1 quads quad is equiv to 2 triangles
stat.numprimtypes[GeoSet::QUADS]++;
stat.primverts[GeoSet::QUADS]+=4;
stat.primverts[0]+=38;
stat.nimpostor++;
return true;
}

View File

@@ -161,6 +161,36 @@ void State::popStateSet()
_drawStateStack.pop_back();
}
void State::captureCurrentState(StateSet& stateset) const
{
// empty the stateset first.
stateset.setAllToInherit();
for(ModeMap::const_iterator mitr=_modeMap.begin();
mitr!=_modeMap.end();
++mitr)
{
// note GLMode = mitr->first
const ModeStack& ms = mitr->second;
if (!ms.valueVec.empty())
{
stateset.setMode(mitr->first,ms.valueVec.back());
}
}
for(AttributeMap::const_iterator aitr=_attributeMap.begin();
aitr!=_attributeMap.end();
++aitr)
{
const AttributeStack& as = aitr->second;
if (!as.attributeVec.empty())
{
stateset.setAttribute(const_cast<StateAttribute*>(as.attributeVec.back().first));
}
}
}
void State::apply(const StateSet* dstate)
{
// equivilant to:

View File

@@ -21,6 +21,17 @@ StateSet::StateSet()
setRendingBinToInherit();
}
StateSet::StateSet(const StateSet& rhs):Object()
{
_modeList = rhs._modeList;
_attributeList = rhs._attributeList;
_renderingHint = rhs._renderingHint;
_binMode = rhs._binMode;
_binNum = rhs._binNum;
_binName = rhs._binName;
}
StateSet::~StateSet()
{

View File

@@ -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);
}

View File

@@ -160,15 +160,16 @@ void RenderBin::draw_local(osg::State& state,RenderLeaf*& previous)
}
}
}
// stats
#include <osg/GeoSet>
void RenderBin::getPrims(osg::Statistics *primStats)
void RenderBin::getStats(Statistics& primStats)
{
for(RenderBinList::iterator itr = _bins.begin();
itr!=_bins.end();
++itr)
{
primStats->nbins++;
primStats.nbins++;
itr->second->getStats(primStats); // gwm 19.08.01 - multi-pass rendering uses these bins too.
}
for(RenderGraphList::iterator oitr=_renderGraphList.begin();
@@ -182,16 +183,10 @@ void RenderBin::getPrims(osg::Statistics *primStats)
{
RenderLeaf* rl = dw_itr->get();
Drawable* dw= rl->_drawable;
primStats->numOpaque++; // number of geosets
if (rl->_matrix.get()) primStats->nummat++; // number of matrices
primStats.numOpaque++; // number of geosets
if (rl->_matrix.get()) primStats.nummat++; // number of matrices
if (dw) { // then tot up the types 1-14
GeoSet *gs=dynamic_cast<osg::GeoSet*>(dw);
if (gs)
{
primStats->addstat(gs);
// rl->getPrims(state,previous);??
// previous = rl;
}
dw->getStats(primStats); // use sub-class to find the stats for each drawable
}
}
}

View File

@@ -140,8 +140,8 @@ void RenderStage::draw(osg::State& state,RenderLeaf*& previous)
}
// Statistics features
void RenderStage::getPrims(osg::Statistics *primStats)
void RenderStage::getStats(Statistics& primStats)
{
if (_renderStageLighting.valid()) primStats->nlights+=_renderStageLighting->_lightList.size();
RenderBin::getPrims(primStats);
if (_renderStageLighting.valid()) primStats.nlights+=_renderStageLighting->_lightList.size();
RenderBin::getStats(primStats);
}