GL Studio C++ Runtime API
gls_es20_effect.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsEffect class. Holds information pertaining to shader programs and their uniform/attribute data
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. Use, distribution,
38duplication, or disclosure by the U. S. Government is subject to
39"Restricted Rights" as set forth in DFARS 252.227-7014(c)(1)(ii).
40
41*/
42
43#ifndef DISTI_GLS_ES20_EFFECT_H_INCLUDED
44#define DISTI_GLS_ES20_EFFECT_H_INCLUDED
45
46#include "dynamic_array.h"
48#include "gls_es20_uniform.h"
49#include "gls_gl.h"
50
51#include <map>
52
53namespace disti
54{
55/** The GlsEffect Class. This class stores program objects and lists of uniforms.
56* Because all construction methods are private, Effects can be only created with the
57* friend Factory class.
58*/
60{
61 /** Only the effect factory should be creating new effects. */
63 friend class std::map<GLuint, GlsEffect>;
64 friend class DynamicArray<GlsEffect, false>;
65
66public:
67 /** Get uniform data for one of the standard uniforms.
68 * \param[in] uniform The standard uniform enum (\see StdUniforms_e)
69 * \pre uniform is a valid StdUniforms_e
70 * \return the uniform
71 */
73
74 /** Get uniform data for one of the custom uniforms.
75 * \param[in] uniform The custom uniform's ID
76 * \return the uniform
77 */
79
80 /** Get attribute location
81 * \param[in] attribute The standard attribute to query (\see StdAttribs_e)
82 * \pre attribute is a valid StdAttribs_e
83 * \return The attribute's location
84 */
86
87 /** Compile and link vertex and fragment shaders, creating a program object.
88 * \param[in] vertexShader The vertex shader.
89 * \param[in] fragmentShader The fragment shader.
90 * \return The newly created program object, or 0 on error.
91 */
92 GLS_EXPORT GLuint CreateShader( const GLchar* vertexShader, const GLchar* fragmentShader );
93
94 /** Create a custom uniform to add to this effect's list of custom uniforms
95 * \param[in] uniformName The string representing the name of this uniform
96 * \return the ID corresponding to this custom uniform's position in the array, or -1 on failure
97 */
98 GLS_EXPORT GLint CreateCustomUniform( const char* uniformName );
99
100 /** Indicates if this effect was successfully loaded or not
101 * \return true if the effect has been successfully loaded
102 */
104
105 /** Use the program for this effect.
106 */
108
109 /** Get the program object associated with this effect.
110 * \return the program object
111 */
113
114 /** dtor */
116
117protected:
118 /// Delete/destroy the shader program and its shaders.
119 /// \param vertObject GL index of the vertex shader program.
120 /// \param fragObject GL index of the fragment shader program.
121 /// \pre none
122 /// \post shaders are deleted
123 /// \post _programObject == 0
124 void FreeShaders( GLuint vertObject, GLuint fragObject );
125
126 /** Load and compile a new shader.
127 * \param[in] shaderType The type of shader this is
128 * \param[in] shaderSource The code for the shader
129 * \pre shaderType is GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
130 * \return The shader object's ID or 0 on failure.
131 */
132 GLuint LoadAndCompileShader( GLenum shaderType, const char* shaderSource );
133
134 /// Hashes the shader programs, used to determine the filename of the precompiled shader
135 /// for platforms that do not support inline shader compilation.
136 /// \param vertexShader The vertex shader program source code.
137 /// \param fragmentShader The fragment shader program source code.
138 /// \return A hash of the shader programs.
139 std::size_t HashShader( const GLchar* vertexShader, const GLchar* fragmentShader );
140
141 /** This effect's program object. */
143
144 /** Standard uniform types. Index values can be acquired from the factory. */
145 GlsUniform _stdUniforms[ MAX_STD_UNIFORMS ];
146
147 /** Custom uniform types for custom shaders. */
149
150 /** The attributes for this effect. */
151 GLint _attribLocations[ MAX_STD_ATTRIBS ];
152
153private:
154 /** Private constructor.
155 * This class should only be instantiated by the GlsEffectFactory class.
156 */
157 GlsEffect();
158
159 // disallow
160 GlsEffect( const GlsEffect& src );
161 GlsEffect& operator=( const GlsEffect& rhs );
162};
163
164} // namespace disti
165
166#endif // DISTI_GLS_ES20_EFFECT_H_INCLUDED
Definition: dynamic_array.h:79
Definition: gls_es20_effect.h:60
GLuint LoadAndCompileShader(GLenum shaderType, const char *shaderSource)
GLuint GetAttribLocation(StdAttribs_e attribute)
GlsUniform _stdUniforms[MAX_STD_UNIFORMS]
Definition: gls_es20_effect.h:145
GLint CreateCustomUniform(const char *uniformName)
void FreeShaders(GLuint vertObject, GLuint fragObject)
DynamicArray< GlsUniform, false > _customUniforms
Definition: gls_es20_effect.h:148
GLuint _programObject
Definition: gls_es20_effect.h:142
friend class GlsEffectFactoryImpl
Definition: gls_es20_effect.h:62
GLuint CreateShader(const GLchar *vertexShader, const GLchar *fragmentShader)
GlsUniform * GetStdUniform(StdUniforms_e uniform)
GLuint GetProgramObject()
std::size_t HashShader(const GLchar *vertexShader, const GLchar *fragmentShader)
GLint _attribLocations[MAX_STD_ATTRIBS]
Definition: gls_es20_effect.h:151
GlsUniform * GetCustomUniform(GLint uniform)
Definition: gls_es20_uniform.h:53
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
Strings and other standard enumerations used in effects.
Templated class to hold uniform data for ES20 effects.
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
StdAttribs_e
Definition: gls_es20_effect_params.h:134
StdUniforms_e
Definition: gls_es20_effect_params.h:50