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 __GLESNullStateCacheManagerImp_H__
30 #define __GLESNullStateCacheManagerImp_H__
31 
32 #include "OgreGLESPrerequisites.h"
33 
34 typedef _OgreGLESExport Ogre::GeneralAllocatedObject StateCacheAlloc;
35 
36 namespace Ogre
37 {
38     /** An in memory cache of the OpenGL ES state.
39      @see GLESStateCacheManager
40      */
41     class GLESStateCacheManagerImp : public StateCacheAlloc
42     {
43     private:
44         /// Stores the current clear colour
45         vector<GLclampf>::type mClearColour;
46         /// Stores the current colour write mask
47         vector<GLboolean>::type mColourMask;
48         /// Stores the current depth write mask
49         GLboolean mDepthMask;
50         /// Stores the current polygon rendering mode
51         GLenum mPolygonMode;
52         /// Stores the current blend equation
53         GLenum mBlendEquation;
54         /// Stores the current face culling setting
55         GLenum mCullFace;
56         /// Stores the current depth test function
57         GLenum mDepthFunc;
58         /// Stores the current stencil mask
59         GLuint mStencilMask;
60         /// Stores the currently active texture unit
61         unsigned char mActiveTextureUnit;
62         /// Mask of buffers who contents can be discarded if GL_EXT_discard_framebuffer is supported
63         unsigned int mDiscardBuffers;
64         /// Stores the current depth clearing colour
65         GLclampf mClearDepth;
66 
67     public:
68         GLESStateCacheManagerImp(void);
69         ~GLESStateCacheManagerImp(void);
70 
71         /// See GLESStateCacheManager.initializeCache.
72         void initializeCache();
73 
74         /// See GLESStateCacheManager.clearCache.
75         void clearCache();
76 
77         /// See GLESStateCacheManager.bindGLBuffer.
78         void bindGLBuffer(GLenum target, GLuint buffer, GLenum attach = 0, bool force = false);
79 
80         /// See GLESStateCacheManager.deleteGLBuffer.
81         void deleteGLBuffer(GLenum target, GLuint buffer, GLenum attach = 0, bool force = false);
82 
83         /// See GLESStateCacheManager.bindGLTexture.
84         void bindGLTexture(GLenum target, GLuint texture);
85 
86         /// See GLESStateCacheManager.setTexParameteri.
87         void setTexParameteri(GLenum target, GLenum pname, GLint param);
88 
89         /// See GLESStateCacheManager.activateGLTextureUnit.
90         bool activateGLTextureUnit(unsigned char unit);
91 
92         /// See GLESStateCacheManager.getBlendEquation.
getBlendEquation(void)93         GLenum getBlendEquation(void) const { return mBlendEquation; }
94 
95         /// See GLESStateCacheManager.setBlendEquation.
96         void setBlendEquation(GLenum eq);
97 
98         /// See GLESStateCacheManager.setBlendFunc.
99         void setBlendFunc(GLenum source, GLenum dest);
100 
101         /// See GLESStateCacheManager.getDepthMask.
getDepthMask(void)102         GLboolean getDepthMask(void) const { return mDepthMask; }
103 
104         /// See GLESStateCacheManager.setDepthMask.
105         void setDepthMask(GLboolean mask);
106 
107         /// See GLESStateCacheManager.getDepthFunc.
getDepthFunc(void)108         GLenum getDepthFunc(void) const { return mDepthFunc; }
109 
110         /// See GLESStateCacheManager.setDepthFunc.
111         void setDepthFunc(GLenum func);
112 
113         /// See GLESStateCacheManager.getClearDepth.
getClearDepth(void)114         GLclampf getClearDepth(void) const { return mClearDepth; }
115 
116         /// See GLESStateCacheManager.setClearDepth.
117         void setClearDepth(GLclampf depth);
118 
119         /// See GLESStateCacheManager.setClearColour.
120         void setClearColour(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
121 
122         /// See GLESStateCacheManager.getColourMask.
getColourMask(void)123         vector<GLboolean>::type & getColourMask(void) { return mColourMask; }
124 
125         /// See GLESStateCacheManager.setColourMask.
126         void setColourMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
127 
128         /// See GLESStateCacheManager.getStencilMask.
getStencilMask(void)129         GLuint getStencilMask(void) const { return mStencilMask; }
130 
131         /// See GLESStateCacheManager.setStencilMask.
132         void setStencilMask(GLuint mask);
133 
134         /// See GLESStateCacheManager.setEnabled.
135         void setEnabled(GLenum flag);
136 
137         /// See GLESStateCacheManager.setDisabled.
138         void setDisabled(GLenum flag);
139 
140         /// See GLESStateCacheManager.getDiscardBuffers.
getDiscardBuffers(void)141         unsigned int getDiscardBuffers(void) const { return mDiscardBuffers; }
142 
143         /// See GLESStateCacheManager.setDiscardBuffers.
setDiscardBuffers(unsigned int flags)144         void setDiscardBuffers(unsigned int flags) { mDiscardBuffers = flags; }
145 
146         /// See GLESStateCacheManager.getPolygonMode.
getPolygonMode(void)147         GLenum getPolygonMode(void) const { return mPolygonMode; }
148 
149         /// See GLESStateCacheManager.setPolygonMode.
setPolygonMode(GLenum mode)150         void setPolygonMode(GLenum mode) { mPolygonMode = mode; }
151 
152         /// See GLESStateCacheManager.getCullFace.
getCullFace(void)153         GLenum getCullFace(void) const { return mCullFace; }
154 
155         /// See GLESStateCacheManager.setCullFace.
156         void setCullFace(GLenum face);
157     };
158 }
159 
160 #endif
161