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  GLS_EXPORT Material(
75  const GlsColor& ambient,
76  const GlsColor& diffuse,
77  const GlsColor& specular,
78  const GlsColor& emission,
79  const float& shininess );
80 
81  /** Materials are equivalent if all of their parameters are the same */
82  inline static bool MaterialsAreEquivalent( const Material& m1, const Material& m2 )
83  {
84  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;
85  }
86 
87  /** Applies the ambient component of this material to the OpenGL pipeline
88  * \param face Which faces to apply this to (front, back or front and back faces)
89  */
90  GLS_EXPORT void ApplyAmbient( GLenum face = GL_FRONT_AND_BACK );
91 
92  /** Applies the diffuse component of this material to the OpenGL pipeline
93  * \param face Which faces to apply this to (front, back or front and back faces)
94  */
95  GLS_EXPORT void ApplyDiffuse( GLenum face = GL_FRONT_AND_BACK );
96 
97  /** Applies the specular 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 ApplySpecular( GLenum face = GL_FRONT_AND_BACK );
101 
102  /** Applies the emission 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 ApplyEmission( GLenum face = GL_FRONT_AND_BACK );
106 
107  /** Applies the shininess 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 ApplyShininess( GLenum face = GL_FRONT_AND_BACK );
111 
112  /** Applies all of the components 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 ApplyAll( GLenum face = GL_FRONT_AND_BACK );
116 
117  /** \return True if this material is in use */
118  GLS_EXPORT bool InUse() const;
119 
120  /** Sets whether this material is in use
121  * \param val Whether this material is in use
122  */
123  GLS_EXPORT void InUse( bool val );
124 
125  /** \return The material name */
126  GLS_EXPORT const std::string& Name() const;
127 
128  /** Sets the material name
129  * \param name The material name
130  */
131  GLS_EXPORT void Name( const std::string& name );
132 };
133 
134 GLS_EXPORT bool operator==( const Material& rhs, const Material& lhs );
135 GLS_EXPORT bool operator!=( const Material& rhs, const Material& lhs );
136 
137 /** Stream operator to write a material to a stream */
138 GLS_EXPORT std::ostream& operator<<( std::ostream& outstr, const Material& mat );
139 
140 /** Stream operator to read a material from a stream */
141 GLS_EXPORT std::istream& operator>>( std::istream& instr, Material& mat );
142 
143 } // namespace disti
144 
145 #endif
The DistiUnhideGlobalsDummyClass class.
static GlsColor _diffuseDefault
Definition: material.h:59
GlsColor _emission
Definition: material.h:67
std::string _name
Definition: material.h:70
void ApplyShininess(GLenum face=GL_FRONT_AND_BACK)
void ApplyEmission(GLenum face=GL_FRONT_AND_BACK)
bool operator!=(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:152
bool _inUse
Definition: material.h:69
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:82
GlsColor _specular
Definition: material.h:66
The Color class: Implements a 4 component RGBA color.
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
Defines the stream out operator.
static GlsColor _specularDefault
Definition: material.h:60
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:144
static float _shininessDefault
Definition: material.h:62
GL Studio Enumerations and constants.
void ApplyAll(GLenum face=GL_FRONT_AND_BACK)
GlsColor _diffuse
Definition: material.h:65
ColorMaterialMode_e
Definition: display_types.h:141
Definition: gls_color.h:53
Definition: material.h:55
void ApplyDiffuse(GLenum face=GL_FRONT_AND_BACK)
bool InUse() const
const std::string & Name() const
float _shininess
Definition: material.h:68
Definition: bmpimage.h:46
GlsColor _ambient
Definition: material.h:64
ColorMaterialMode_e _colorMaterialMode
Definition: material.h:71
static GlsColor _emissionDefault
Definition: material.h:61
The gls_gl.