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 
48 
49 #include "gls_es20_effect.h"
50 #include "gls_es20_effect_params.h"
51 
52 #ifndef LESS_MAX_LIGHTS
53 # define MAX_LIGHTS 8
54 #else
55 # define MAX_LIGHTS 6
56 #endif
57 
58 namespace 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  */
65 class IGlsStateManagerES20 : virtual public IGlsStateManager
66 {
67 public:
68  /** Structure used to replic8 the Fixed-Function lighting model */
70  {
71  GLfloat _ambient[ 4 ];
72  GLfloat _diffuse[ 4 ];
73  GLfloat _specular[ 4 ];
74  GLfloat _position[ 4 ];
75 
76  GLfloat _spotDirection[ 3 ];
77 
78  float _spotExponent;
79  float _spotCutoff;
80 
81  float _constantAttenuation;
82  float _linearAttenuation;
83  float _quadraticAttenuation;
84  };
85 
86  ////////////////////////////////////////////////////////////////
87  //
88  // Matrix Stack
89  //
90  ////////////////////////////////////////////////////////////////
91  GLS_EXPORT virtual GlsMatrixType& GetTopModelViewMatrix( void ) = 0;
92  GLS_EXPORT virtual GlsMatrixType& GetTopProjMatrix( void ) = 0;
93 
94  ////////////////////////////////////////////////////////////////
95  //
96  // The following methods manage the various OpenGL state calls
97  //
98  ////////////////////////////////////////////////////////////////
99  GLS_EXPORT virtual void TangentArrayEnabled( bool val ) = 0;
100  GLS_EXPORT virtual void BinormalArrayEnabled( bool val ) = 0;
101 
102  GLS_EXPORT virtual void TangentPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
103  GLS_EXPORT virtual void BinormalPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
104 
105  GLS_EXPORT virtual void AlphaBlendFuncSeparate( GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha ) = 0;
106  GLS_EXPORT virtual void AlphaBlendFunc( GLenum src, GLenum dst ) = 0;
107  GLS_EXPORT virtual void PushAlphaBlendFunc() = 0;
108  GLS_EXPORT virtual void PopAlphaBlendFunc() = 0;
109 
110  ////////////////////////////////////////////////////////////////
111  //
112  // The following methods manage the effects
113  //
114  ////////////////////////////////////////////////////////////////
115  GLS_EXPORT virtual gl_LightSourceParameters& GetLightSourceParameters( unsigned int index ) = 0;
116 
117  /** Enable the given custom shader program and push it to the top of the custom shader program stack
118  * \param effect custom shader program
119  * \param useProgramImmediately GL_TRUE if custom shader program should immediately be set as the active
120  * shader program else GL_FALSE to allow the state manager to set the program
121  * active when it is needed
122  * \pre number of custom shader programs is < CUSTOM_SHADER_PROGRAM_STACK_DEPTH
123  * \post the given custom shader program is at the top of the custom shader program stack and is enabled, it
124  * is set to the current active shader program if useProgramImmediately is GL_TRUE
125  */
126  GLS_EXPORT virtual void PushCustomShaderProgram( GlsEffect* effect, const GLboolean useProgramImmediately ) = 0;
127 
128  /** Pop the custom shader program stack enabling the next custom shader program on the stack if there is one
129  * \pre number of custom shader programs is > 0
130  * \post the custom shader program stack is popped enabling the next custom shader program on the stack if there is one
131  */
132  GLS_EXPORT virtual void PopCustomShaderProgram( void ) = 0;
133 
134  /** Returns true if there is at least one custom shader on the stack
135  */
136  GLS_EXPORT virtual bool HasCustomShader( void ) const = 0;
137 
138  /** Select the appropriate shader program based on the current settings and update
139  * the current shader program if needed
140  * \param forceUpdate GL_TRUE to force uniforms to be updated as if shader program changed
141  * \pre none
142  * \post appropriate shader program based on the current settings is active
143  */
144  GLS_EXPORT virtual void UpdateShaderProgram( const GLboolean forceUpdate ) = 0;
145 
146  /** Update the attributes for the current shader as needed
147  * \pre none
148  * \post Appropriate attributes for the current shader are updated
149  */
150  GLS_EXPORT virtual void UpdateShaderAttributes( void ) = 0;
151 
152  /** Update the uniforms for the current shader as needed
153  * \pre none
154  * \post Appropriate uniforms for the current shader are updated
155  */
156  GLS_EXPORT virtual void UpdateShaderUniforms( void ) = 0;
157 
158 protected:
159  /** empty ctor */
161 
162  /** empty dtor */
164 };
165 
166 } // namespace disti
167 
168 #endif // DISTI_GLS_STATE_MANAGER_ES20_INTERFACE_H_INCLUDED
virtual void PushCustomShaderProgram(GlsEffect *effect, const GLboolean useProgramImmediately)=0
Definition: gls_state_manager_es20_interface.h:65
Definition: gls_es20_effect.h:58
virtual void PushAlphaBlendFunc()=0
IGlsStateManager, interface to a state manager that manages the GL Studio runtime library's use of th...
virtual void PopAlphaBlendFunc()=0
virtual void UpdateShaderProgram(const GLboolean forceUpdate)=0
The disti::GlsEffect class. Holds information pertaining to shader programs and their uniform/attribu...
Definition: gls_state_manager_interface.h:67
Strings and other standard enumerations used in effects.
Definition: gls_state_manager_es20_interface.h:69
virtual void AlphaBlendFunc(GLenum src, GLenum dst)=0
virtual void PopCustomShaderProgram(void)=0
virtual void AlphaBlendFuncSeparate(GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha)=0
IGlsStateManagerES20(void)
Definition: gls_state_manager_es20_interface.h:160
virtual void UpdateShaderUniforms(void)=0
virtual bool HasCustomShader(void) const =0
Definition: bmpimage.h:46
virtual void UpdateShaderAttributes(void)=0
~IGlsStateManagerES20()
Definition: gls_state_manager_es20_interface.h:163