GL Studio C++ Runtime API
gls_state_manager_es20_interface.h
Go to the documentation of this file.
1/// \file gls_state_manager_es20_interface.h
2/// \brief IGlsStateManager, interface to a state manager that manages the GL Studio
3/// runtime library's use of the OpenGL context, minimizing unnecessary state changes.
4///
5/// \par Copyright Information
6///
7/// Copyright (c) 2017 by The DiSTI Corporation.<br>
8/// 12249 Science Drive; Suite 300<br>
9/// Orlando, Florida 32826<br>
10/// USA<br>
11/// <br>
12/// All rights reserved.<br>
13///
14/// This Software contains proprietary trade secrets of DiSTI and may not be
15/// reproduced, in whole or part, in any form, or by any means of electronic,
16/// mechanical, or otherwise, without the written permission of DiSTI. Said
17/// permission may be derived through the purchase of applicable DiSTI product
18/// licenses which detail the distribution rights of this content and any
19/// Derivative Works based on this or other copyrighted DiSTI Software.
20///
21/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
22/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
23/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
24/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
25/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
26/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
27///
28/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
29/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
30/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
31/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
32/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
33/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
34/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
35/// EXCEED FIVE DOLLARS (US$5.00).
36///
37/// The aforementioned terms and restrictions are governed by the laws of the
38/// State of Florida and the United States of America.
39
40#ifndef DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
41#define DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
42
44
45#include "gls_es20_effect.h"
47
48/// The maximum number of lights, matching the fixed function pipeline.
49#ifndef LESS_MAX_LIGHTS
50# define MAX_LIGHTS 8
51#else
52# define MAX_LIGHTS 6
53#endif
54
55/// Polygon stipple patterns assume a 32x32 pattern where each bit determines which fragments are masked out. Divide by 8 to pack the pattern to ubytes.
56#define POLYGON_STIPPLE_SIZE 128
57
58namespace disti
59{
60/** \interface IGlsStateManagerES20
61 * The interface to a state manager that manages the GL Studio
62 * runtime library's use of the OpenGL context, minimizing unnecessary state changes,
63 * and has support for managing shaders.
64 */
66{
67public:
68 /** Structure used to replicate the Fixed-Function lighting model */
70 {
71 GLfloat _ambient[ 4 ]; ///< Ambient color RGBA
72 GLfloat _diffuse[ 4 ]; ///< Diffuse color RGBA
73 GLfloat _specular[ 4 ]; ///< Specular color RGBA
74 GLfloat _position[ 4 ]; ///< Position XYZW
75
76 GLfloat _spotDirection[ 3 ]; ///< Spotlight direction XYZ vector
77
78 float _spotExponent; ///< Spotlight exponent
79 float _spotCutoff; ///< Spotlight cutoff in degrees
80
81 float _constantAttenuation; ///< Constant attenuation
82 float _linearAttenuation; ///< Linear attenuation
83 float _quadraticAttenuation; ///< Quadratic attenuation
84 };
85
86 /// \return A reference to the top of the modelview matrix stack.
88
89 /// \return A reference to the top of the projection matrix stack.
91
92 ////////////////////////////////////////////////////////////////
93 //
94 // The following methods manage the various OpenGL state calls
95 //
96 ////////////////////////////////////////////////////////////////
97
98 /// Enable or disable the tangent array vertex attribute.
99 /// \param val The new state flag to set.
100 GLS_EXPORT virtual void TangentArrayEnabled( bool val ) = 0;
101
102 /// Enable or disable the binormal array vertex attribute.
103 /// \param val The new state flag to set.
104 GLS_EXPORT virtual void BinormalArrayEnabled( bool val ) = 0;
105
106 /// Set the vertex attribute pointer (to underlying data) for the tangent array.
107 /// \param type Must be GL_FLOAT.
108 /// \param stride The stride in bytes between tangent elements in the vertex data.
109 /// \param pointer The vertex data.
110 GLS_EXPORT virtual void TangentPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
111
112 /// Set the vertex attribute pointer (to underlying data) for the binormal array.
113 /// \param type Must be GL_FLOAT.
114 /// \param stride The stride in bytes between binormal elements in the vertex data.
115 /// \param pointer The vertex data.
116 GLS_EXPORT virtual void BinormalPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
117
118 /// Set the alpha blend function separately for RGB and A channels.
119 /// \param srcColor Function to use for source color.
120 /// \param dstColor Function to use for destination color.
121 /// \param srcAlpha Function to use for source alpha.
122 /// \param dstAlpha Function to use for destination alpha.
123 GLS_EXPORT virtual void AlphaBlendFuncSeparate( GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha ) = 0;
124
125 /// Set the alpha blend function.
126 /// \param src Function to use for source color.
127 /// \param dst Function to use for destination color.
128 GLS_EXPORT virtual void AlphaBlendFunc( GLenum src, GLenum dst ) = 0;
129
130 /// Push the current alpha blend function on the stack.
131 GLS_EXPORT virtual void PushAlphaBlendFunc() = 0;
132
133 /// Pop the current alpha blend function off the stack.
134 GLS_EXPORT virtual void PopAlphaBlendFunc() = 0;
135
136 /// Activates or deactivates the polygon stipple feature.
137 /// \param val True to enable polygon stippling, false to disable it.
138 GLS_EXPORT virtual void PolygonStippleEnabled( bool val ) = 0;
139
140 /// When activated, polygons will render with the specified bit mask pattern.
141 /// \param pattern Each bit in the pattern determines which fragments in the shader will be masked out. 0 maps to masked out. 1 maps to opaque.
142 GLS_EXPORT virtual void SetPolygonStipple( const GLubyte pattern[ POLYGON_STIPPLE_SIZE ] ) = 0;
143
144 ////////////////////////////////////////////////////////////////
145 //
146 // The following methods manage the effects
147 //
148 ////////////////////////////////////////////////////////////////
149
150 /// \return The light source paramters for the given light index.
151 /// \param index The light index whose parameters are to be returned.
153
154 /** Enable the given custom shader program and push it to the top of the custom shader program stack
155 * \param effect custom shader program
156 * \param useProgramImmediately GL_TRUE if custom shader program should immediately be set as the active
157 * shader program else GL_FALSE to allow the state manager to set the program
158 * active when it is needed
159 * \pre number of custom shader programs is < CUSTOM_SHADER_PROGRAM_STACK_DEPTH
160 * \post the given custom shader program is at the top of the custom shader program stack and is enabled, it
161 * is set to the current active shader program if useProgramImmediately is GL_TRUE
162 */
163 GLS_EXPORT virtual void PushCustomShaderProgram( GlsEffect* effect, const GLboolean useProgramImmediately ) = 0;
164
165 /** Pop the custom shader program stack enabling the next custom shader program on the stack if there is one
166 * \pre number of custom shader programs is > 0
167 * \post the custom shader program stack is popped enabling the next custom shader program on the stack if there is one
168 */
170
171 /// \return True if there is at least one custom shader on the stack.
172 GLS_EXPORT virtual bool HasCustomShader() const = 0;
173
174 /** Select the appropriate shader program based on the current settings and update
175 * the current shader program if needed
176 * \param forceUpdate GL_TRUE to force uniforms to be updated as if shader program changed
177 * \pre none
178 * \post appropriate shader program based on the current settings is active
179 */
180 GLS_EXPORT virtual void UpdateShaderProgram( const GLboolean forceUpdate ) = 0;
181
182 /** Update the attributes for the current shader as needed
183 * \pre none
184 * \post Appropriate attributes for the current shader are updated
185 */
187
188 /** Update the uniforms for the current shader as needed
189 * \pre none
190 * \post Appropriate uniforms for the current shader are updated
191 */
193
194protected:
195 /** empty ctor */
197
198 /** empty dtor */
200};
201
202} // namespace disti
203
204#endif // DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
Definition: gls_es20_effect.h:56
Definition: gls_state_manager_es20_interface.h:66
virtual void PopCustomShaderProgram()=0
virtual void TangentArrayEnabled(bool val)=0
virtual void UpdateShaderUniforms()=0
virtual GlsMatrixType & GetTopModelViewMatrix()=0
virtual gl_LightSourceParameters & GetLightSourceParameters(unsigned int index)=0
virtual void PolygonStippleEnabled(bool val)=0
virtual void PushCustomShaderProgram(GlsEffect *effect, const GLboolean useProgramImmediately)=0
virtual void SetPolygonStipple(const GLubyte pattern[128])=0
virtual void TangentPointer(GLenum type, GLsizei stride, const GLvoid *pointer)=0
virtual GlsMatrixType & GetTopProjMatrix()=0
virtual void PushAlphaBlendFunc()=0
Push the current alpha blend function on the stack.
virtual void AlphaBlendFuncSeparate(GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha)=0
IGlsStateManagerES20()
Definition: gls_state_manager_es20_interface.h:196
virtual void BinormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)=0
~IGlsStateManagerES20()
Definition: gls_state_manager_es20_interface.h:199
virtual void BinormalArrayEnabled(bool val)=0
virtual bool HasCustomShader() const =0
virtual void AlphaBlendFunc(GLenum src, GLenum dst)=0
virtual void UpdateShaderProgram(const GLboolean forceUpdate)=0
virtual void PopAlphaBlendFunc()=0
Pop the current alpha blend function off the stack.
virtual void UpdateShaderAttributes()=0
Definition: gls_state_manager_interface.h:65
The disti::GlsEffect class. Holds information pertaining to shader programs and their uniform/attribu...
Strings and other standard enumerations used in effects.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
#define POLYGON_STIPPLE_SIZE
Polygon stipple patterns assume a 32x32 pattern where each bit determines which fragments are masked ...
Definition: gls_state_manager_es20_interface.h:56
IGlsStateManager, interface to a state manager that manages the GL Studio runtime library's use of th...
Definition: bmpimage.h:46
Definition: gls_state_manager_es20_interface.h:70
GLfloat _ambient[4]
Ambient color RGBA.
Definition: gls_state_manager_es20_interface.h:71
float _spotExponent
Spotlight exponent.
Definition: gls_state_manager_es20_interface.h:78
GLfloat _specular[4]
Specular color RGBA.
Definition: gls_state_manager_es20_interface.h:73
float _spotCutoff
Spotlight cutoff in degrees.
Definition: gls_state_manager_es20_interface.h:79
GLfloat _diffuse[4]
Diffuse color RGBA.
Definition: gls_state_manager_es20_interface.h:72
float _quadraticAttenuation
Quadratic attenuation.
Definition: gls_state_manager_es20_interface.h:83
GLfloat _position[4]
Position XYZW.
Definition: gls_state_manager_es20_interface.h:74
float _linearAttenuation
Linear attenuation.
Definition: gls_state_manager_es20_interface.h:82
GLfloat _spotDirection[3]
Spotlight direction XYZ vector.
Definition: gls_state_manager_es20_interface.h:76
float _constantAttenuation
Constant attenuation.
Definition: gls_state_manager_es20_interface.h:81