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

Revision 2822, 2.1 KB checked in by mattausch, 16 years ago (diff)

worked on deferred shading

Line 
1#ifndef __MATERIAL_H
2#define __MATERIAL_H
3
4#include "glInterface.h"
5#include <Cg/cg.h>
6#include <Cg/cgGL.h>
7#include "common.h"
8
9
10namespace CHCDemoEngine
11{
12
13class Texture;
14class RenderState;
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        Material();
46
47        Material(const RgbaColor &color);
48
49        friend Material RandomMaterial();
50
51        inline Texture *GetTexture() const { return mTexture; }
52
53        inline RgbaColor GetAmbient() const { return mAmbientColor; }
54        inline RgbaColor GetDiffuse() const { return mDiffuseColor; }
55        inline RgbaColor GetSpecular() const { return mSpecularColor; }
56        inline RgbaColor GetEmmisive() const { return mEmmisiveColor; }
57
58        inline void SetTexture(Texture *texture) { mTexture = texture; }
59
60        inline void SetAmbient(const RgbaColor &color) { mAmbientColor = color; }
61        inline void SetDiffuse(const RgbaColor &color) { mDiffuseColor = color; }
62        inline void SetSpecular(const RgbaColor &color) { mSpecularColor = color; }
63        inline void SetEmmisive(const RgbaColor &color) { mEmmisiveColor = color; }
64       
65        inline void SetAlphaTestEnabled(bool alpha) { mAlphaTestEnabled = alpha; }
66        inline bool IsAlphaTestEnabled() const { return mAlphaTestEnabled; }
67        /** Renders this material.
68        */
69        void Render(RenderState *state);
70        /** Initialize the material with default values
71        */
72        void InitMaterial();
73
74        static CGparameter sDiffuseParam;
75        static CGparameter sDiffuseTexParam;
76
77        static CGparameter sAmbientParam;
78        static CGparameter sAmbientTexParam;
79
80protected:
81
82        ///////////
83
84        RgbaColor mDiffuseColor;
85        RgbaColor mSpecularColor;
86        RgbaColor mAmbientColor;
87        RgbaColor mEmmisiveColor;
88
89        bool mAlphaTestEnabled;
90        /// the assciated texture
91        Texture *mTexture;
92};
93
94
95extern Material RandomMaterial();
96
97}
98
99#endif
Note: See TracBrowser for help on using the repository browser.