OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreGLHardwareBufferManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2011 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __GLHARWAREBUFFERMANAGER_H__
29 #define __GLHARWAREBUFFERMANAGER_H__
30 
31 #include "OgreGLPrerequisites.h"
33 
34 namespace Ogre {
35 
36 // Default threshold at which glMapBuffer becomes more efficient than glBufferSubData (32k?)
37 # define OGRE_GL_DEFAULT_MAP_BUFFER_THRESHOLD (1024 * 32)
38 
39 
42  {
43  protected:
45  OGRE_MUTEX(mScratchMutex)
46  size_t mMapBufferThreshold;
47 
48  public:
50  ~GLHardwareBufferManagerBase();
52  HardwareVertexBufferSharedPtr createVertexBuffer(size_t vertexSize,
53  size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
55  HardwareIndexBufferSharedPtr createIndexBuffer(
56  HardwareIndexBuffer::IndexType itype, size_t numIndexes,
57  HardwareBuffer::Usage usage, bool useShadowBuffer = false);
59  RenderToVertexBufferSharedPtr createRenderToVertexBuffer();
61  static GLenum getGLUsage(unsigned int usage);
62 
64  static GLenum getGLType(unsigned int type);
65 
73  void* allocateScratch(uint32 size);
74 
76  void deallocateScratch(void* ptr);
77 
80  const size_t getGLMapBufferThreshold() const;
81  void setGLMapBufferThreshold( const size_t value );
82  };
83 
86  {
87  public:
89  : HardwareBufferManager(OGRE_NEW GLHardwareBufferManagerBase())
90  {
91 
92  }
94  {
95  OGRE_DELETE mImpl;
96  }
97 
98 
99 
101  static GLenum getGLUsage(unsigned int usage)
102  { return GLHardwareBufferManagerBase::getGLUsage(usage); }
103 
105  static GLenum getGLType(unsigned int type)
107 
116  {
117  return static_cast<GLHardwareBufferManagerBase*>(mImpl)->allocateScratch(size);
118  }
119 
121  void deallocateScratch(void* ptr)
122  {
123  static_cast<GLHardwareBufferManagerBase*>(mImpl)->deallocateScratch(ptr);
124  }
125 
128  const size_t getGLMapBufferThreshold() const
129  {
130  return static_cast<GLHardwareBufferManagerBase*>(mImpl)->getGLMapBufferThreshold();
131  }
132  void setGLMapBufferThreshold( const size_t value )
133  {
134  static_cast<GLHardwareBufferManagerBase*>(mImpl)->setGLMapBufferThreshold(value);
135  }
136 
137  };
138 
139 }
140 
141 #endif // __GLHARWAREBUFFERMANAGER_H__
unsigned int uint32
Definition: OgrePlatform.h:246
Singleton wrapper for hardware buffer manager.
Specialisation of HardwareBuffer for vertex index buffers, still abstract.
#define OGRE_MUTEX(name)
Shared pointer implementation used to share index buffers.
#define _OgreGLExport
static GLenum getGLUsage(unsigned int usage)
Utility function to get the correct GL usage based on HBU's.
Shared pointer implementation used to share index buffers.
static GLenum getGLUsage(unsigned int usage)
Utility function to get the correct GL usage based on HBU's.
Base definition of a hardware buffer manager.
void setGLMapBufferThreshold(const size_t value)
const size_t getGLMapBufferThreshold() const
Threshold after which glMapBuffer is used and not glBufferSubData.
Implementation of HardwareBufferManager for OpenGL.
GLHardwareBufferManagerBase as a Singleton.
#define OGRE_DELETE
#define OGRE_NEW
Abstract class defining common features of hardware buffers.
static GLenum getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:60
static GLenum getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
void * allocateScratch(uint32 size)
Allocator method to allow us to use a pool of memory as a scratch area for hardware buffers...