GL Studio C++ Runtime API
gls_es20_uniform.h
Go to the documentation of this file.
1/// \file gls_es20_uniform.h
2/// \brief Templated class to hold uniform data for ES20 effects.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef DISTI_GLS_ES20_UNIFORM_H_INCLUDED
40#define DISTI_GLS_ES20_UNIFORM_H_INCLUDED
41
42#include "gls_gl.h"
43#include "gls_include.h"
44
45namespace disti
46{
47/// \details The GlsUniform class. Wraps an OpenGL shader uniform.
49{
50public:
51 /** Constructor. Sets the dirty flag and "invalid" uniform location.
52 */
54
55 /** Destructor. Does nothing.
56 */
58
59 /** Grabs the uniform location for this uniform from the program object.
60 * \param[in] programObject The program that this uniform belongs to.
61 * \param[in] name The name of the variable as provided to the shaders
62 * \return The new uniform location, or -1 on failure.
63 */
64 GLS_EXPORT GLint SetUniformLocation( GLuint programObject, const GLchar* name );
65
66 /** Set single integer uniform data.
67 * \param[in] data The uniform value to set.
68 */
69 GLS_EXPORT void SetUniform1i( int data );
70
71 /** Set two integer uniform data.
72 * \param[in] data The uniform value to set.
73 */
74 GLS_EXPORT void SetUniform2i( int* data );
75
76 /** Set three integer uniform data.
77 * \param[in] data The uniform value to set.
78 */
79 GLS_EXPORT void SetUniform3i( int* data );
80
81 /** Set four integer uniform data.
82 * \param[in] data The uniform value to set.
83 */
84 GLS_EXPORT void SetUniform4i( int* data );
85
86 /** Set single float uniform data.
87 * \param[in] data The uniform value to set.
88 */
89 GLS_EXPORT void SetUniform1f( float data );
90
91 /** Set two float uniform data.
92 * \param[in] data The uniform value to set.
93 */
94 GLS_EXPORT void SetUniform2f( float* data );
95
96 /** Set three float uniform data.
97 * \param[in] data The uniform value to set.
98 */
99 GLS_EXPORT void SetUniform3f( float* data );
100
101 /** Set four float uniform data.
102 * \param[in] data The uniform value to set.
103 */
104 GLS_EXPORT void SetUniform4f( float* data );
105
106 /** Set four float uniform data.
107 * \param[in] x the first float value
108 * \param[in] y the second float value
109 * \param[in] z the third float value
110 * \param[in] w the fourth float value
111 */
112 GLS_EXPORT void SetUniform4f( float x, float y, float z, float w );
113
114 /** Set four float uniform data vectors. Note that this method doesn't cache the old values,
115 * since we would have to dynamically allocate the cache memory based on size. Therefore,
116 * prefer SetUniform4f when just setting a single 4 float vector
117 * \param[in] size the number of 4 float vectors to set
118 * \param[in] data The uniform value to set.
119 */
120 GLS_EXPORT void SetUniform4fv( int size, float* data );
121
122 /** Set 2x2 matrix uniform data.
123 * \param[in] data The uniform value to set.
124 */
125 GLS_EXPORT void SetUniformMatrix2f( float* data );
126
127 /** Set 3x3 matrix uniform data.
128 * \param[in] data The uniform value to set.
129 */
130 GLS_EXPORT void SetUniformMatrix3f( float* data );
131
132 /** Set 4x4 matrix uniform data.
133 * \param[in] data The uniform value to set.
134 */
135 GLS_EXPORT void SetUniformMatrix4f( float* data );
136
137 /** Mark this uniform as dirty, guaranteeing the uniform will be updated on the next set call.
138 */
140
141protected:
142 /** The uniform location as provided by the shader program. Defaults to -1. */
143 GLint _uniformLocation; // = -1;
144
145 /** If true, the uniform data should be sent to the program object. Defaults to true. */
146 bool _isDirty; // = true;
147
148 /** Convenience Union for comparing data. */
149 union
150 {
151 int as1i;
152 int as2i[ 2 ];
153 int as3i[ 3 ];
154 int as4i[ 4 ];
155 float as1f;
156 float as2f[ 2 ];
157 float as3f[ 3 ];
158 float as4f[ 4 ];
159 float asMat2[ 4 ];
160 float asMat3[ 9 ];
161 float asMat4[ 16 ];
163};
164
165} // namespace disti
166
167#endif // DISTI_GLS_ES20_UNIFORM_H_INCLUDED
Definition: gls_es20_uniform.h:49
void SetUniformMatrix2f(float *data)
~GlsUniform()
Definition: gls_es20_uniform.h:57
void SetUniform4fv(int size, float *data)
union disti::GlsUniform::@1 _data
void SetUniform3f(float *data)
void SetUniformMatrix3f(float *data)
void SetUniform2f(float *data)
void SetUniform1i(int data)
void SetUniform1f(float data)
void SetUniform4f(float *data)
void SetUniform3i(int *data)
void SetUniform4i(int *data)
bool _isDirty
Definition: gls_es20_uniform.h:146
GLint SetUniformLocation(GLuint programObject, const GLchar *name)
void SetUniform2i(int *data)
void SetUniform4f(float x, float y, float z, float w)
void SetUniformMatrix4f(float *data)
GLint _uniformLocation
Definition: gls_es20_uniform.h:143
The gls_gl.
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
Definition: bmpimage.h:46