GL Studio API
material.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::Material class.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 
41 #ifndef _MATERIAL_H
42 #define _MATERIAL_H
43 
44 #include "gls_color.h"
45 #include "unhide_globals.h"
46 #include "gls_gl.h"
47 #include <string>
48 #include <iosfwd> //Forward references for the stream operators
49 #include "display_types.h"
50 
51 namespace disti
52 {
53 
54 /** The Material class
55  */
56 class Material
57 {
58 public:
59  static glsColor _ambientDefault; /** The ambient value for the default material */
60  static glsColor _diffuseDefault; /** The diffuse value for the default material */
61  static glsColor _specularDefault; /** The specular value for the default material */
62  static glsColor _emissionDefault; /** The emission value for the default material */
63  static float _shininessDefault; /** The shininess value for the default material */
64 
65  glsColor _ambient; /** Ambient component of the material */
66  glsColor _diffuse; /** Diffuse component of the material */
67  glsColor _specular; /** Specular component of the material */
68  glsColor _emission; /** Emission component of the material */
69  float _shininess; /** Shininess component of the material */
70  bool _inUse; /** True if the material is in use */
71  std::string _name; /** String name of the material */
72  ColorMaterialMode_e _colorMaterialMode; /* Color mode to use for this material */
73 
74  GLS_EXPORT Material();
75  GLS_EXPORT Material(
76  const glsColor& ambient,
77  const glsColor& diffuse,
78  const glsColor& specular,
79  const glsColor& emission,
80  const float& shininess);
81 
82  /** Materials are equivalent if all of their parameters are the same */
83  inline static bool MaterialsAreEquivalent(const Material& m1, const Material& m2)
84  {
85  return
86  m1._name == m2._name &&
87  m1._ambient == m2._ambient &&
88  m1._specular == m2._specular &&
89  m1._diffuse == m2._diffuse &&
90  m1._emission == m2._emission &&
91  m1._shininess == m2._shininess;
92  }
93 
94  /** Applies the ambient component of this material to the OpenGL pipeline
95  * \param face Which faces to apply this to (front, back or front and back faces)
96  */
97  GLS_EXPORT void ApplyAmbient (GLenum face = GL_FRONT_AND_BACK);
98 
99  /** Applies the diffuse component of this material to the OpenGL pipeline
100  * \param face Which faces to apply this to (front, back or front and back faces)
101  */
102  GLS_EXPORT void ApplyDiffuse (GLenum face = GL_FRONT_AND_BACK);
103 
104  /** Applies the specular component of this material to the OpenGL pipeline
105  * \param face Which faces to apply this to (front, back or front and back faces)
106  */
107  GLS_EXPORT void ApplySpecular (GLenum face = GL_FRONT_AND_BACK);
108 
109  /** Applies the emission component of this material to the OpenGL pipeline
110  * \param face Which faces to apply this to (front, back or front and back faces)
111  */
112  GLS_EXPORT void ApplyEmission (GLenum face = GL_FRONT_AND_BACK);
113 
114  /** Applies the shininess component of this material to the OpenGL pipeline
115  * \param face Which faces to apply this to (front, back or front and back faces)
116  */
117  GLS_EXPORT void ApplyShininess(GLenum face = GL_FRONT_AND_BACK);\
118 
119  /** Applies all of the components of this material to the OpenGL pipeline
120  * \param face Which faces to apply this to (front, back or front and back faces)
121  */
122  GLS_EXPORT void ApplyAll(GLenum face = GL_FRONT_AND_BACK);
123 
124  /** \return True if this material is in use */
125  GLS_EXPORT bool InUse(void);
126 
127  /** Sets whether this material is in use
128  * \param val Whether this material is in use
129  */
130  GLS_EXPORT void InUse(bool val);
131 
132  /** \return The material name */
133  GLS_EXPORT std::string& Name(void);
134 
135  /** Sets the material name
136  * \param name The material name
137  */
138  GLS_EXPORT void Name(const std::string& name);
139 };
140 
141 GLS_EXPORT bool operator==(const Material & rhs, const Material& lhs );
142 GLS_EXPORT bool operator!=(const Material & rhs, const Material& lhs );
143 
144 /** Stream operator to write a material to a stream */
145 GLS_EXPORT std::ostream & operator<<(std::ostream & outstr, const Material & mat);
146 
147 /** Stream operator to read a material from a stream */
148 GLS_EXPORT std::istream & operator>>(std::istream & instr, Material & mat);
149 
150 } // namespace disti
151 
152 #endif
The DistiUnhideGlobalsDummyClass class.
std::string _name
Definition: material.h:71
void ApplyShininess(GLenum face=GL_FRONT_AND_BACK)
void ApplyEmission(GLenum face=GL_FRONT_AND_BACK)
static glsColor _emissionDefault
Definition: material.h:62
static glsColor _diffuseDefault
Definition: material.h:60
glsColor _specular
Definition: material.h:67
bool InUse(void)
bool _inUse
Definition: material.h:70
void ApplySpecular(GLenum face=GL_FRONT_AND_BACK)
void ApplyAmbient(GLenum face=GL_FRONT_AND_BACK)
static bool MaterialsAreEquivalent(const Material &m1, const Material &m2)
Definition: material.h:83
The Color class: Implements a 4 component RGBA color.
static float _shininessDefault
Definition: material.h:63
GL Studio Enumerations and constants.
void ApplyAll(GLenum face=GL_FRONT_AND_BACK)
ColorMaterialMode_e
Definition: display_types.h:147
Definition: material.h:56
glsColor _ambient
Definition: material.h:65
void ApplyDiffuse(GLenum face=GL_FRONT_AND_BACK)
Definition: gls_color.h:54
glsColor _diffuse
Definition: material.h:66
std::string & Name(void)
float _shininess
Definition: material.h:69
static glsColor _specularDefault
Definition: material.h:61
Definition: bmpimage.h:46
ColorMaterialMode_e _colorMaterialMode
Definition: material.h:72
glsColor _emission
Definition: material.h:68
The gls_gl.