zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Material.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
34 #ifndef ZENI_MATERIAL_H
35 #define ZENI_MATERIAL_H
36 
37 #include <Zeni/Color.h>
38 #include <Zeni/String.h>
39 
40 #ifndef DISABLE_GL
41 #if defined(REQUIRE_GL_ES)
42 #include <GLES/gl.h>
43 #else
44 #include <GL/glew.h>
45 #endif
46 #endif
47 
48 #include <Zeni/Define.h>
49 
50 namespace Zeni {
51 
52  class ZENI_GRAPHICS_DLL Video_GL_Fixed;
53  class ZENI_GRAPHICS_DLL Video_GL_Shader;
54  class ZENI_GRAPHICS_DLL Video_DX9;
55 
56  class ZENI_GRAPHICS_DLL Material {
57  public:
60  const Color &diffuse = ZENI_DEFAULT_MATERIAL_DIFFUSE,
61  const Color &specular = ZENI_DEFAULT_MATERIAL_SPECULAR,
62  const Color &emissive = ZENI_DEFAULT_MATERIAL_EMISSIVE,
63  const float &power = ZENI_DEFAULT_MATERIAL_POWER,
64  const String &texture = "");
65  Material(const String &texture,
66  const Color &ambient_and_diffuse = ZENI_DEFAULT_MATERIAL_DIFFUSE);
67 
68  // Accessors
69  inline float get_power() const;
70  float get_shininess() const;
71  inline const String & get_Texture() const;
72 
73  // Modifiers
74  inline void set_power(const float &power);
75  void set_shininess(const float &shininess);
76  void set_Texture(const String &texture);
77 
78 #ifndef DISABLE_GL_FIXED
79  void set(Video_GL_Fixed &screen) const;
80  void unset(Video_GL_Fixed &screen) const;
81 #endif
82 
83 #ifndef DISABLE_GL_SHADER
84  void set(Video_GL_Shader &screen) const;
85  void unset(Video_GL_Shader &screen) const;
86 #endif
87 
88 #ifndef DISABLE_DX9
89  void set(Video_DX9 &screen) const;
90  void unset(Video_DX9 &screen) const;
91 #endif
92 
93  bool operator<(const Material &rhs) const;
94 
95  bool operator==(const Material &rhs) const;
96 
97  // Optimizers
98  void optimize_to_follow(const Material &rhs);
99  void optimize_to_precede(const Material &rhs);
100  void clear_optimization();
101 
106 
107  private:
108  float m_power;
109 
110  String m_texture;
111  mutable unsigned long m_texture_id;
112 
113  unsigned int m_optimization;
114  };
115 
116 }
117 
118 #include <Zeni/Undefine.h>
119 
120 #endif
The Direct3D9 Rendering System.
Definition: Video_DX9.h:62
#define ZENI_DEFAULT_MATERIAL_EMISSIVE
Definition: Define.h:46
Color specular
The specular Color.
Definition: Material.h:104
bool operator<(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:273
bool operator==(const SourceLocation &lhs, const SourceLocation &rhs)
#define ZENI_DEFAULT_MATERIAL_SPECULAR
Definition: Define.h:45
An Abstraction of a Material.
Definition: Material.h:56
#define ZENI_DEFAULT_MATERIAL_DIFFUSE
Definition: Define.h:44
The OpenGL Rendering System.
Color ambient
The ambient Color.
Definition: Material.h:103
The OpenGL Rendering System.
Color diffuse
The diffuse Color.
Definition: Material.h:102
Color emissive
The emissive Color.
Definition: Material.h:105
GLenum GLenum GLuint texture
Definition: gl2ext.h:850
#define ZENI_DEFAULT_MATERIAL_POWER
Definition: Define.h:47
Color.
Definition: Color.h:41