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:
20  osg::ref_ptr<osg::DrawElements> getIndexBuffer (unsigned int numVerts, unsigned int flags);
21 
23  osg::ref_ptr<osg::Vec2Array> getUVBuffer(unsigned int numVerts);
24 
25  void clearCache();
26 
27  void releaseGLObjects(osg::State* state);
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<std::pair<int, 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 
39 }
40 
41 #endif
std::map< std::pair< int, int >, osg::ref_ptr< osg::DrawElements > > mIndexBufferMap
Definition: buffercache.hpp:32
void releaseGLObjects(osg::State *state)
Definition: buffercache.cpp:246
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
osg::ref_ptr< osg::Vec2Array > getUVBuffer(unsigned int numVerts)
Definition: buffercache.cpp:181
OpenThreads::Mutex mIndexBufferMutex
Definition: buffercache.hpp:33
OpenThreads::Mutex mUvBufferMutex
Definition: buffercache.hpp:36
State
Definition: state.hpp:6
osg::ref_ptr< osg::DrawElements > getIndexBuffer(unsigned int numVerts, unsigned int flags)
Definition: buffercache.cpp:210
void clearCache()
Definition: buffercache.cpp:234