OgreGLNullStateCacheManagerImp.h
Go to the documentation of this file.
00001 /*
00002  -----------------------------------------------------------------------------
00003  This source file is part of OGRE
00004  (Object-oriented Graphics Rendering Engine)
00005  For the latest info, see http://www.ogre3d.org/
00006  
00007  Copyright (c) 2000-2013 Torus Knot Software Ltd
00008  
00009  Permission is hereby granted, free of charge, to any person obtaining a copy
00010  of this software and associated documentation files (the "Software"), to deal
00011  in the Software without restriction, including without limitation the rights
00012  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013  copies of the Software, and to permit persons to whom the Software is
00014  furnished to do so, subject to the following conditions:
00015  
00016  The above copyright notice and this permission notice shall be included in
00017  all copies or substantial portions of the Software.
00018  
00019  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025  THE SOFTWARE.
00026  -----------------------------------------------------------------------------
00027  */
00028 
00029 #ifndef __GLNullStateCacheManagerImp_H__
00030 #define __GLNullStateCacheManagerImp_H__
00031 
00032 #include "OgreGLPrerequisites.h"
00033 
00034 typedef Ogre::GeneralAllocatedObject StateCacheAlloc;
00035 
00036 namespace Ogre
00037 {
00041     class GLStateCacheManagerImp : public StateCacheAlloc
00042     {
00043     private:        
00045         vector<GLclampf>::type mClearColour;
00047         vector<GLboolean>::type mColourMask;
00049         GLboolean mDepthMask;
00051         GLenum mPolygonMode;
00053         GLenum mBlendEquation;
00055         GLenum mBlendFuncSource;
00057         GLenum mBlendFuncDest;
00059         GLenum mCullFace;
00061         GLenum mDepthFunc;
00063         GLuint mStencilMask;
00065         size_t mActiveTextureUnit;
00067         unsigned int mDiscardBuffers;
00069         GLclampf mClearDepth;
00071         int mViewport[4];
00072 
00073         GLenum mBlendEquationRGB;
00074         GLenum mBlendEquationAlpha;
00075         GLenum mShadeModel;
00076 
00077         GLfloat mAmbient[4];
00078         GLfloat mDiffuse[4];
00079         GLfloat mSpecular[4];
00080         GLfloat mEmissive[4];
00081         GLfloat mLightAmbient[4];
00082         GLfloat mShininess;
00083 
00084         GLfloat mPointSize;
00085         GLfloat mPointSizeMin;
00086         GLfloat mPointSizeMax;
00087         GLfloat mPointAttenuation[3];
00088 
00089     public:
00090         GLStateCacheManagerImp(void);
00091         ~GLStateCacheManagerImp(void);
00092         
00094         void initializeCache();
00095         
00097         void clearCache();
00098         
00100         void bindGLBuffer(GLenum target, GLuint buffer, bool force = false);
00101         
00103         void deleteGLBuffer(GLenum target, GLuint buffer, bool force = false);
00104         
00106         void bindGLTexture(GLenum target, GLuint texture);
00107         
00109         void setTexParameteri(GLenum target, GLenum pname, GLint param);
00110 
00112         void invalidateStateForTexture(GLuint texture);
00113 
00115         bool activateGLTextureUnit(size_t unit);
00116         
00118         GLenum getBlendEquation(void) const { return mBlendEquation; }
00119         
00121         void setBlendEquation(GLenum eq);
00122 
00124         void setBlendEquation(GLenum eqRGB, GLenum eqA);
00125 
00127         void setBlendFunc(GLenum source, GLenum dest);
00128 
00130         void setShadeModel(GLenum model);
00131 
00133         void setLightAmbient(GLfloat r, GLfloat g, GLfloat b);
00134 
00136         GLboolean getDepthMask(void) const { return mDepthMask; }
00137         
00139         void setDepthMask(GLboolean mask);
00140         
00142         GLenum getDepthFunc(void) const { return mDepthFunc; }
00143         
00145         void setDepthFunc(GLenum func);
00146         
00148         GLclampf getClearDepth(void) const { return mClearDepth; }
00149         
00151         void setClearDepth(GLclampf depth);
00152         
00154         void setClearColour(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
00155         
00157         vector<GLboolean>::type & getColourMask(void) { return mColourMask; }
00158         
00160         void setColourMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
00161         
00163         GLuint getStencilMask(void) const { return mStencilMask; }
00164         
00166         void setStencilMask(GLuint mask);
00167         
00169         void setEnabled(GLenum flag);
00170         
00172         void setDisabled(GLenum flag);
00173         
00175         unsigned int getDiscardBuffers(void) const { return mDiscardBuffers; }
00176         
00178         void setDiscardBuffers(unsigned int flags) { mDiscardBuffers = flags; }
00179         
00181         GLenum getPolygonMode(void) const { return mPolygonMode; }
00182         
00184         void setPolygonMode(GLenum mode);
00185         
00187         GLenum getCullFace(void) const { return mCullFace; }
00188         
00190         void setCullFace(GLenum face);
00191 
00193         void enableTextureCoordGen(GLenum type);
00195         void disableTextureCoordGen(GLenum type);
00196 
00197         // Set material lighting parameters
00198         void setMaterialAmbient(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
00199         void setMaterialDiffuse(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
00200         void setMaterialEmissive(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
00201         void setMaterialSpecular(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
00202         void setMaterialShininess(GLfloat shininess);
00203         void setPointSize(GLfloat size);
00204         void setPointParameters(GLfloat* attenuation, float minSize, float maxSize);
00205 
00207         void setViewport(GLint x, GLint y, GLsizei width, GLsizei height);
00208 
00210         void getViewport(int* array);
00211     };
00212 }
00213 
00214 #endif

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 Mon Jul 27 2020 13:40:42