//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield //Distributed under the terms of the GNU Library General Public License (LGPL) //as published by the Free Software Foundation. #ifndef OSGUTIL_STATISTICS #define OSGUTIL_STATISTICS 1 #include namespace osg { /** * Statistics base class. Used to extract primitive information from * the renderBin(s). Add a case of getStats(osgUtil::Statistics *stat) * for any new drawable (or drawable derived class) that you generate * (eg see GeoSet.cpp). There are 20 types of drawable counted - actually only * 14 cases can occur in reality. these represent sets of GL_POINTS, GL_LINES * GL_LINESTRIPS, LOOPS, TRIANGLES, TRI-fans, tristrips, quads, quadstrips etc * The number of triangles rendered is inferred: * each triangle = 1 triangle (number of vertices/3) * each quad = 2 triangles (nverts/2) * each trifan or tristrip = (length-2) triangles and so on. */ class SG_EXPORT Statistics : public osg::Object { public: Statistics() { numOpaque=0, nummat=0; nprims=0, nlights=0; nbins=0; nimpostor=0; reset(); }; ~Statistics() {}; // no dynamic allocations, so no need to free virtual osg::Object* clone() const { return new Statistics(); } virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=0L; } virtual const char* className() const { return "Statistics"; } enum statsType { STAT_NONE, // default STAT_FRAMERATE, STAT_GRAPHS, STAT_PRIMS, STAT_PRIMSPERVIEW, STAT_DC, STAT_RESTART // hint to restart the stats }; void reset() { for (int i=0; i<20; i++) primverts[i]=numprimtypes[i]=primlens[i]=primtypes[i]=0; } public: int numOpaque, nummat, nbins; int nprims, nlights; int nimpostor; // number of impostors rendered int numprimtypes[20]; // histogram of number of each type of prim int primtypes[20]; // histogram of number of each type of prim int primlens[20]; // histogram of lengths of each type of prim int primverts[20]; // histogram of number of vertices to be transformed protected: }; } #endif