OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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 __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:
101  GLESStateCacheManagerImp(void);
102  ~GLESStateCacheManagerImp(void);
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(size_t 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
vector< GLenum >::type mEnableVector
Array of each OpenGL feature that is enabled i.e. blending, depth test, etc.
GLboolean getDepthMask(void) const
See GLESStateCacheManager.getDepthMask.
GLenum getPolygonMode(void) const
See GLESStateCacheManager.getPolygonMode.
void setPolygonMode(GLenum mode)
See GLESStateCacheManager.setPolygonMode.
vector< GLboolean >::type & getColourMask(void)
See GLESStateCacheManager.getColourMask.
GLuint mLastBoundedTexID
Stores the last bounded texture id.
unsigned int getDiscardBuffers(void) const
See GLESStateCacheManager.getDiscardBuffers.
#define _OgreGLESExport
TexUnitsMap mTexUnitsMap
A map of texture parameters for each texture unit.
GLuint getStencilMask(void) const
See GLESStateCacheManager.getStencilMask.
GLenum mBlendFuncSrc
Stores the current blend function.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
void setDiscardBuffers(unsigned int flags)
See GLESStateCacheManager.setDiscardBuffers.
Ogre::GeneralAllocatedObject StateCacheAlloc
HashMap< GLuint, TextureUnitParams > TexUnitsMap
GLenum getBlendEquation(void) const
See GLESStateCacheManager.getBlendEquation.
GLBindingMap mActiveTextureMap
A map of different texture types and the currently bound texture for each type.
GLenum getCullFace(void) const
See GLESStateCacheManager.getCullFace.
GLclampf getClearDepth(void) const
See GLESStateCacheManager.getClearDepth.
GLBindingMap mActiveBufferMap
A map of different buffer types and the currently bound buffer for each type.
GLenum getDepthFunc(void) const
See GLESStateCacheManager.getDepthFunc.