1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGCSMStatisticsForeground.h"
49 #include "OSGSimpleStatisticsForeground.h"
51 #include "OSGRenderAction.h"
52 #include "OSGPointLight.h"
53 #include "OSGSpotLight.h"
54 #include "OSGDirectionalLight.h"
58 // Documentation for this class is emitted in the
59 // OSGCSMStatisticsForegroundBase.cpp file.
60 // To modify it, please change the .fcd file (OSGCSMStatisticsForeground.fcd)
61 // and regenerate the base file.
63 /***************************************************************************\
65 \***************************************************************************/
67 /***************************************************************************\
69 \***************************************************************************/
71 void CSMStatisticsForeground::initMethod(InitPhase ePhase
)
73 Inherited::initMethod(ePhase
);
75 if(ePhase
== TypeObject::SystemPost
)
81 /***************************************************************************\
83 \***************************************************************************/
85 /*-------------------------------------------------------------------------*\
87 \*-------------------------------------------------------------------------*/
89 /*----------------------- constructors & destructors ----------------------*/
91 CSMStatisticsForeground::CSMStatisticsForeground(void) :
97 CSMStatisticsForeground::CSMStatisticsForeground(
98 const CSMStatisticsForeground
&source
) :
105 CSMStatisticsForeground::~CSMStatisticsForeground(void)
109 void CSMStatisticsForeground::draw(DrawEnv
*)
113 void CSMStatisticsForeground::addElement(
114 SimpleStatisticsForeground
*pStatFG
,
115 const std::string
&szStatObj
,
116 const std::string
&szStatElem
,
117 const std::string
&szFormat
)
119 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
120 if(szStatObj
.compare("Text") == 0)
122 if(szStatElem
.compare("freetext") == 0)
124 pStatFG
->addText(szFormat
.c_str());
128 fprintf(stderr
, "Unknown stat elem %s for %s\n",
133 else if(szStatObj
.compare("RenderAction") == 0)
135 if(szStatElem
.compare("statDrawTime") == 0)
137 pStatFG
->addElement(RenderAction::statDrawTime
,
140 else if(szStatElem
.compare("statTravTime") == 0)
142 pStatFG
->addElement(RenderAction::statTravTime
,
145 else if(szStatElem
.compare("statNMatrices") == 0)
147 pStatFG
->addElement(RenderAction::statNMatrices
,
150 else if(szStatElem
.compare("statNStates") == 0)
152 pStatFG
->addElement(RenderAction::statNStates
,
155 else if(szStatElem
.compare("statNChunks") == 0)
157 pStatFG
->addElement(RenderAction::statNChunks
,
160 else if(szStatElem
.compare("statNShaders") == 0)
162 pStatFG
->addElement(RenderAction::statNShaders
,
165 else if(szStatElem
.compare("statNShaderParams") == 0)
167 pStatFG
->addElement(RenderAction::statNShaderParams
,
172 fprintf(stderr
, "Unknown stat elem %s for %s\n",
177 else if(szStatObj
.compare("PointLight") == 0)
179 if(szStatElem
.compare("statNPointLights") == 0)
181 pStatFG
->addElement(PointLight::statNPointLights
,
186 fprintf(stderr
, "Unknown stat elem %s for %s\n",
191 else if(szStatObj
.compare("DirectionalLight") == 0)
193 if(szStatElem
.compare("statNDirectionalLights") == 0)
195 pStatFG
->addElement(DirectionalLight::statNDirectionalLights
,
200 fprintf(stderr
, "Unknown stat elem %s for %s\n",
205 else if(szStatObj
.compare("SpotLight") == 0)
207 if(szStatElem
.compare("statNSpotLights") == 0)
209 pStatFG
->addElement(SpotLight::statNSpotLights
,
214 fprintf(stderr
, "Unknown stat elem %s for %s\n",
219 else if(szStatObj
.compare("Drawable") == 0)
221 if(szStatElem
.compare("statNTriangles") == 0)
223 pStatFG
->addElement(Drawable::statNTriangles
,
226 else if(szStatElem
.compare("statNLines") == 0)
228 pStatFG
->addElement(Drawable::statNLines
,
231 else if(szStatElem
.compare("statNPoints") == 0)
233 pStatFG
->addElement(Drawable::statNPoints
,
236 else if(szStatElem
.compare("statNVertices") == 0)
238 pStatFG
->addElement(Drawable::statNVertices
,
241 else if(szStatElem
.compare("statNPrimitives") == 0)
243 pStatFG
->addElement(Drawable::statNPrimitives
,
246 else if(szStatElem
.compare("statNGeoBytes") == 0)
248 pStatFG
->addElement(Drawable::statNGeoBytes
,
251 else if(szStatElem
.compare("statNDrawFunctors") == 0)
253 pStatFG
->addElement(Drawable::statNDrawFunctors
,
258 fprintf(stderr
, "Unknown stat elem %s for %s\n",
263 else if(szStatObj
.compare("TextureObjChunk") == 0)
265 if(szStatElem
.compare("statNTextures") == 0)
267 pStatFG
->addElement(TextureObjChunk::statNTextures
,
270 else if(szStatElem
.compare("statNTexBytes") == 0)
272 pStatFG
->addElement(TextureObjChunk::statNTexBytes
,
277 fprintf(stderr
, "Unknown stat elem %s for %s\n",
282 else if(szStatObj
.compare("ChangeList") == 0)
284 if(szStatElem
.compare("statNChangedStoreSize") == 0)
286 pStatFG
->addElement(ChangeList::statNChangedStoreSize
,
289 else if(szStatElem
.compare("statNCreatedStoreSize") == 0)
291 pStatFG
->addElement(ChangeList::statNCreatedStoreSize
,
294 else if(szStatElem
.compare("statNUnCommittedStoreSize") == 0)
296 pStatFG
->addElement(ChangeList::statNUnCommittedStoreSize
,
299 else if(szStatElem
.compare("statNPoolSize") == 0)
301 pStatFG
->addElement(ChangeList::statNPoolSize
,
306 fprintf(stderr
, "Unknown stat elem %s for %s\n",
311 else if(szStatObj
.compare("Partition") == 0)
313 if(szStatElem
.compare("statCullTestedNodes") == 0)
315 pStatFG
->addElement(RenderPartition::statCullTestedNodes
,
318 else if(szStatElem
.compare("statCulledNodes") == 0)
320 pStatFG
->addElement(RenderPartition::statCulledNodes
,
325 fprintf(stderr
, "Unknown stat elem %s for %s\n",
332 fprintf(stderr
, "Unknown stat object %s\n",
338 bool CSMStatisticsForeground::init(CSMWindow
*pCSMWin
)
340 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
341 SimpleStatisticsForegroundUnrecPtr pStatFG
=
342 OSG::SimpleStatisticsForeground::create();
344 pStatFG
->setActive (this->getActive ());
345 pStatFG
->setSize (this->getSize ());
346 pStatFG
->setColor (this->getColor ());
347 pStatFG
->setBgColor(this->getBgColor());
351 if(_mfElements
.size() != 0)
353 std::string
szSep("::");
355 for(SizeT i
= 0; i
< _mfElements
.size(); ++i
)
357 SizeT uiPos
= _mfElements
[i
].rfind(szSep
);
359 if(uiPos
!= std::string::npos
)
361 std::string szElem
= _mfElements
[i
].substr(0,
363 std::string szFormat
= _mfElements
[i
].substr(uiPos
+ 2,
366 if(szElem
.size() == 0 || szFormat
.size() == 0)
369 uiPos
= szElem
.rfind(szSep
);
371 if(uiPos
!= std::string::npos
)
373 std::string szStatObj
= szElem
.substr(0,
375 std::string szStatElem
= szElem
.substr(uiPos
+ 2,
378 if(szStatObj
.size() == 0 || szStatElem
.size() == 0)
390 // pStatFG->addElement(RenderAction::statDrawTime, "Draw FPS: %r.3f");
391 // pStatFG->addElement(RenderAction::statDrawTime, "DrawTime: %.3f s");
397 StatisticsForeground
*CSMStatisticsForeground::getOSGForeground(void)
402 void CSMStatisticsForeground::resolveLinks(void)
406 Inherited::resolveLinks();
409 /*----------------------------- class specific ----------------------------*/
411 void CSMStatisticsForeground::changed(ConstFieldMaskArg whichField
,
415 Inherited::changed(whichField
, origin
, details
);
418 void CSMStatisticsForeground::dump( UInt32
,
419 const BitVector
) const
421 SLOG
<< "Dump CSMStatisticsForeground NI" << std::endl
;