1 | #ifndef __RENDERSTATE_H
|
---|
2 | #define __RENDERSTATE_H
|
---|
3 |
|
---|
4 |
|
---|
5 | #include "common.h"
|
---|
6 | #include "glInterface.h"
|
---|
7 | #include <Cg/cg.h>
|
---|
8 | #include <Cg/cgGL.h>
|
---|
9 |
|
---|
10 |
|
---|
11 | namespace CHCDemoEngine
|
---|
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 |
|
---|
26 | /// the used render type for this render pass
|
---|
27 | enum RenderPassType
|
---|
28 | {
|
---|
29 | FIXED,
|
---|
30 | DEPTH_PASS,
|
---|
31 | DEFERRED
|
---|
32 | };
|
---|
33 |
|
---|
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 | */
|
---|
46 | void SetState(bool texturing, bool alphaTest, bool cullFace);
|
---|
47 | /** Returns either query or render mode
|
---|
48 | */
|
---|
49 | inline Mode GetMode() const { return mMode; }
|
---|
50 | /** Reset the state.
|
---|
51 | */
|
---|
52 | void Reset();
|
---|
53 | /** Stores the current vbo id.
|
---|
54 | */
|
---|
55 | inline void SetCurrentVboId(int id) { mCurrentVboId = id; }
|
---|
56 | /** Returns the current vbo id.
|
---|
57 | */
|
---|
58 | inline int GetCurrentVboId() const { return mCurrentVboId; }
|
---|
59 | /** If alpha to coverage is instead of alpha testing
|
---|
60 | */
|
---|
61 | void SetUseAlphaToCoverage(bool useAlphaToCoverage);
|
---|
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);
|
---|
72 |
|
---|
73 |
|
---|
74 | ///////////////////
|
---|
75 | //-- for deferred shading, we have to switch shaders on and off
|
---|
76 |
|
---|
77 | static CGprofile sCgFragmentProfile;
|
---|
78 | static CGprofile sCgVertexProfile;
|
---|
79 |
|
---|
80 | static CGprogram sCgMrtFragmentProgram;
|
---|
81 | static CGprogram sCgMrtFragmentTexProgram;
|
---|
82 |
|
---|
83 | static CGparameter sTexParam;
|
---|
84 |
|
---|
85 | protected:
|
---|
86 |
|
---|
87 | bool mAlphaTestEnabled;
|
---|
88 | bool mCullFaceEnabled;
|
---|
89 | bool mTexturesEnabled;
|
---|
90 |
|
---|
91 | Mode mMode;
|
---|
92 |
|
---|
93 | int mCurrentVboId;
|
---|
94 |
|
---|
95 | RenderPassType mRenderType;
|
---|
96 |
|
---|
97 | bool mUseAlphaToCoverage;
|
---|
98 |
|
---|
99 | bool mLockCullFaceEnabled;
|
---|
100 | };
|
---|
101 |
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | #endif // __RENDERSTATE_H |
---|