OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
buffercache.hpp
Go to the documentation of this file.
1 #ifndef COMPONENTS_TERRAIN_BUFFERCACHE_H
2 #define COMPONENTS_TERRAIN_BUFFERCACHE_H
3 
4 #include <osg/ref_ptr>
5 #include <osg/Array>
6 #include <osg/PrimitiveSet>
7 
8 #include <map>
9 
10 namespace Terrain
11 {
12 
15  {
16  public:
17  BufferCache(unsigned int numVerts) : mNumVerts(numVerts) {}
18 
22  osg::ref_ptr<osg::DrawElements> getIndexBuffer (unsigned int flags);
23 
25  osg::ref_ptr<osg::Vec2Array> getUVBuffer();
26 
27  // TODO: add releaseGLObjects() for our vertex/element buffer objects
28 
29  private:
30  // Index buffers are shared across terrain batches where possible. There is one index buffer for each
31  // combination of LOD deltas and index buffer LOD we may need.
32  std::map<int, osg::ref_ptr<osg::DrawElements> > mIndexBufferMap;
33  OpenThreads::Mutex mIndexBufferMutex;
34 
35  std::map<int, osg::ref_ptr<osg::Vec2Array> > mUvBufferMap;
36  OpenThreads::Mutex mUvBufferMutex;
37 
38  unsigned int mNumVerts;
39  };
40 
41 }
42 
43 #endif
Implements creation and caching of vertex buffers for terrain chunks.
Definition: buffercache.hpp:14
std::map< int, osg::ref_ptr< osg::Vec2Array > > mUvBufferMap
Definition: buffercache.hpp:35
OpenThreads::Mutex mIndexBufferMutex
Definition: buffercache.hpp:33
unsigned int mNumVerts
Definition: buffercache.hpp:38
osg::ref_ptr< osg::Vec2Array > getUVBuffer()
Definition: buffercache.cpp:181
osg::ref_ptr< osg::DrawElements > getIndexBuffer(unsigned int flags)
Definition: buffercache.cpp:210
OpenThreads::Mutex mUvBufferMutex
Definition: buffercache.hpp:36
std::map< int, osg::ref_ptr< osg::DrawElements > > mIndexBufferMap
Definition: buffercache.hpp:32
BufferCache(unsigned int numVerts)
Definition: buffercache.hpp:17