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