[2769] | 1 | #ifndef __RENDERSTATE_H
|
---|
| 2 | #define __RENDERSTATE_H
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | #include "common.h"
|
---|
[2818] | 6 | #include "glInterface.h"
|
---|
| 7 | #include <Cg/cg.h>
|
---|
| 8 | #include <Cg/cgGL.h>
|
---|
[2769] | 9 |
|
---|
| 10 |
|
---|
[2776] | 11 | namespace CHCDemoEngine
|
---|
[2769] | 12 | {
|
---|
| 13 |
|
---|
| 14 | /** The current render state.
|
---|
| 15 | */
|
---|
| 16 | class RenderState
|
---|
| 17 | {
|
---|
| 18 | public:
|
---|
| 19 |
|
---|
| 20 | enum Mode
|
---|
| 21 | {
|
---|
| 22 | QUERY,
|
---|
| 23 | RENDER
|
---|
| 24 | };
|
---|
| 25 |
|
---|
[2955] | 26 | /// the used render type for this render pass
|
---|
| 27 | enum RenderPassType
|
---|
[2825] | 28 | {
|
---|
| 29 | FIXED,
|
---|
| 30 | DEPTH_PASS,
|
---|
[2955] | 31 | DEFERRED
|
---|
[2825] | 32 | };
|
---|
| 33 |
|
---|
[2769] | 34 | /** Constructor setting render as default state.
|
---|
| 35 | */
|
---|
| 36 | RenderState();
|
---|
| 37 |
|
---|
| 38 | ~RenderState() { Reset(); };
|
---|
| 39 | /** This must be called each time before and after an occlusion test.
|
---|
| 40 | Mode is one of render mode or query mode. Returns true if a state
|
---|
| 41 | change was issued.
|
---|
| 42 | */
|
---|
| 43 | bool SetState(Mode mode);
|
---|
| 44 | /** Sets the current render state.
|
---|
| 45 | */
|
---|
[2844] | 46 | void SetState(bool texturing, bool alphaTest, bool cullFace);
|
---|
[2854] | 47 | /** Returns either query or render mode
|
---|
[2769] | 48 | */
|
---|
| 49 | inline Mode GetMode() const { return mMode; }
|
---|
| 50 | /** Reset the state.
|
---|
| 51 | */
|
---|
| 52 | void Reset();
|
---|
[2773] | 53 | /** Stores the current vbo id.
|
---|
| 54 | */
|
---|
| 55 | inline void SetCurrentVboId(int id) { mCurrentVboId = id; }
|
---|
| 56 | /** Returns the current vbo id.
|
---|
| 57 | */
|
---|
[2854] | 58 | inline int GetCurrentVboId() const { return mCurrentVboId; }
|
---|
[2943] | 59 | /** If alpha to coverage is instead of alpha testing
|
---|
| 60 | */
|
---|
| 61 | void SetUseAlphaToCoverage(bool useAlphaToCoverage);
|
---|
[2955] | 62 | /** Sets the type of rendering used (foreward, depth pass, deferred)
|
---|
| 63 | */
|
---|
| 64 | void SetRenderPassType(RenderPassType t);
|
---|
| 65 | /** See Set
|
---|
| 66 | */
|
---|
| 67 | RenderPassType GetRenderPassType() const;
|
---|
| 68 | /** If true, the current value of cull face enabled / disable will
|
---|
| 69 | not be changed by the render state.
|
---|
| 70 | */
|
---|
| 71 | void LockCullFaceEnabled(bool lockCull);
|
---|
[2769] | 72 |
|
---|
[2800] | 73 |
|
---|
[2825] | 74 | ///////////////////
|
---|
[2854] | 75 | //-- for deferred shading, we have to switch shaders on and off
|
---|
| 76 |
|
---|
[2818] | 77 | static CGprofile sCgFragmentProfile;
|
---|
| 78 | static CGprofile sCgVertexProfile;
|
---|
| 79 |
|
---|
[2819] | 80 | static CGprogram sCgMrtFragmentProgram;
|
---|
| 81 | static CGprogram sCgMrtFragmentTexProgram;
|
---|
[2818] | 82 |
|
---|
[2819] | 83 |
|
---|
[2769] | 84 | protected:
|
---|
| 85 |
|
---|
| 86 | bool mAlphaTestEnabled;
|
---|
[2844] | 87 | bool mCullFaceEnabled;
|
---|
[2769] | 88 | bool mTexturesEnabled;
|
---|
| 89 |
|
---|
| 90 | Mode mMode;
|
---|
[2773] | 91 |
|
---|
| 92 | int mCurrentVboId;
|
---|
[2801] | 93 |
|
---|
[2955] | 94 | RenderPassType mRenderType;
|
---|
[2943] | 95 |
|
---|
| 96 | bool mUseAlphaToCoverage;
|
---|
[2955] | 97 |
|
---|
| 98 | bool mLockCullFaceEnabled;
|
---|
[2769] | 99 | };
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | #endif // __RENDERSTATE_H |
---|