source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h @ 3034

Revision 3034, 2.3 KB checked in by mattausch, 16 years ago (diff)
Line 
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
11namespace CHCDemoEngine
12{
13
14class ShaderProgram;
15class Texture;
16class Material;
17
18/** The current render state.
19*/
20class RenderState
21{
22public:
23
24        enum Mode
25        {
26                QUERY,
27                RENDER
28        };
29
30        /// the used render type for this render pass
31        enum RenderPassType
32        {
33                FIXED,
34                DEPTH_PASS,
35                DEFERRED
36        };
37
38        /** Constructor setting render as default state.
39        */
40        RenderState();
41       
42        ~RenderState() { Reset(); };
43        /** This must be called each time before and after an occlusion test.
44                Mode is one of render mode or query mode. Returns true if a state
45                change was issued.
46        */
47        bool SetMode(Mode mode);
48        /** Sets the current render state.
49        */
50        void SetState(Material *mat);
51        /** Returns either query or render mode
52        */
53        inline Mode GetMode() const { return mMode; }
54        /** Reset the state.
55        */
56        void Reset();
57        /** Stores the current vbo id.
58        */
59        inline void SetCurrentVboId(int id) { mCurrentVboId = id; }
60        /** Returns the current vbo id.
61        */
62        inline int GetCurrentVboId() const { return mCurrentVboId; }
63        /** Sets the type of rendering used (foreward, depth pass, deferred)
64        */
65        void SetRenderPassType(RenderPassType t);
66        /** See Set
67        */
68        RenderPassType GetRenderPassType() const;
69        /** If alpha to coverage is instead of alpha testing
70        */
71        void SetUseAlphaToCoverage(bool useAlphaToCoverage);
72        /** If true, the current value of cull face enabled / disable will
73                not be changed by the render state.
74        */
75        void LockCullFaceEnabled(bool lockCull);
76       
77       
78        ///////////////////
79        //-- for deferred shading, we have to switch shaders on and off
80
81        static CGprofile sCgFragmentProfile;
82        static CGprofile sCgVertexProfile;
83
84        static ShaderProgram *sCgMrtFragmentProgram;
85        static ShaderProgram *sCgMrtFragmentTexProgram;
86        static ShaderProgram *sCgMrtVertexProgram;
87
88        static int sTexParam;
89
90
91protected:
92
93        //////////////////
94
95        bool mAlphaTestEnabled;
96        bool mCullFaceEnabled;
97        bool mTexturesEnabled;
98
99        Mode mMode;
100
101        int mCurrentVboId;
102
103        RenderPassType mRenderType;
104
105        bool mUseAlphaToCoverage;
106
107        bool mLockCullFaceEnabled;
108
109        int mCurrentTexId;
110
111        ShaderProgram *mCurrentVertexProgram;
112        ShaderProgram *mCurrentFragmentProgram;
113};
114
115
116}
117
118#endif // __RENDERSTATE_H
Note: See TracBrowser for help on using the repository browser.