GL Studio C++ Runtime API
material.h
Go to the documentation of this file.
1/// \file material.h
2/// \brief The disti::Material class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef INCLUDED_DISTI_MATERIAL_H
40#define INCLUDED_DISTI_MATERIAL_H
41
42#include "display_types.h"
43#include "gls_color.h"
44#include "gls_gl.h"
45#include "unhide_globals.h"
46#include <iosfwd> //Forward references for the stream operators
47#include <string>
48
49namespace disti
50{
51/** The Material class
52 */
54{
55public:
56 static GlsColor _ambientDefault; ///< The ambient value for the default material.
57 static GlsColor _diffuseDefault; ///< The diffuse value for the default material.
58 static GlsColor _specularDefault; ///< The specular value for the default material.
59 static GlsColor _emissionDefault; ///< The emission value for the default material.
60 static float _shininessDefault; ///< The shininess value for the default material.
61
62 GlsColor _ambient; ///< Ambient component of the material.
63 GlsColor _diffuse; ///< Diffuse component of the material.
64 GlsColor _specular; ///< Specular component of the material.
65 GlsColor _emission; ///< Emission component of the material.
66 float _shininess; ///< Shininess component of the material.
67 bool _inUse; ///< True if the material is in use.
68 std::string _name; ///< String name of the material.
69 ColorMaterialMode_e _colorMaterialMode; ///< Color mode to use for this material.
70
72
73 /// Constructor
74 /// \param ambient The ambient component of the material.
75 /// \param diffuse The diffuse component of the material.
76 /// \param specular The specular component of the material.
77 /// \param emission The emission component of the material.
78 /// \param shininess The shininess component of the material.
80 const GlsColor& ambient,
81 const GlsColor& diffuse,
82 const GlsColor& specular,
83 const GlsColor& emission,
84 const float& shininess );
85
86 /// Materials are equivalent if all of their parameters are the same.
87 /// \param m1 A material to compare.
88 /// \param m2 The other material to compare.
89 /// \return True if the materials are the same.
90 static bool MaterialsAreEquivalent( const Material& m1, const Material& m2 )
91 {
92 return m1._name == m2._name && m1._ambient == m2._ambient && m1._specular == m2._specular && m1._diffuse == m2._diffuse && m1._emission == m2._emission && m1._shininess == m2._shininess;
93 }
94
95 /** Applies the ambient component of this material to the OpenGL pipeline
96 * \param face Which faces to apply this to (front, back or front and back faces)
97 */
98 GLS_EXPORT void ApplyAmbient( GLenum face = GL_FRONT_AND_BACK );
99
100 /** Applies the diffuse component of this material to the OpenGL pipeline
101 * \param face Which faces to apply this to (front, back or front and back faces)
102 */
103 GLS_EXPORT void ApplyDiffuse( GLenum face = GL_FRONT_AND_BACK );
104
105 /** Applies the specular component of this material to the OpenGL pipeline
106 * \param face Which faces to apply this to (front, back or front and back faces)
107 */
108 GLS_EXPORT void ApplySpecular( GLenum face = GL_FRONT_AND_BACK );
109
110 /** Applies the emission component of this material to the OpenGL pipeline
111 * \param face Which faces to apply this to (front, back or front and back faces)
112 */
113 GLS_EXPORT void ApplyEmission( GLenum face = GL_FRONT_AND_BACK );
114
115 /** Applies the shininess component of this material to the OpenGL pipeline
116 * \param face Which faces to apply this to (front, back or front and back faces)
117 */
118 GLS_EXPORT void ApplyShininess( GLenum face = GL_FRONT_AND_BACK );
119
120 /** Applies all of the components of this material to the OpenGL pipeline
121 * \param face Which faces to apply this to (front, back or front and back faces)
122 */
123 GLS_EXPORT void ApplyAll( GLenum face = GL_FRONT_AND_BACK );
124
125 /** \return True if this material is in use */
126 GLS_EXPORT bool InUse() const;
127
128 /** Sets whether this material is in use
129 * \param val Whether this material is in use
130 */
131 GLS_EXPORT void InUse( bool val );
132
133 /** \return The material name */
134 GLS_EXPORT const std::string& Name() const;
135
136 /** Sets the material name
137 * \param name The material name
138 */
139 GLS_EXPORT void Name( const std::string& name );
140};
141
142/// Equality operator
143/// \param rhs An object to compare.
144/// \param lhs Another object to compare.
145/// \return Whether or not the objects are equal.
146GLS_EXPORT bool operator==( const Material& rhs, const Material& lhs );
147
148/// Inequality operator
149/// \param rhs An object to compare.
150/// \param lhs Another object to compare.
151/// \return Whether or not the objects are not equal.
152GLS_EXPORT bool operator!=( const Material& rhs, const Material& lhs );
153
154/// Stream out operator
155/// \param outstr The stream to write to.
156/// \param mat The value to write to the stream.
157/// \return The stream in its current state.
158GLS_EXPORT std::ostream& operator<<( std::ostream& outstr, const Material& mat );
159
160/// Stream in operator
161/// \param instr The stream to read from.
162/// \param mat The returned value read from the stream.
163/// \return The stream in its current state.
164GLS_EXPORT std::istream& operator>>( std::istream& instr, Material& mat );
165
166} // namespace disti
167
168#endif
Definition: gls_color.h:53
Definition: material.h:54
GlsColor _ambient
Ambient component of the material.
Definition: material.h:62
GlsColor _emission
Emission component of the material.
Definition: material.h:65
void ApplyShininess(GLenum face=GL_FRONT_AND_BACK)
ColorMaterialMode_e _colorMaterialMode
Color mode to use for this material.
Definition: material.h:69
static GlsColor _emissionDefault
The emission value for the default material.
Definition: material.h:59
void InUse(bool val)
static float _shininessDefault
The shininess value for the default material.
Definition: material.h:60
static GlsColor _ambientDefault
The ambient value for the default material.
Definition: material.h:56
bool InUse() const
void ApplyDiffuse(GLenum face=GL_FRONT_AND_BACK)
void ApplyAll(GLenum face=GL_FRONT_AND_BACK)
static GlsColor _specularDefault
The specular value for the default material.
Definition: material.h:58
const std::string & Name() const
GlsColor _specular
Specular component of the material.
Definition: material.h:64
void ApplyAmbient(GLenum face=GL_FRONT_AND_BACK)
bool _inUse
True if the material is in use.
Definition: material.h:67
void ApplySpecular(GLenum face=GL_FRONT_AND_BACK)
GlsColor _diffuse
Diffuse component of the material.
Definition: material.h:63
static GlsColor _diffuseDefault
The diffuse value for the default material.
Definition: material.h:57
Material(const GlsColor &ambient, const GlsColor &diffuse, const GlsColor &specular, const GlsColor &emission, const float &shininess)
std::string _name
String name of the material.
Definition: material.h:68
float _shininess
Shininess component of the material.
Definition: material.h:66
static bool MaterialsAreEquivalent(const Material &m1, const Material &m2)
Definition: material.h:90
void ApplyEmission(GLenum face=GL_FRONT_AND_BACK)
void Name(const std::string &name)
GL Studio Enumerations and constants.
The Color class: Implements a 4 component RGBA color.
The gls_gl.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
Definition: bmpimage.h:46
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
ColorMaterialMode_e
Definition: display_types.h:140
bool operator!=(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:165
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:154
std::istream & operator>>(std::istream &instr, GlsColor &color)
The DistiUnhideGlobalsDummyClass class.