OgreGLESStateCacheManagerImp.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 __GLESStateCacheManagerImp_H__
30 #define __GLESStateCacheManagerImp_H__
31 
32 #include "OgreGLESPrerequisites.h"
33 
35 
36 namespace Ogre
37 {
41  class _OgreGLESExport GLESStateCacheManagerImp : public StateCacheAlloc
42  {
43  private:
44  typedef HashMap<GLuint, GLuint> GLBindingMap;
45  typedef HashMap<GLenum, GLint> TexParameteriMap;
46 
48  {
50  {
51  mTexParameteriMap.clear();
52  }
53 
55  };
56 
57  typedef HashMap<GLuint, TextureUnitParams> TexUnitsMap;
58 
59  /* These variables are used for caching OpenGL state.
60  They are cached because state changes can be quite expensive,
61  which is especially important on mobile or embedded systems.
62  */
63 
73  vector<GLclampf>::type mClearColour;
75  vector<GLboolean>::type mColourMask;
77  GLboolean mDepthMask;
79  GLenum mPolygonMode;
81  GLenum mBlendEquation;
83  GLenum mBlendFuncSrc;
88  GLenum mCullFace;
90  GLenum mDepthFunc;
92  GLuint mStencilMask;
94  unsigned char mActiveTextureUnit;
96  unsigned int mDiscardBuffers;
98  GLclampf mClearDepth;
99 
100  public:
103 
105  void initializeCache();
106 
108  void clearCache();
109 
111  void bindGLBuffer(GLenum target, GLuint buffer, GLenum attach = 0, bool force = false);
112 
114  void deleteGLBuffer(GLenum target, GLuint buffer, GLenum attach = 0, bool force = false);
115 
117  void bindGLTexture(GLenum target, GLuint texture);
118 
120  void setTexParameteri(GLenum target, GLenum pname, GLint param);
121 
123  bool activateGLTextureUnit(unsigned char unit);
124 
126  GLenum getBlendEquation(void) const { return mBlendEquation; }
127 
129  void setBlendEquation(GLenum eq);
130 
132  void setBlendFunc(GLenum source, GLenum dest);
133 
135  GLboolean getDepthMask(void) const { return mDepthMask; }
136 
138  void setDepthMask(GLboolean mask);
139 
141  GLenum getDepthFunc(void) const { return mDepthFunc; }
142 
144  void setDepthFunc(GLenum func);
145 
147  GLclampf getClearDepth(void) const { return mClearDepth; }
148 
150  void setClearDepth(GLclampf depth);
151 
153  void setClearColour(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
154 
156  vector<GLboolean>::type & getColourMask(void) { return mColourMask; }
157 
159  void setColourMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
160 
162  GLuint getStencilMask(void) const { return mStencilMask; }
163 
165  void setStencilMask(GLuint mask);
166 
168  void setEnabled(GLenum flag);
169 
171  void setDisabled(GLenum flag);
172 
174  unsigned int getDiscardBuffers(void) const { return mDiscardBuffers; }
175 
177  void setDiscardBuffers(unsigned int flags) { mDiscardBuffers = flags; }
178 
180  GLenum getPolygonMode(void) const { return mPolygonMode; }
181 
183  void setPolygonMode(GLenum mode) { mPolygonMode = mode; }
184 
186  GLenum getCullFace(void) const { return mCullFace; }
187 
189  void setCullFace(GLenum face);
190  };
191 }
192 
193 #endif
Ogre::GLESStateCacheManagerImp::mActiveBufferMap
GLBindingMap mActiveBufferMap
A map of different buffer types and the currently bound buffer for each type.
Definition: OgreGLESStateCacheManagerImp.h:65
Ogre::GLESStateCacheManagerImp::getCullFace
GLenum getCullFace(void) const
See GLESStateCacheManager.getCullFace.
Definition: OgreGLESStateCacheManagerImp.h:186
Ogre::GLESStateCacheManagerImp::mTexUnitsMap
TexUnitsMap mTexUnitsMap
A map of texture parameters for each texture unit.
Definition: OgreGLESStateCacheManagerImp.h:69
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GLESStateCacheManagerImp::mActiveTextureMap
GLBindingMap mActiveTextureMap
A map of different texture types and the currently bound texture for each type.
Definition: OgreGLESStateCacheManagerImp.h:67
Ogre::GLESStateCacheManagerImp::getStencilMask
GLuint getStencilMask(void) const
See GLESStateCacheManager.getStencilMask.
Definition: OgreGLESStateCacheManagerImp.h:162
Ogre::GLESStateCacheManagerImp::TextureUnitParams::~TextureUnitParams
~TextureUnitParams()
Definition: OgreGLESStateCacheManagerImp.h:49
Ogre::GLESStateCacheManagerImp::TextureUnitParams
Definition: OgreGLESStateCacheManagerImp.h:47
Ogre::GLESStateCacheManagerImp::getDepthFunc
GLenum getDepthFunc(void) const
See GLESStateCacheManager.getDepthFunc.
Definition: OgreGLESStateCacheManagerImp.h:141
_OgreGLESExport
#define _OgreGLESExport
Definition: OgreGLESPrerequisites.h:139
OgreGLESPrerequisites.h
Ogre::GLESStateCacheManagerImp::setPolygonMode
void setPolygonMode(GLenum mode)
See GLESStateCacheManager.setPolygonMode.
Definition: OgreGLESStateCacheManagerImp.h:183
Ogre::GLESStateCacheManagerImp::GLBindingMap
HashMap< GLuint, GLuint > GLBindingMap
Definition: OgreGLESStateCacheManagerImp.h:44
Ogre::GLESStateCacheManagerImp::getColourMask
vector< GLboolean >::type & getColourMask(void)
See GLESStateCacheManager.getColourMask.
Definition: OgreGLESStateCacheManagerImp.h:156
Ogre::GLESStateCacheManagerImp
An in memory cache of the OpenGL ES state.
Definition: OgreGLESNullStateCacheManagerImp.h:41
Ogre::GLESStateCacheManagerImp::mBlendFuncSrc
GLenum mBlendFuncSrc
Stores the current blend function.
Definition: OgreGLESStateCacheManagerImp.h:83
Ogre::GLESStateCacheManagerImp::getDepthMask
GLboolean getDepthMask(void) const
See GLESStateCacheManager.getDepthMask.
Definition: OgreGLESStateCacheManagerImp.h:135
Ogre::GLESStateCacheManagerImp::mBlendFuncDest
GLenum mBlendFuncDest
Definition: OgreGLESStateCacheManagerImp.h:84
Ogre::GLESStateCacheManagerImp::getBlendEquation
GLenum getBlendEquation(void) const
See GLESStateCacheManager.getBlendEquation.
Definition: OgreGLESStateCacheManagerImp.h:126
Ogre::GLESStateCacheManagerImp::mLastBoundedTexID
GLuint mLastBoundedTexID
Stores the last bounded texture id.
Definition: OgreGLESStateCacheManagerImp.h:86
Ogre::GLESStateCacheManagerImp::getClearDepth
GLclampf getClearDepth(void) const
See GLESStateCacheManager.getClearDepth.
Definition: OgreGLESStateCacheManagerImp.h:147
Ogre::GLESStateCacheManagerImp::TextureUnitParams::mTexParameteriMap
TexParameteriMap mTexParameteriMap
Definition: OgreGLESStateCacheManagerImp.h:54
StateCacheAlloc
Ogre::GeneralAllocatedObject StateCacheAlloc
Definition: OgreGLESStateCacheManagerImp.h:34
Ogre::GLESStateCacheManagerImp::TexParameteriMap
HashMap< GLenum, GLint > TexParameteriMap
Definition: OgreGLESStateCacheManagerImp.h:45
Ogre::GLESStateCacheManagerImp::setDiscardBuffers
void setDiscardBuffers(unsigned int flags)
See GLESStateCacheManager.setDiscardBuffers.
Definition: OgreGLESStateCacheManagerImp.h:177
Ogre::GLESStateCacheManagerImp::getPolygonMode
GLenum getPolygonMode(void) const
See GLESStateCacheManager.getPolygonMode.
Definition: OgreGLESStateCacheManagerImp.h:180
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::GLESStateCacheManagerImp::mEnableVector
vector< GLenum >::type mEnableVector
Array of each OpenGL feature that is enabled i.e. blending, depth test, etc.
Definition: OgreGLESStateCacheManagerImp.h:71
Ogre::GLESStateCacheManagerImp::getDiscardBuffers
unsigned int getDiscardBuffers(void) const
See GLESStateCacheManager.getDiscardBuffers.
Definition: OgreGLESStateCacheManagerImp.h:174
Ogre::GLESStateCacheManagerImp::TexUnitsMap
HashMap< GLuint, TextureUnitParams > TexUnitsMap
Definition: OgreGLESStateCacheManagerImp.h:57

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15