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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State 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
51namespace disti
52{
53/** The Material class
54 */
56{
57public:
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
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.
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.
148GLS_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.
154GLS_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.
160GLS_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.
166GLS_EXPORT std::istream& operator>>( std::istream& instr, Material& mat );
167
168} // namespace disti
169
170#endif
Definition: gls_color.h:54
Definition: material.h:56
GlsColor _ambient
Ambient component of the material.
Definition: material.h:64
GlsColor _emission
Emission component of the material.
Definition: material.h:67
void ApplyShininess(GLenum face=GL_FRONT_AND_BACK)
ColorMaterialMode_e _colorMaterialMode
Color mode to use for this material.
Definition: material.h:71
static GlsColor _emissionDefault
The emission value for the default material.
Definition: material.h:61
void InUse(bool val)
static float _shininessDefault
The shininess value for the default material.
Definition: material.h:62
static GlsColor _ambientDefault
The ambient value for the default material.
Definition: material.h:58
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:60
const std::string & Name() const
GlsColor _specular
Specular component of the material.
Definition: material.h:66
void ApplyAmbient(GLenum face=GL_FRONT_AND_BACK)
bool _inUse
True if the material is in use.
Definition: material.h:69
void ApplySpecular(GLenum face=GL_FRONT_AND_BACK)
GlsColor _diffuse
Diffuse component of the material.
Definition: material.h:65
static GlsColor _diffuseDefault
The diffuse value for the default material.
Definition: material.h:59
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:70
float _shininess
Shininess component of the material.
Definition: material.h:68
static bool MaterialsAreEquivalent(const Material &m1, const Material &m2)
Definition: material.h:92
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:52
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
ColorMaterialMode_e
Definition: display_types.h:141
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.