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