diff --git a/components/terrain/buffercache.cpp b/components/terrain/buffercache.cpp index 7dc93f1d65..dfb3eff883 100644 --- a/components/terrain/buffercache.cpp +++ b/components/terrain/buffercache.cpp @@ -218,6 +218,9 @@ namespace Terrain } } + // Assign a VBO here to enable state sharing between different Geometries. + uvs->setVertexBufferObject(new osg::VertexBufferObject); + mUvBufferMap[mNumVerts] = uvs; return uvs; } @@ -238,6 +241,9 @@ namespace Terrain else buffer = createIndexBuffer(flags, verts); + // Assign a EBO here to enable state sharing between different Geometries. + buffer->setElementBufferObject(new osg::ElementBufferObject); + mIndexBufferMap[flags] = buffer; return buffer; } diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index e99126a2a8..7ae4d85116 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -104,6 +104,11 @@ void TerrainGrid::loadCell(int x, int y) osg::ref_ptr normals (new osg::Vec3Array); osg::ref_ptr colors (new osg::Vec4Array); + osg::ref_ptr vbo (new osg::VertexBufferObject); + positions->setVertexBufferObject(vbo); + normals->setVertexBufferObject(vbo); + colors->setVertexBufferObject(vbo); + mStorage->fillVertexBuffers(0, 1, center, positions, normals, colors); osg::ref_ptr geometry (new osg::Geometry);