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

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