OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLES2HardwareBufferManager.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-2013 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 __GLES2HardwareBufferManager_H__
30 #define __GLES2HardwareBufferManager_H__
31 
32 #include "OgreGLES2Prerequisites.h"
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)
45  size_t mMapBufferThreshold;
46 
47  public:
49  virtual ~GLES2HardwareBufferManagerBase();
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  RenderToVertexBufferSharedPtr createRenderToVertexBuffer();
59 
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  size_t getGLMapBufferThreshold() const;
81  void setGLMapBufferThreshold( const size_t value );
82  };
83 
86  {
87  public:
89  : HardwareBufferManager(OGRE_NEW GLES2HardwareBufferManagerBase())
90  {
91 
92  }
94  {
95  OGRE_DELETE mImpl;
96  }
97 
99  static GLenum getGLUsage(unsigned int usage)
101 
103  static GLenum getGLType(unsigned int type)
105 
114  {
115  return static_cast<GLES2HardwareBufferManagerBase*>(mImpl)->allocateScratch(size);
116  }
117 
119  void deallocateScratch(void* ptr)
120  {
121  static_cast<GLES2HardwareBufferManagerBase*>(mImpl)->deallocateScratch(ptr);
122  }
123 
126  size_t getGLMapBufferThreshold() const
127  {
128  return static_cast<GLES2HardwareBufferManagerBase*>(mImpl)->getGLMapBufferThreshold();
129  }
130  void setGLMapBufferThreshold( const size_t value )
131  {
132  static_cast<GLES2HardwareBufferManagerBase*>(mImpl)->setGLMapBufferThreshold(value);
133  }
134 
135  };
136 
137 }
138 
139 #endif
unsigned int uint32
Definition: OgrePlatform.h:270
Singleton wrapper for hardware buffer manager.
#define _OgreGLES2Export
Specialisation of HardwareBuffer for vertex index buffers, still abstract.
#define OGRE_MUTEX(name)
Shared pointer implementation used to share index buffers.
GLES2HardwareBufferManagerBase as a Singleton.
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.
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.
#define OGRE_DELETE
static GLenum getGLUsage(unsigned int usage)
Utility function to get the correct GL usage based on HBU's.
Implementation of HardwareBufferManager for OpenGL ES.
#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
void * allocateScratch(uint32 size)
Allocator method to allow us to use a pool of memory as a scratch area for hardware buffers...
size_t getGLMapBufferThreshold() const
Threshold after which glMapBuffer is used and not glBufferSubData.