]> git.tdb.fi Git - libs/gl.git/blob - source/material.h
Support for loading materials from datafiles
[libs/gl.git] / source / material.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_MATERIAL_H_
9 #define MSP_GL_MATERIAL_H_
10
11 #include <msp/datafile/loader.h>
12 #include "color.h"
13
14 namespace Msp {
15 namespace GL {
16
17 /**
18 Stores OpenGL material properties.  Since OpenGL does not support material
19 objects, application of material is done with several calls to glMaterial.
20 */
21 class Material
22 {
23 public:
24         class Loader: public DataFile::Loader
25         {
26         private:
27                 Material &mat;
28
29         public:
30                 Loader(Material &);
31                 Material &get_object() const { return mat; }
32         
33         private:
34                 void ambient(float, float, float, float);
35                 void diffuse(float, float, float, float);
36                 void specular(float, float, float, float);
37                 void emission(float, float, float, float);
38         };
39
40 private:
41         Color ambient;
42         Color diffuse;
43         Color specular;
44         Color emission;
45         float shininess;
46
47 public:
48         Material();
49         void set_ambient(const Color &a);
50         void set_diffuse(const Color &d);
51         void set_specular(const Color &s);
52         void set_emission(const Color &e);
53         void set_shininess(float s);
54         void apply() const;
55 };
56
57 } // namespace GL
58 } // namespace Msp
59
60 #endif