Rev | Line | |
---|
[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 |
|
---|
[2825] | 26 | enum RenderType
|
---|
| 27 | {
|
---|
| 28 | FIXED,
|
---|
| 29 | DEPTH_PASS,
|
---|
| 30 | DEFERRED
|
---|
| 31 | };
|
---|
| 32 |
|
---|
[2769] | 33 | /** Constructor setting render as default state.
|
---|
| 34 | */
|
---|
| 35 | RenderState();
|
---|
| 36 |
|
---|
| 37 | ~RenderState() { Reset(); };
|
---|
| 38 |
|
---|
| 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; }
|
---|
[2769] | 59 |
|
---|
[2825] | 60 | void SetRenderType(RenderType type) { mRenderType = type; }
|
---|
[2854] | 61 | RenderType GetRenderType() const { return mRenderType; }
|
---|
[2800] | 62 |
|
---|
[2825] | 63 |
|
---|
| 64 | ///////////////////
|
---|
| 65 |
|
---|
[2854] | 66 |
|
---|
| 67 | ///////////////////
|
---|
| 68 | //-- for deferred shading, we have to switch shaders on and off
|
---|
| 69 |
|
---|
[2818] | 70 | static CGprofile sCgFragmentProfile;
|
---|
| 71 | static CGprofile sCgVertexProfile;
|
---|
| 72 |
|
---|
[2819] | 73 | static CGprogram sCgMrtFragmentProgram;
|
---|
| 74 | static CGprogram sCgMrtFragmentTexProgram;
|
---|
[2818] | 75 |
|
---|
[2819] | 76 |
|
---|
[2769] | 77 | protected:
|
---|
| 78 |
|
---|
| 79 | bool mAlphaTestEnabled;
|
---|
[2844] | 80 | bool mCullFaceEnabled;
|
---|
[2769] | 81 | bool mTexturesEnabled;
|
---|
| 82 |
|
---|
| 83 | Mode mMode;
|
---|
[2773] | 84 |
|
---|
| 85 | int mCurrentVboId;
|
---|
[2801] | 86 |
|
---|
[2825] | 87 | RenderType mRenderType;
|
---|
[2769] | 88 | };
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | #endif // __RENDERSTATE_H |
---|
Note: See
TracBrowser
for help on using the repository browser.