}
}
- osg::Geometry* buildGeometry(const TriangleVector& triangles) const
+ osg::Geometry* buildGeometry(const TriangleVector& triangles, bool useVBOs) const
{
// Do not build anything if there is nothing in here ...
if (empty() || triangles.empty())
colors->push_back(osg::Vec4(1, 1, 1, 1));
osg::Geometry* geometry = new osg::Geometry;
+ geometry->setUseDisplayList(false);
+ if (useVBOs)
+ geometry->setUseVertexBufferObjects(true);
+
geometry->setDataVariance(osg::Object::STATIC);
geometry->setVertexArray(vertices);
geometry->setNormalArray(normals);
return geometry;
}
- osg::Geometry* buildGeometry() const
- { return buildGeometry(getTriangles()); }
+ osg::Geometry* buildGeometry(bool useVBOs) const
+ { return buildGeometry(getTriangles(), useVBOs); }
int getTextureIndex() const
{
SGDirectionalLightListBin reilLights;
SGMatModelBin randomModels;
SGBuildingBinList randomBuildings;
-
+
static SGVec4f
getMaterialLightColor(const SGMaterial* material)
{
return true;
}
- osg::Node* getSurfaceGeometry(SGMaterialLib* matlib) const
+ osg::Node* getSurfaceGeometry(SGMaterialLib* matlib, bool useVBOs) const
{
if (materialTriangleMap.empty())
return 0;
//osg::Geode* geode = new osg::Geode;
SGMaterialTriangleMap::const_iterator i;
for (i = materialTriangleMap.begin(); i != materialTriangleMap.end(); ++i) {
- osg::Geometry* geometry = i->second.buildGeometry();
+ osg::Geometry* geometry = i->second.buildGeometry(useVBOs);
SGMaterial *mat = 0;
if (matlib)
mat = matlib->findCached(i->first);
matlib = options->getMaterialLib();
}
+ bool useVBOs = (options->getPluginStringData("SimGear::USE_VBOS") == "ON");
+
SGVec3d center = tile.get_gbs_center();
SGGeod geodPos = SGGeod::fromCart(center);
SGQuatd hlOr = SGQuatd::fromLonLat(geodPos)*SGQuatd::fromEulerDeg(0, 0, 180);
osg::Group* terrainGroup = new osg::Group;
terrainGroup->setName("BTGTerrainGroup");
- osg::Node* node = tileGeometryBin->getSurfaceGeometry(matlib);
+ osg::Node* node = tileGeometryBin->getSurfaceGeometry(matlib, useVBOs);
if (node)
terrainGroup->addChild(node);