OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGL3PlusHardwareBufferManager.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 
29 #ifndef __GL3PlusHardwareBufferManager_H__
30 #define __GL3PlusHardwareBufferManager_H__
31 
34 
35 namespace Ogre {
36  // Default threshold at which glMapBuffer becomes more efficient than glBufferSubData (32k?)
37 # define OGRE_GL_DEFAULT_MAP_BUFFER_THRESHOLD (1024 * 32)
38 
41  {
42  protected:
44  OGRE_MUTEX(mScratchMutex);
46 
47  public:
51  HardwareVertexBufferSharedPtr createVertexBuffer(size_t vertexSize,
52  size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
54  HardwareIndexBufferSharedPtr createIndexBuffer(
55  HardwareIndexBuffer::IndexType itype, size_t numIndexes,
56  HardwareBuffer::Usage usage, bool useShadowBuffer = false);
58  HardwareUniformBufferSharedPtr createUniformBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
59  bool useShadowBuffer, const String& name = "");
61  HardwareUniformBufferSharedPtr createUniformBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
62  bool useShadowBuffer, size_t binding, const String& name = "");
64  HardwareCounterBufferSharedPtr createCounterBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
65  bool useShadowBuffer, const String& name = "");
67  RenderToVertexBufferSharedPtr createRenderToVertexBuffer();
68 
70  static GLenum getGLUsage(unsigned int usage);
71 
73  static GLenum getGLType(unsigned int type);
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 
108  static GLenum getGLUsage(unsigned int usage)
110 
112  static GLenum getGLType(unsigned int type)
114 
123  {
124  return static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->allocateScratch(size);
125  }
126 
128  void deallocateScratch(void* ptr)
129  {
130  static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->deallocateScratch(ptr);
131  }
132 
135  size_t getGLMapBufferThreshold() const
136  {
137  return static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->getGLMapBufferThreshold();
138  }
139  void setGLMapBufferThreshold( const size_t value )
140  {
141  static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->setGLMapBufferThreshold(value);
142  }
143 
144  };
145 
146 }
147 
148 #endif
GL3PlusHardwareBufferManagerBase as a Singleton.
size_t getGLMapBufferThreshold() const
Threshold after which glMapBuffer is used and not glBufferSubData.
Implementation of HardwareBufferManager for OpenGL.
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.
static GLenum getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
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 getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
Base definition of a hardware buffer manager.
static GLenum getGLUsage(unsigned int usage)
Utility function to get the correct GL usage based on HBU's.
Usage
Enums describing buffer usage; not mutually exclusive.
#define OGRE_DELETE
#define _OgreGL3PlusExport
#define OGRE_NEW
Shared pointer implementation used to share counter buffers.
void * allocateScratch(uint32 size)
Allocator method to allow us to use a pool of memory as a scratch area for hardware buffers...
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String