#ifndef __RENDERSTATE_H #define __RENDERSTATE_H #include "common.h" namespace CHCDemoEngine { class ShaderProgram; class Texture; class Material; /** Class representing the current render state. */ class RenderState { public: enum Mode { QUERY, RENDER }; /** Constructor setting render as default state. */ RenderState(); /** This must be called each time before and after an occlusion test. Mode is one of render mode or query mode. Returns true if a state change was issued. */ bool SetMode(Mode mode); /** Sets the current render state with the current technique + scene entity */ void SetState(Technique *tech, SceneEntity *ent = NULL); /** Returns the current render state. */ Technique *GetState() { return mCurrentTechnique; } /** Returns either query or render mode */ inline Mode GetMode() const { return mMode; } /** Reset the state. */ void Reset(); /** Stores the current vbo id. */ inline void SetCurrentVboId(int id) { mCurrentVboId = id; } /** Returns the current vbo id. */ inline int GetCurrentVboId() const { return mCurrentVboId; } /** Sets the index of the render technique that is used to render a material. Initially we use foreward = 0, deferred = 1, depth pass = 1 */ void SetRenderTechnique(int t); /** See Set */ int GetRenderTechnique() const; /** If alpha to coverage is instead of alpha testing */ void SetUseAlphaToCoverage(bool useAlphaToCoverage); /** If true, the current value of cull face enabled / disable will not be changed by the render state. */ void LockCullFaceEnabled(bool lockCull); protected: ////////////////// bool mAlphaTestEnabled; bool mCullFaceEnabled; bool mTexturesEnabled; /// Render or query mode Mode mMode; int mCurrentVboId; /// the current render technique int mRenderTechnique; bool mUseAlphaToCoverage; bool mLockCullFaceEnabled; int mCurrentTexId; ShaderProgram *mCurrentVertexProgram; ShaderProgram *mCurrentFragmentProgram; bool mFragmentProgramEnabled; bool mVertexProgramEnabled; bool mLightingEnabled; bool mColorWriteEnabled; Technique *mCurrentTechnique; bool mDepthWriteEnabled; }; } #endif // __RENDERSTATE_H