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