OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLESHardwareBufferManager.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) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
8 Copyright (c) 2000-2013 Torus Knot Software Ltd
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 
30 #ifndef __GLESHardwareBufferManager_H__
31 #define __GLESHardwareBufferManager_H__
32 
33 #include "OgreGLESPrerequisites.h"
35 
36 namespace Ogre {
37  // Default threshold at which glMapBuffer becomes more efficient than glBufferSubData (32k?)
38  # define OGRE_GL_MAP_BUFFER_THRESHOLD (1024 * 32)
39 
42  {
43  protected:
45  OGRE_MUTEX(mScratchMutex)
46  size_t mMapBufferThreshold;
47 
48  public:
50  virtual ~GLESHardwareBufferManagerBase();
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();
60 
62  static GLenum getGLUsage(unsigned int usage);
63 
65  static GLenum getGLType(unsigned int type);
66 
74  void* allocateScratch(uint32 size);
75 
77  void deallocateScratch(void* ptr);
78 
81  size_t getGLMapBufferThreshold() const;
82  void setGLMapBufferThreshold( const size_t value );
83  };
84 
87  {
88  public:
90  : HardwareBufferManager(OGRE_NEW GLESHardwareBufferManagerBase())
91  {
92 
93  }
95  {
96  OGRE_DELETE mImpl;
97  }
98 
99 
100 
102  static GLenum getGLUsage(unsigned int usage)
104 
106  static GLenum getGLType(unsigned int type)
108 
117  {
118  return static_cast<GLESHardwareBufferManagerBase*>(mImpl)->allocateScratch(size);
119  }
120 
122  void deallocateScratch(void* ptr)
123  {
124  static_cast<GLESHardwareBufferManagerBase*>(mImpl)->deallocateScratch(ptr);
125  }
128  size_t getGLMapBufferThreshold() const
129  {
130  return static_cast<GLESHardwareBufferManagerBase*>(mImpl)->getGLMapBufferThreshold();
131  }
132  void setGLMapBufferThreshold( const size_t value )
133  {
134  static_cast<GLESHardwareBufferManagerBase*>(mImpl)->setGLMapBufferThreshold(value);
135  }
136 
137  };
138 
139 }
140 
141 #endif
unsigned int uint32
Definition: OgrePlatform.h:270
Singleton wrapper for hardware buffer manager.
void * allocateScratch(uint32 size)
Allocator method to allow us to use a pool of memory as a scratch area for hardware buffers...
Specialisation of HardwareBuffer for vertex index buffers, still abstract.
#define OGRE_MUTEX(name)
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.
#define _OgreGLESExport
Implementation of HardwareBufferManager for OpenGL ES.
Shared pointer implementation used to share index buffers.
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.
#define OGRE_DELETE
size_t getGLMapBufferThreshold() const
Threshold after which glMapBuffer is used and not glBufferSubData.
#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.
GLESHardwareBufferManagerBase as a Singleton.