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

Revision 3034, 2.4 KB checked in by mattausch, 16 years ago (diff)
Line 
1#ifndef __MATERIAL_H
2#define __MATERIAL_H
3
4#include "glInterface.h"
5#include "common.h"
6
7
8namespace CHCDemoEngine
9{
10
11class Texture;
12class RenderState;
13class GPUProgramParameters;
14class ShaderProgram;
15
16
17class RgbaColor
18{
19
20public:
21
22        float r, g, b, a;
23
24        RgbaColor(): r(1), g(1), b(1), a(1)
25        {}
26
27        RgbaColor(float _r, float _g, float _b, float _a): r(_r), g(_g), b(_b), a(_a)
28        {}
29
30        friend RgbaColor RandomColor(float a = 0.0f, float b = 1.0f);
31};
32
33
34// Forward declarations
35RgbaColor RandomColor(float a, float b);
36
37
38
39class Material
40{
41friend class ResourceManager;
42
43public:
44
45        /** Sets default material (ambient intensity 0.2f, diffuse intensity 1.0f)
46        */
47        Material();
48
49        ~Material();
50        /** Sets ambient and diffuse color to color
51        */
52        Material(const RgbaColor &color);
53
54        friend Material RandomMaterial();
55
56        inline Texture *GetTexture() const { return mTexture; }
57
58        inline RgbaColor GetAmbient() const { return mAmbientColor; }
59        inline RgbaColor GetDiffuse() const { return mDiffuseColor; }
60        inline RgbaColor GetSpecular() const { return mSpecularColor; }
61        inline RgbaColor GetEmmisive() const { return mEmmisiveColor; }
62
63        inline void SetTexture(Texture *texture) { mTexture = texture; }
64
65        inline void SetAmbient(const RgbaColor &color) { mAmbientColor = color; }
66        inline void SetDiffuse(const RgbaColor &color) { mDiffuseColor = color; }
67        inline void SetSpecular(const RgbaColor &color) { mSpecularColor = color; }
68        inline void SetEmmisive(const RgbaColor &color) { mEmmisiveColor = color; }
69       
70        inline void SetAlphaTestEnabled(bool alpha) { mAlphaTestEnabled = alpha; }
71        inline void SetCullFaceEnabled(bool cull) { mCullFaceEnabled = cull; }
72
73        inline bool IsAlphaTestEnabled() const { return mAlphaTestEnabled; }
74        inline bool IsCullFaceEnabled() const { return mCullFaceEnabled; }
75        /** Renders this material.
76        */
77        void Render(RenderState *state);
78        /** Initialize the material with default values
79        */
80        void InitMaterial();
81
82        GPUProgramParameters *mGPUVertexParameters;
83        GPUProgramParameters *mGPUFragmentParameters;
84
85        ShaderProgram *mFragmentProgram;
86        ShaderProgram *mVertexProgram;
87
88protected:
89
90        ///////////
91
92        RgbaColor mDiffuseColor;
93        RgbaColor mSpecularColor;
94        RgbaColor mAmbientColor;
95        RgbaColor mEmmisiveColor;
96
97        bool mAlphaTestEnabled;
98        bool mCullFaceEnabled;
99        /// the associated texture
100        Texture *mTexture;
101};
102
103
104extern Material RandomMaterial();
105
106}
107
108#endif
Note: See TracBrowser for help on using the repository browser.