| 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
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. Use, distribution,
38 duplication, 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
49 namespace disti
50{
51/// \details The GlsUniform class. Wraps an OpenGL shader uniform.
52 class GlsUniform
53{
54 public:
55 /** Constructor. Sets the dirty flag and "invalid" uniform location.
56 */
57 GLS_EXPORT GlsUniform();
58
59 /** Destructor. Does nothing.
60 */
61 GLS_EXPORT ~GlsUniform() {}
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 */
143 GLS_EXPORT void SetDirtyFlag();
144
145 protected:
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 ];
166 } _data;
167};
168
169} // namespace disti
170
171#endif // DISTI_GLS_ES20_UNIFORM_H_INCLUDED
disti::GlsUniform
Definition: gls_es20_uniform.h:53
disti::GlsUniform::SetUniformMatrix2f
void SetUniformMatrix2f(float *data)
disti::GlsUniform::~GlsUniform
~GlsUniform()
Definition: gls_es20_uniform.h:61
disti::GlsUniform::SetUniform4fv
void SetUniform4fv(int size, float *data)
disti::GlsUniform::_data
union disti::GlsUniform::@1 _data
disti::GlsUniform::SetUniform3f
void SetUniform3f(float *data)
disti::GlsUniform::SetUniformMatrix3f
void SetUniformMatrix3f(float *data)
disti::GlsUniform::SetUniform2f
void SetUniform2f(float *data)
disti::GlsUniform::SetUniform1i
void SetUniform1i(int data)
disti::GlsUniform::SetUniform1f
void SetUniform1f(float data)
disti::GlsUniform::SetUniform4f
void SetUniform4f(float *data)
disti::GlsUniform::SetUniform3i
void SetUniform3i(int *data)
disti::GlsUniform::GlsUniform
GlsUniform()
disti::GlsUniform::SetDirtyFlag
void SetDirtyFlag()
disti::GlsUniform::SetUniform4i
void SetUniform4i(int *data)
disti::GlsUniform::SetUniformLocation
GLint SetUniformLocation(GLuint programObject, const char *name)
disti::GlsUniform::_isDirty
bool _isDirty
Definition: gls_es20_uniform.h:150
disti::GlsUniform::SetUniform2i
void SetUniform2i(int *data)
disti::GlsUniform::SetUniform4f
void SetUniform4f(float x, float y, float z, float w)
disti::GlsUniform::SetUniformMatrix4f
void SetUniformMatrix4f(float *data)
disti::GlsUniform::_uniformLocation
GLint _uniformLocation
Definition: gls_es20_uniform.h:147
gls_gl.h
The gls_gl.
GLchar
#define GLchar
Hack for imx.53 board which does not define GLchar in gl2.h or gl2ext.h.
Definition: gls_gl.h:80
gls_include.h
A file for all GL Studio files to include.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
disti
Definition: bmpimage.h:47