OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLES2StateCacheManagerImp.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 __GLES2StateCacheManagerImp_H__
30 #define __GLES2StateCacheManagerImp_H__
31 
32 #include "OgreGLES2Prerequisites.h"
33 
35 
36 namespace Ogre
37 {
41  class _OgreGLES2Export GLES2StateCacheManagerImp : public StateCacheAlloc
42  {
43  private:
44  typedef HashMap<GLenum, GLuint> BindBufferMap;
45  typedef HashMap<GLenum, GLint> TexParameteriMap;
46  typedef HashMap<GLenum, GLfloat> TexParameterfMap;
47 
49  {
51  {
52  mTexParameteriMap.clear();
53  mTexParameterfMap.clear();
54  }
55 
58  };
59 
60  typedef HashMap<GLuint, TextureUnitParams> TexUnitsMap;
61 
62  /* These variables are used for caching OpenGL state.
63  They are cached because state changes can be quite expensive,
64  which is especially important on mobile or embedded systems.
65  */
66 
74  vector<GLclampf>::type mClearColour;
76  vector<GLboolean>::type mColourMask;
80  GLboolean mDepthMask;
82  GLenum mPolygonMode;
84  GLenum mBlendEquation;
90  GLenum mCullFace;
92  GLenum mDepthFunc;
94  GLuint mStencilMask;
100  unsigned int mDiscardBuffers;
102  GLclampf mClearDepth;
103 
104  public:
105  GLES2StateCacheManagerImp(void);
106  ~GLES2StateCacheManagerImp(void);
107 
109  void initializeCache();
110 
112  void clearCache();
113 
115  void bindGLBuffer(GLenum target, GLuint buffer, GLenum attach = 0, bool force = false);
116 
118  void deleteGLBuffer(GLenum target, GLuint buffer, GLenum attach = 0, bool force = false);
119 
121  void bindGLTexture(GLenum target, GLuint texture);
122 
124  void setTexParameteri(GLenum target, GLenum pname, GLint param);
125 
127  void setTexParameterf(GLenum target, GLenum pname, GLfloat params);
128 
130  void getTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
131 
133  void invalidateStateForTexture(GLuint texture);
134 
136  bool activateGLTextureUnit(size_t unit);
137 
139  GLenum getBlendEquation(void) const { return mBlendEquation; }
140 
142  void setBlendEquation(GLenum eq);
143 
145  void setBlendFunc(GLenum source, GLenum dest);
146 
148  GLboolean getDepthMask(void) const { return mDepthMask; }
149 
151  void setDepthMask(GLboolean mask);
152 
154  GLenum getDepthFunc(void) const { return mDepthFunc; }
155 
157  void setDepthFunc(GLenum func);
158 
160  GLclampf getClearDepth(void) const { return mClearDepth; }
161 
163  void setClearDepth(GLclampf depth);
164 
166  void setClearColour(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
167 
169  vector<GLboolean>::type & getColourMask(void) { return mColourMask; }
170 
172  void setColourMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
173 
175  GLuint getStencilMask(void) const { return mStencilMask; }
176 
178  void setStencilMask(GLuint mask);
179 
181  void setEnabled(GLenum flag);
182 
184  void setDisabled(GLenum flag);
185 
187  void setVertexAttribEnabled(GLuint attrib);
188 
190  void setVertexAttribDisabled(GLuint attrib);
191 
193  unsigned int getDiscardBuffers(void) const { return mDiscardBuffers; }
194 
196  void setDiscardBuffers(unsigned int flags) { mDiscardBuffers = flags; }
197 
199  GLenum getPolygonMode(void) const { return mPolygonMode; }
200 
202  void setPolygonMode(GLenum mode) { mPolygonMode = mode; }
203 
205  GLenum getCullFace(void) const { return mCullFace; }
206 
208  void setCullFace(GLenum face);
209  };
210 }
211 
212 #endif
GLboolean getDepthMask(void) const
See GLES2StateCacheManager.getDepthMask.
Ogre::GeneralAllocatedObject StateCacheAlloc
void setPolygonMode(GLenum mode)
See GLES2StateCacheManager.setPolygonMode.
#define _OgreGLES2Export
unsigned int getDiscardBuffers(void) const
See GLES2StateCacheManager.getDiscardBuffers.
GLuint mLastBoundTexID
Stores the last bound texture id.
GLenum getCullFace(void) const
See GLES2StateCacheManager.getCullFace.
void setDiscardBuffers(unsigned int flags)
See GLES2StateCacheManager.setDiscardBuffers.
GLenum getPolygonMode(void) const
See GLES2StateCacheManager.getPolygonMode.
GLclampf getClearDepth(void) const
See GLES2StateCacheManager.getClearDepth.
BindBufferMap mActiveBufferMap
A map of different buffer types and the currently bound buffer for each type.
GLuint getStencilMask(void) const
See GLES2StateCacheManager.getStencilMask.
GLenum mBlendFuncDest
Stores the current blend destination function.
vector< GLboolean >::type & getColourMask(void)
See GLES2StateCacheManager.getColourMask.
GLenum mActiveTextureUnit
Stores the currently active texture unit.
vector< GLenum >::type mEnableVector
Array of each OpenGL feature that is enabled i.e. blending, depth test, etc.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
GLenum mBlendFuncSource
Stores the current blend source function.
vector< GLuint >::type mEnabledVertexAttribs
Stores the currently enabled vertex attributes.
GLenum getBlendEquation(void) const
See GLES2StateCacheManager.getBlendEquation.
TexUnitsMap mTexUnitsMap
A map of texture parameters for each texture unit.
GLenum getDepthFunc(void) const
See GLES2StateCacheManager.getDepthFunc.
HashMap< GLuint, TextureUnitParams > TexUnitsMap