| GL Studio C++ Runtime API

gls_state_manager_es20_interface.h
Go to the documentation of this file.
1/*! \file
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 11301 Corporate Blvd; Suite 100<br>
9 Orlando, Florida 32817<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. Use, distribution,
39 duplication, or disclosure by the U. S. Government is subject to
40"Restricted Rights" as set forth in DFARS 252.227-7014(c)(1)(ii).
41
42*/
43
44#ifndef DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
45#define DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
46
47#include "gls_state_manager_interface.h"
48
49#include "gls_es20_effect.h"
50#include "gls_es20_effect_params.h"
51
52/// The maximum number of lights, matching the fixed function pipeline.
53#ifndef LESS_MAX_LIGHTS
54# define MAX_LIGHTS 8
55#else
56# define MAX_LIGHTS 6
57#endif
58
59 namespace disti
60{
61/** \interface IGlsStateManagerES20
62 * The interface to a state manager that manages the GL Studio
63 * runtime library's use of the OpenGL context, minimizing unnecessary state changes,
64 * and has support for managing shaders.
65 */
66 class IGlsStateManagerES20 : virtual public IGlsStateManager
67{
68 public:
69 /** Structure used to replicate the Fixed-Function lighting model */
70 struct gl_LightSourceParameters
71 {
72 GLfloat _ambient[ 4 ]; ///< Ambient color RGBA
73 GLfloat _diffuse[ 4 ]; ///< Diffuse color RGBA
74 GLfloat _specular[ 4 ]; ///< Specular color RGBA
75 GLfloat _position[ 4 ]; ///< Position XYZW
76
77 GLfloat _spotDirection[ 3 ]; ///< Spotlight direction XYZ vector
78
79 float _spotExponent; ///< Spotlight exponent
80 float _spotCutoff; ///< Spotlight cutoff in degrees
81
82 float _constantAttenuation; ///< Constant attenuation
83 float _linearAttenuation; ///< Linear attenuation
84 float _quadraticAttenuation; ///< Quadratic attenuation
85 };
86
87 /// \return A reference to the top of the modelview matrix stack.
88 GLS_EXPORT virtual GlsMatrixType& GetTopModelViewMatrix() = 0;
89
90 /// \return A reference to the top of the projection matrix stack.
91 GLS_EXPORT virtual GlsMatrixType& GetTopProjMatrix() = 0;
92
93 ////////////////////////////////////////////////////////////////
94 //
95 // The following methods manage the various OpenGL state calls
96 //
97 ////////////////////////////////////////////////////////////////
98
99 /// Enable or disable the tangent array vertex attribute.
100 /// \param val The new state flag to set.
101 GLS_EXPORT virtual void TangentArrayEnabled( bool val ) = 0;
102
103 /// Enable or disable the binormal array vertex attribute.
104 /// \param val The new state flag to set.
105 GLS_EXPORT virtual void BinormalArrayEnabled( bool val ) = 0;
106
107 /// Set the vertex attribute pointer (to underlying data) for the tangent array.
108 /// \param type Must be GL_FLOAT.
109 /// \param stride The stride in bytes between tangent elements in the vertex data.
110 /// \param pointer The vertex data.
111 GLS_EXPORT virtual void TangentPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
112
113 /// Set the vertex attribute pointer (to underlying data) for the binormal array.
114 /// \param type Must be GL_FLOAT.
115 /// \param stride The stride in bytes between binormal elements in the vertex data.
116 /// \param pointer The vertex data.
117 GLS_EXPORT virtual void BinormalPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
118
119 /// Set the alpha blend function separately for RGB and A channels.
120 /// \param srcColor Function to use for source color.
121 /// \param dstColor Function to use for destination color.
122 /// \param srcAlpha Function to use for source alpha.
123 /// \param dstAlpha Function to use for destination alpha.
124 GLS_EXPORT virtual void AlphaBlendFuncSeparate( GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha ) = 0;
125
126 /// Set the alpha blend function.
127 /// \param src Function to use for source color.
128 /// \param dst Function to use for destination color.
129 GLS_EXPORT virtual void AlphaBlendFunc( GLenum src, GLenum dst ) = 0;
130
131 /// Push the current alpha blend function on the stack.
132 GLS_EXPORT virtual void PushAlphaBlendFunc() = 0;
133
134 /// Pop the current alpha blend function off the stack.
135 GLS_EXPORT virtual void PopAlphaBlendFunc() = 0;
136
137 ////////////////////////////////////////////////////////////////
138 //
139 // The following methods manage the effects
140 //
141 ////////////////////////////////////////////////////////////////
142
143 /// \return The light source paramters for the given light index.
144 /// \param index The light index whose parameters are to be returned.
145 GLS_EXPORT virtual gl_LightSourceParameters& GetLightSourceParameters( unsigned int index ) = 0;
146
147 /** Enable the given custom shader program and push it to the top of the custom shader program stack
148 * \param effect custom shader program
149 * \param useProgramImmediately GL_TRUE if custom shader program should immediately be set as the active
150 * shader program else GL_FALSE to allow the state manager to set the program
151 * active when it is needed
152 * \pre number of custom shader programs is < CUSTOM_SHADER_PROGRAM_STACK_DEPTH
153 * \post the given custom shader program is at the top of the custom shader program stack and is enabled, it
154 * is set to the current active shader program if useProgramImmediately is GL_TRUE
155 */
156 GLS_EXPORT virtual void PushCustomShaderProgram( GlsEffect* effect, const GLboolean useProgramImmediately ) = 0;
157
158 /** Pop the custom shader program stack enabling the next custom shader program on the stack if there is one
159 * \pre number of custom shader programs is > 0
160 * \post the custom shader program stack is popped enabling the next custom shader program on the stack if there is one
161 */
162 GLS_EXPORT virtual void PopCustomShaderProgram() = 0;
163
164 /// \return True if there is at least one custom shader on the stack.
165 GLS_EXPORT virtual bool HasCustomShader() const = 0;
166
167 /** Select the appropriate shader program based on the current settings and update
168 * the current shader program if needed
169 * \param forceUpdate GL_TRUE to force uniforms to be updated as if shader program changed
170 * \pre none
171 * \post appropriate shader program based on the current settings is active
172 */
173 GLS_EXPORT virtual void UpdateShaderProgram( const GLboolean forceUpdate ) = 0;
174
175 /** Update the attributes for the current shader as needed
176 * \pre none
177 * \post Appropriate attributes for the current shader are updated
178 */
179 GLS_EXPORT virtual void UpdateShaderAttributes() = 0;
180
181 /** Update the uniforms for the current shader as needed
182 * \pre none
183 * \post Appropriate uniforms for the current shader are updated
184 */
185 GLS_EXPORT virtual void UpdateShaderUniforms() = 0;
186
187 protected:
188 /** empty ctor */
189 IGlsStateManagerES20() {}
190
191 /** empty dtor */
192 ~IGlsStateManagerES20() {}
193};
194
195} // namespace disti
196
197#endif // DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
disti::GlsEffect
Definition: gls_es20_effect.h:60
disti::GlsMatrixAffine< double >
disti::IGlsStateManagerES20
Definition: gls_state_manager_es20_interface.h:67
disti::IGlsStateManagerES20::PopCustomShaderProgram
virtual void PopCustomShaderProgram()=0
disti::IGlsStateManagerES20::TangentArrayEnabled
virtual void TangentArrayEnabled(bool val)=0
disti::IGlsStateManagerES20::UpdateShaderUniforms
virtual void UpdateShaderUniforms()=0
disti::IGlsStateManagerES20::GetTopModelViewMatrix
virtual GlsMatrixType & GetTopModelViewMatrix()=0
disti::IGlsStateManagerES20::GetLightSourceParameters
virtual gl_LightSourceParameters & GetLightSourceParameters(unsigned int index)=0
disti::IGlsStateManagerES20::PushCustomShaderProgram
virtual void PushCustomShaderProgram(GlsEffect *effect, const GLboolean useProgramImmediately)=0
disti::IGlsStateManagerES20::TangentPointer
virtual void TangentPointer(GLenum type, GLsizei stride, const GLvoid *pointer)=0
disti::IGlsStateManagerES20::GetTopProjMatrix
virtual GlsMatrixType & GetTopProjMatrix()=0
disti::IGlsStateManagerES20::PushAlphaBlendFunc
virtual void PushAlphaBlendFunc()=0
Push the current alpha blend function on the stack.
disti::IGlsStateManagerES20::AlphaBlendFuncSeparate
virtual void AlphaBlendFuncSeparate(GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha)=0
disti::IGlsStateManagerES20::IGlsStateManagerES20
IGlsStateManagerES20()
Definition: gls_state_manager_es20_interface.h:189
disti::IGlsStateManagerES20::BinormalPointer
virtual void BinormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)=0
disti::IGlsStateManagerES20::~IGlsStateManagerES20
~IGlsStateManagerES20()
Definition: gls_state_manager_es20_interface.h:192
disti::IGlsStateManagerES20::BinormalArrayEnabled
virtual void BinormalArrayEnabled(bool val)=0
disti::IGlsStateManagerES20::HasCustomShader
virtual bool HasCustomShader() const =0
disti::IGlsStateManagerES20::AlphaBlendFunc
virtual void AlphaBlendFunc(GLenum src, GLenum dst)=0
disti::IGlsStateManagerES20::UpdateShaderProgram
virtual void UpdateShaderProgram(const GLboolean forceUpdate)=0
disti::IGlsStateManagerES20::PopAlphaBlendFunc
virtual void PopAlphaBlendFunc()=0
Pop the current alpha blend function off the stack.
disti::IGlsStateManagerES20::UpdateShaderAttributes
virtual void UpdateShaderAttributes()=0
disti::IGlsStateManager
Definition: gls_state_manager_interface.h:69
gls_es20_effect.h
The disti::GlsEffect class. Holds information pertaining to shader programs and their uniform/attribu...
gls_es20_effect_params.h
Strings and other standard enumerations used in effects.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
gls_state_manager_interface.h
IGlsStateManager, interface to a state manager that manages the GL Studio runtime library's use of th...
disti
Definition: bmpimage.h:47
disti::IGlsStateManagerES20::gl_LightSourceParameters
Definition: gls_state_manager_es20_interface.h:71
disti::IGlsStateManagerES20::gl_LightSourceParameters::_ambient
GLfloat _ambient[4]
Ambient color RGBA.
Definition: gls_state_manager_es20_interface.h:72
disti::IGlsStateManagerES20::gl_LightSourceParameters::_spotExponent
float _spotExponent
Spotlight exponent.
Definition: gls_state_manager_es20_interface.h:79
disti::IGlsStateManagerES20::gl_LightSourceParameters::_specular
GLfloat _specular[4]
Specular color RGBA.
Definition: gls_state_manager_es20_interface.h:74
disti::IGlsStateManagerES20::gl_LightSourceParameters::_spotCutoff
float _spotCutoff
Spotlight cutoff in degrees.
Definition: gls_state_manager_es20_interface.h:80
disti::IGlsStateManagerES20::gl_LightSourceParameters::_diffuse
GLfloat _diffuse[4]
Diffuse color RGBA.
Definition: gls_state_manager_es20_interface.h:73
disti::IGlsStateManagerES20::gl_LightSourceParameters::_quadraticAttenuation
float _quadraticAttenuation
Quadratic attenuation.
Definition: gls_state_manager_es20_interface.h:84
disti::IGlsStateManagerES20::gl_LightSourceParameters::_position
GLfloat _position[4]
Position XYZW.
Definition: gls_state_manager_es20_interface.h:75
disti::IGlsStateManagerES20::gl_LightSourceParameters::_linearAttenuation
float _linearAttenuation
Linear attenuation.
Definition: gls_state_manager_es20_interface.h:83
disti::IGlsStateManagerES20::gl_LightSourceParameters::_spotDirection
GLfloat _spotDirection[3]
Spotlight direction XYZ vector.
Definition: gls_state_manager_es20_interface.h:77
disti::IGlsStateManagerES20::gl_LightSourceParameters::_constantAttenuation
float _constantAttenuation
Constant attenuation.
Definition: gls_state_manager_es20_interface.h:82