#ifndef __RENDERSTATE_H #define __RENDERSTATE_H #include "common.h" #include "glInterface.h" #include #include namespace CHCDemoEngine { /** The current render state. */ class RenderState { public: enum Mode { QUERY, RENDER }; /// the used render type for this render pass enum RenderPassType { FIXED, DEPTH_PASS, DEFERRED }; /** Constructor setting render as default state. */ RenderState(); ~RenderState() { Reset(); }; /** 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 SetState(Mode mode); /** Sets the current render state. */ void SetState(bool texturing, bool alphaTest, bool cullFace); /** 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; } /** If alpha to coverage is instead of alpha testing */ void SetUseAlphaToCoverage(bool useAlphaToCoverage); /** Sets the type of rendering used (foreward, depth pass, deferred) */ void SetRenderPassType(RenderPassType t); /** See Set */ RenderPassType GetRenderPassType() const; /** If true, the current value of cull face enabled / disable will not be changed by the render state. */ void LockCullFaceEnabled(bool lockCull); /////////////////// //-- for deferred shading, we have to switch shaders on and off static CGprofile sCgFragmentProfile; static CGprofile sCgVertexProfile; static CGprogram sCgMrtFragmentProgram; static CGprogram sCgMrtFragmentTexProgram; static CGparameter sTexParam; protected: bool mAlphaTestEnabled; bool mCullFaceEnabled; bool mTexturesEnabled; Mode mMode; int mCurrentVboId; RenderPassType mRenderType; bool mUseAlphaToCoverage; bool mLockCullFaceEnabled; }; } #endif // __RENDERSTATE_H