OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2014 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  class GLStateCacheManager;
37 
38 // Default threshold at which glMapBuffer becomes more efficient than glBufferSubData (32k?)
39 # define OGRE_GL_DEFAULT_MAP_BUFFER_THRESHOLD (1024 * 32)
40 
43  {
44  protected:
47  OGRE_MUTEX(mScratchMutex);
49 
50  public:
54  HardwareVertexBufferSharedPtr createVertexBuffer(size_t vertexSize,
55  size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
57  HardwareIndexBufferSharedPtr createIndexBuffer(
58  HardwareIndexBuffer::IndexType itype, size_t numIndexes,
59  HardwareBuffer::Usage usage, bool useShadowBuffer = false);
61  RenderToVertexBufferSharedPtr createRenderToVertexBuffer();
63  HardwareUniformBufferSharedPtr createUniformBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,bool useShadowBuffer, const String& name = "");
64  HardwareCounterBufferSharedPtr createCounterBuffer(size_t sizeBytes,
66  bool useShadowBuffer = false, const String& name = "");
68  static GLenum getGLUsage(unsigned int usage);
69 
71  static GLenum getGLType(unsigned int type);
72 
73  GLStateCacheManager * getStateCacheManager() { return mStateCacheManager; }
74 
82  void* allocateScratch(uint32 size);
83 
85  void deallocateScratch(void* ptr);
86 
89  size_t getGLMapBufferThreshold() const;
90  void setGLMapBufferThreshold( const size_t value );
91  };
92 
95  {
96  public:
99  {
100 
101  }
103  {
104  OGRE_DELETE mImpl;
105  }
106 
107 
108 
110  static GLenum getGLUsage(unsigned int usage)
111  { return GLHardwareBufferManagerBase::getGLUsage(usage); }
112 
114  static GLenum getGLType(unsigned int type)
116 
125  {
126  return static_cast<GLHardwareBufferManagerBase*>(mImpl)->allocateScratch(size);
127  }
128 
130  void deallocateScratch(void* ptr)
131  {
132  static_cast<GLHardwareBufferManagerBase*>(mImpl)->deallocateScratch(ptr);
133  }
134 
137  size_t getGLMapBufferThreshold() const
138  {
139  return static_cast<GLHardwareBufferManagerBase*>(mImpl)->getGLMapBufferThreshold();
140  }
141  void setGLMapBufferThreshold( const size_t value )
142  {
143  static_cast<GLHardwareBufferManagerBase*>(mImpl)->setGLMapBufferThreshold(value);
144  }
145 
146  };
147 
148 }
149 
150 #endif // __GLHARWAREBUFFERMANAGER_H__
unsigned int uint32
Definition: OgrePlatform.h:344
Singleton wrapper for hardware buffer manager.
Shared pointer implementation used to share uniform buffers.
#define OGRE_MUTEX(name)
Shared pointer implementation used to share vertex buffers.
#define _OgreGLExport
Combination of HBU_DYNAMIC, HBU_WRITE_ONLY and HBU_DISCARDABLE.
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.
size_t getGLMapBufferThreshold() const
Threshold after which glMapBuffer is used and not glBufferSubData.
Base definition of a hardware buffer manager.
Usage
Enums describing buffer usage; not mutually exclusive.
void setGLMapBufferThreshold(const size_t value)
Implementation of HardwareBufferManager for OpenGL.
GLHardwareBufferManagerBase as a Singleton.
#define OGRE_DELETE
#define OGRE_NEW
static GLenum getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
Shared pointer implementation used to share counter buffers.
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
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...
An in memory cache of the OpenGL state.