diff --git a/examples/osggraphicscost/osggraphicscost.cpp b/examples/osggraphicscost/osggraphicscost.cpp
index 7f0cce48e..8ef8763a2 100644
--- a/examples/osggraphicscost/osggraphicscost.cpp
+++ b/examples/osggraphicscost/osggraphicscost.cpp
@@ -32,30 +32,25 @@
namespace osgUtil
{
-
-struct CostFunction1D
+struct ClampedLinearCostFunction1D
{
- virtual double operator() (unsigned int input) = 0;
-};
-
-struct LinearCostFunction1D : public CostFunction1D
-{
- LinearCostFunction1D(double cost0, double dcost_di):
- _cost0(cost0),
- _dcost_di(dcost_di) {}
- virtual double operator() (unsigned int input) { return _cost0 + _dcost_di * double(input); }
- double _cost0;
- double _dcost_di;
-};
-
-struct ClampedLinearCostFunction1D : public CostFunction1D
-{
- ClampedLinearCostFunction1D(double cost0, double dcost_di, unsigned int min_input):
+ ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0):
_cost0(cost0),
_dcost_di(dcost_di),
_min_input(min_input) {}
- virtual double operator() (unsigned int input) { return _cost0 + _dcost_di * double(input<=_min_input ? 0u : input-_min_input); }
+ void set(double cost0, double dcost_di, unsigned int min_input)
+ {
+ _cost0 = cost0;
+ _dcost_di = dcost_di;
+ _min_input = min_input;
+ }
+
+ double operator() (unsigned int input) const
+ {
+ OSG_NOTICE<<"ClampedLinearCostFunction1D::operator("<getUseVertexBufferObjects() && geometry->areFastPathsUsed();
+ bool usesDL = !usesVBO && geometry->getUseDisplayList() && geometry->getSupportsDisplayList();
+
+ if (usesVBO || usesDL)
+ {
+ CostPair cost;
+ if (geometry->getVertexArray()) { cost.first += _arrayCompileCost(geometry->getVertexArray()->getTotalDataSize()); }
+ if (geometry->getNormalArray()) { cost.first += _arrayCompileCost(geometry->getNormalArray()->getTotalDataSize()); }
+ if (geometry->getColorArray()) { cost.first += _arrayCompileCost(geometry->getColorArray()->getTotalDataSize()); }
+ if (geometry->getSecondaryColorArray()) { cost.first += _arrayCompileCost(geometry->getSecondaryColorArray()->getTotalDataSize()); }
+ if (geometry->getFogCoordArray()) { cost.first += _arrayCompileCost(geometry->getFogCoordArray()->getTotalDataSize()); }
+ for(unsigned i=0; igetNumTexCoordArrays(); ++i)
+ {
+ if (geometry->getTexCoordArray(i)) { cost.first += _arrayCompileCost(geometry->getTexCoordArray(i)->getTotalDataSize()); }
+ }
+ for(unsigned i=0; igetNumVertexAttribArrays(); ++i)
+ {
+ if (geometry->getVertexAttribArray(i)) { cost.first += _arrayCompileCost(geometry->getVertexAttribArray(i)->getTotalDataSize()); }
+ }
+ for(unsigned i=0; igetNumPrimitiveSets(); ++i)
+ {
+ const osg::PrimitiveSet* primSet = geometry->getPrimitiveSet(i);
+ const osg::DrawElements* drawElements = primSet ? primSet->getDrawElements() : 0;
+ if (drawElements) { cost.first += _primtiveSetCompileCost(drawElements->getTotalDataSize()); }
+ }
+
+
+
+ if (usesDL)
+ {
+ cost.first = _displayListCompileConstant + _displayListCompileFactor * cost.first ;
+ }
+
+ OSG_NOTICE<<" cost.first="<estimateCompileCost(geometry);
+
+ OSG_NOTICE<<"apply(Geometry), cost.first="<