| GL Studio C++ Runtime API

gls_state_manager_interface.h
Go to the documentation of this file.
1/*! \file
2 \brief IGlsStateManager, interface to a state manager that manages the GL Studio
3 runtime library's use of the OpenGL context, minimizing unnecessary state changes.
4
5 \par Copyright Information
6
7 Copyright (c) 2017 by The DiSTI Corporation.<br>
8 11301 Corporate Blvd; Suite 100<br>
9 Orlando, Florida 32817<br>
10 USA<br>
11 <br>
12 All rights reserved.<br>
13
14 This Software contains proprietary trade secrets of DiSTI and may not be
15 reproduced, in whole or part, in any form, or by any means of electronic,
16 mechanical, or otherwise, without the written permission of DiSTI. Said
17 permission may be derived through the purchase of applicable DiSTI product
18 licenses which detail the distribution rights of this content and any
19 Derivative Works based on this or other copyrighted DiSTI Software.
20
21 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
22 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
23 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
24 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
25 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
26 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
27
28 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
29 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
30 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
31 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
32 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
33 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
34 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
35 EXCEED FIVE DOLLARS (US$5.00).
36
37 The aforementioned terms and restrictions are governed by the laws of the
38 State of Florida and the United States of America. Use, distribution,
39 duplication, or disclosure by the U. S. Government is subject to
40"Restricted Rights" as set forth in DFARS 252.227-7014(c)(1)(ii).
41
42*/
43
44#ifndef DISTI_GLS_STATE_MANAGER_INTERFACE_H_INCLUDED
45#define DISTI_GLS_STATE_MANAGER_INTERFACE_H_INCLUDED
46
47#include "IFontImage.h"
48#include "gls_color.h"
49#include "gls_gl.h"
50#include "gls_include.h"
51#include "gls_matrix_affine.h"
52#include "non_copyable.h"
53#include "scoped_ptr.h"
54
55/// The maximum number of lights, matching the fixed function pipeline.
56#ifndef LESS_MAX_LIGHTS
57# define MAX_LIGHTS 8
58#else
59# define MAX_LIGHTS 6
60#endif
61
62 namespace disti
63{
64/** \interface IGlsStateManager
65 * The interface to a state manager that manages the GL Studio
66 * runtime library's use of the OpenGL context, minimizing unnecessary state changes
67 */
68 class IGlsStateManager : public NonCopyable
69{
70 public:
71 /// Wrapper for glBlendFuncSeparate if supported, or glBlendFunc (ignoring the last two parameters) if
72 /// glBlendFuncSeparate is not supported. Parameters are equivalent to glBlendFuncSeparate.
73 /// \param srcColor Function to use for source color.
74 /// \param dstColor Function to use for destination color.
75 /// \param srcAlpha Function to use for source alpha.
76 /// \param dstAlpha Function to use for destination alpha.
77 GLS_EXPORT virtual void AlphaBlendFuncSeparate( GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha ) = 0;
78
79 /// Sets the default blend function for GL Studio.
80 GLS_EXPORT virtual void SetDefaultAlphaBlendFunc() = 0;
81
82 /// Pushes the current alpha blend func onto an internal stack. Can restore the pushed alpha blend func by calling PopAlphaBlendFunc.
83 GLS_EXPORT virtual void PushAlphaBlendFunc() = 0;
84
85 /// Pops the previously pushed alpha blend func from the stack and restores its state to the opengl context.
86 GLS_EXPORT virtual void PopAlphaBlendFunc() = 0;
87
88 /// Wrapper for glBlendFunc. Parameters are equivalent to glBlendFunc.
89 /// \param src Function to use for source color.
90 /// \param dst Function to use for destination color.
91 GLS_EXPORT virtual void AlphaBlendFunc( GLenum src, GLenum dst ) = 0;
92
93#ifdef GLES
94 /// Supported texture mapping modes.
95 enum {
96 GLS_TEXTURE_MAP_MODE_MODULATE = 0x2100, // = GL_MODULATE
97 GLS_TEXTURE_MAP_MODE_DECAL = 0x2101, // = GL_DECAL
98 GLS_TEXTURE_MAP_MODE_BLEND = 0x0BE2, // = GL_BLEND
99 GLS_TEXTURE_MAP_MODE_REPLACE = 0x1E01 // = GL_REPLACE
100 };
101
102 /** Initializes the state manager to its default states and then sends that state
103 * to the OpenGL context
104 * \param forceResetUnmanagedState Force the reset of all GL state, even state unmanaged by GL Studio.
105 */
106 GLS_EXPORT virtual void SetDefaultState( bool forceResetUnmanagedState = false ) = 0;
107
108 ////////////////////////////////////////////////////////////////
109 //
110 // Matrix Stack
111 //
112 ////////////////////////////////////////////////////////////////
113 enum {
114 MATRIX_STACK_DEPTH = 64u, /**< Depth of model view matrix stack */
115 PROJECTION_STACK_DEPTH = 64u, /**< Depth of projection matrix stack */
116 TEXTURE_STACK_DEPTH = 64u, /**< Depth of texture matrix stack */
117 CUSTOM_SHADER_PROGRAM_STACK_DEPTH = 64u /**< Depth of custom shader stack */
118 };
119
120 /// Load the given matrix into the projection matrix.
121 /// \pre GLMatrixAffineFIsValid( m )
122 /// \post The given matrix is the projection matrix.
123 /// \param m The matrix to load onto the projeciton matrix.
124 GLS_EXPORT virtual void LoadProjectionMatrixf( const GlsMatrixType& m ) = 0;
125
126 /// Set the current projection matrix to the identity matrix.
127 /// \post The projection matrix becomes the identity matrix.
128 GLS_EXPORT virtual void LoadProjectionIdentityMatrix() = 0;
129
130 /// Adds a projection matrix to the top of the stack.
131 /// \pre Current projection matrix stack index is < ( PROJECTION_STACK_DEPTH - 1u ).
132 /// \post Project matrix stack is pushed.
133 GLS_EXPORT virtual void PushProjectionMatrix() = 0;
134
135 /// Removes a projection matrix from the top of the stack.
136 /// \pre Current projection matrix stack index is > 0u.
137 /// \post Projection matrix stack is popped.
138 GLS_EXPORT virtual void PopProjectionMatrix() = 0;
139
140 /// Load the given matrix on to the top of the matrix stack.
141 /// \pre GLMatrixAffineFIsValid( m )
142 /// \post The given matrix is on the top of the matrix stack.
143 /// \param m The matrix to push onto the stack.
144 GLS_EXPORT virtual void LoadModelViewMatrixf( const GlsMatrixType& m ) = 0;
145
146 /// Set the current model view matrix to the identity matrix.
147 GLS_EXPORT virtual void LoadModelViewIdentityMatrix() = 0;
148
149 /// Multiply (and optionally push) the top of the stack by the given matrix such that if
150 /// t is the top of the matrix then t=t*m . If pushMatrix is true then the matrix stack
151 /// is pushed before the multiplication.
152 /// \param m matrix to multiply by.
153 /// \param pushMatrix true to push the matrix stack before multiplying.
154 /// \pre GLMatrixAffineFIsValid( m ), current matrix stack index is < ( MATRIX_STACK_DEPTH - 1u ) if pushMatrix is true.
155 /// \post the top of the stack is multiplied by the given matrix.
156 GLS_EXPORT virtual void MultModelViewMatrixf( const GlsMatrixType& m, const GLboolean pushMatrix ) = 0;
157
158 /// Apply a translation to the top of the model view matrix stack.
159 /// \param x The x-coordinate of the translation vector.
160 /// \param y The y-coordinate of the translation vector.
161 /// \param z The z-coordinate of the translation vector.
162 GLS_EXPORT virtual void TranslateModelViewMatrixf( GLfloat x, GLfloat y, GLfloat z ) = 0;
163
164 /// Push the matrix stack.
165 /// \pre Current matrix stack index is < ( MATRIX_STACK_DEPTH - 1u ).
166 /// \post Matrix stack is pushed.
167 GLS_EXPORT virtual void PushModelViewMatrix() = 0;
168
169 /// Pop the matrix stack.
170 /// \pre Current matrix stack index is > 0u.
171 /// \post Matrix stack is popped.
172 GLS_EXPORT virtual void PopModelViewMatrix() = 0;
173
174 /// Load the given matrix to the top of the texture matrix stack.
175 /// \pre GLMatrixAffineFIsValid( m ).
176 /// \post The given matrix is on the top of the texture matrix stack.
177 /// \param m The matrix to load to the top of the texture matrix stack.
178 GLS_EXPORT virtual void LoadTextureMatrixf( const GlsMatrixType& m ) = 0;
179
180 /// Sets the current texture matrix to the identity matrix.
181 GLS_EXPORT virtual void LoadTextureIdentityMatrix() = 0;
182
183 /// Apply a scale factor to the top of the texture matrix stack.
184 /// \param x The x-coordinate of the scale vector.
185 /// \param y The y-coordinate of the scale vector.
186 /// \param z The z-coordinate of the scale vector.
187 GLS_EXPORT virtual void ScaleTextureMatrixf( GLfloat x, GLfloat y, GLfloat z ) = 0;
188
189 /// Apply a translation to the top of the texture matrix stack.
190 /// \param x The x-coordinate of the translation vector.
191 /// \param y The y-coordinate of the translation vector.
192 /// \param z The z-coordinate of the translation vector.
193 GLS_EXPORT virtual void TranslateTextureMatrixf( GLfloat x, GLfloat y, GLfloat z ) = 0;
194
195 /// Push the texture matrix stack.
196 /// \pre Current matrix stack index is < ( MATRIX_STACK_DEPTH - 1u ).
197 /// \post Matrix stack is pushed.
198 GLS_EXPORT virtual void PushTextureMatrix() = 0;
199
200 /// Pop the texture matrix stack.
201 /// \pre Current matrix stack index is > 0u.
202 /// \post Matrix stack is popped.
203 GLS_EXPORT virtual void PopTextureMatrix() = 0;
204
205 ////////////////////////////////////////////////////////////////
206 //
207 // The following methods manage the various OpenGL state calls
208 //
209 ////////////////////////////////////////////////////////////////
210
211 /// Updates OpenGL to enable or disable alpha blending.
212 /// \param val If true, then alpha blend is enabled. Otherwise, it'll disable alpha blend.
213 GLS_EXPORT virtual void AlphaBlendEnabled( bool val ) = 0;
214
215 /// Enables or disables the shader alpha test. When testing, the fragment shaders will
216 /// check the transparency of the fragment. If it's nearly invisible, the shader instructions
217 /// will be discarded and will not update the buffer.
218 /// \param val If true, then the shader alpha test is enabled. Otherwise, it's disabled.
219 GLS_EXPORT virtual void AlphaTestEnabled( bool val ) = 0;
220
221 /// Specifies the alpha comparison function. Fragments may be discarded depending on the outcome of this function comparison.
222 /// \param func Determines the type of comparison to conduct.
223 /// \param val Determines the threshold when the comparison passes or not.
224 GLS_EXPORT virtual void AlphaTestFunc( GLenum func, GLfloat val ) = 0;
225
226 /// Updates OpenGL to enable or disable the depth test. The depth test will determine if fragments
227 /// behind other surfaces should be discarded or not.
228 /// \param val If true, then the depth test is enabled. Otherwise, it'll disable the depth test.
229 GLS_EXPORT virtual void DepthTestEnabled( bool val ) = 0;
230
231 /// Notifies OpenGL to enable or disable writing to the depth buffer.
232 /// \param val If true, then writing to the depth buffer is enabled. Otherwise, it'll be disabled.
233 GLS_EXPORT virtual void DepthMaskEnabled( bool val ) = 0;
234
235 /// \return True if writing to the depth buffer is enabled. Otherwise, false is returned if it's disabled.
236 GLS_EXPORT virtual bool IsDepthMaskEnabled() = 0;
237
238 /// Determines the comparison function to use when performing a depth test.
239 /// \param func Determines the type of comparison to conduct when performing a depth test.
240 GLS_EXPORT virtual void DepthFunc( GLenum func ) = 0;
241
242 /// Specifies a linear mapping of the normalized depth coordinates.
243 /// \param min The mapping of the near clipping plane.
244 /// \param max The mapping of the far clipping plane.
245 GLS_EXPORT virtual void DepthRange( GLfloat min, GLfloat max ) = 0;
246
247 /// Notifies OpenGL to enable or disable backface culling. If enabled, triangles facing away from
248 /// the camera are not rendered.
249 /// \param val If true, then backface culling is enabled. Otherwise, it's disabled.
250 GLS_EXPORT virtual void BackfaceCullingEnabled( bool val ) = 0;
251
252 /// Enables or disables textures. When enabled, shaders can leverage the diffuse map.
253 /// \param val If true, then textures are enabled. Otherwise, it's disabled.
254 GLS_EXPORT virtual void Texture2DEnabled( bool val ) = 0;
255
256 /// Notifies OpenGL the active texture. All subsequent texture state calls will affect the active texture
257 /// \param textureUnit the texture unit to make active.
258 GLS_EXPORT virtual void ActiveTexture( GLenum textureUnit ) = 0;
259
260 /// Binds the given texture to the current active texture unit.
261 /// \param texture the texture to bind to the active texture unit.
262 GLS_EXPORT virtual void BindTexture( IFontImage* texture ) = 0;
263
264 /// Unbinds and deletes the specified texture.
265 /// \param texture the texture to unbind from OpenGL and delete.
266 GLS_EXPORT virtual void DeleteTexture( IFontImage* texture ) = 0;
267
268 /// Determines the horizontal wrapping behavior of the active texture.
269 /// \param mode The type of wrapping behavior. Common ones are clamping and repeat.
270 GLS_EXPORT virtual void SetTextureWrapS( GLenum mode ) = 0;
271
272 /// Determines the vertical wrapping behavior of the active texture.
273 /// \param mode The type of wrapping behavior. Common ones are clamping and repeat.
274 GLS_EXPORT virtual void SetTextureWrapT( GLenum mode ) = 0;
275
276 /// Equivalent to calling glTexEnv. This updates the texture environment mode to determine shader functions should run.
277 /// \param mode The type of feature to run. For GLES 2.0, the valid values are GLS_TEXTURE_MAP_MODE_MODULATE,
278 /// GLS_TEXTURE_MAP_MODE_REPLACE, GLS_TEXTURE_MAP_MODE_BLEND, and GLS_TEXTURE_MAP_MODE_DECAL.
279 /// Otherwise mode may refer to one of six texture functions: GL_ADD, GL_MODULATE, GL_DECAL, GL_BLEND, GL_REPLACE, or GL_COMBINE.
280 /// Any other value will disable this feature.
281 GLS_EXPORT virtual void SetTextureEnvMode( GLenum mode ) = 0;
282
283 /// Updates the shader to blend the specified color.
284 /// \param color the new color to blend against.
285 GLS_EXPORT virtual void SetTextureBlendColor( GLfloat* color ) = 0;
286
287 /// Specifies the active texture's minification function whenever the pixel being textured maps to an area greater than one texture element.
288 /// \param mode The function to use when scaling down. Valid values are GL_NEAREST, GL_LINEAR
289 /// GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR.
290 GLS_EXPORT virtual void SetTextureMinFilter( GLenum mode ) = 0;
291
292 /// Specifies the active texture's magnification function whenever the pixel being texture maps to an area less than or equal to one texture element.
293 /// \param mode The function to use when scaling up. Valid values are GL_NEAREST, GL_LINEAR.
294 GLS_EXPORT virtual void SetTextureMagFilter( GLenum mode ) = 0;
295
296 /// Binds the vertex array buffer to an OpenGL context.
297 /// \param handle The handle to map to the OpenGL context.
298 GLS_EXPORT virtual void BindIndexBuffer( unsigned int handle ) = 0;
299
300 /// Binds the vertex attribute array buffer to an OpenGL context.
301 /// \param handle The handle to map to the OpenGL context.
302 GLS_EXPORT virtual void BindVertexBuffer( unsigned int handle ) = 0;
303
304 /// Enables or disables the vertex shader position attribute.
305 /// \param val If true, then the shader position attribute is enabled. Otherwise, it's disabled.
306 GLS_EXPORT virtual void VertexArrayEnabled( bool val ) = 0;
307
308 /// Enables or disables the vertex shader normal attribute.
309 /// \param val If true, then the shader normal attribute is enabled. Otherwise, it's disabled.
310 GLS_EXPORT virtual void NormalArrayEnabled( bool val ) = 0;
311
312 /// Enables or disables the vertex shader texture coordinates attribute.
313 /// \param val If true, then the shader texture coordinates are enabled. Otherwise, it's disabled.
314 GLS_EXPORT virtual void TextureArrayEnabled( bool val ) = 0;
315
316 /// Enables or disables the vertex shader color attribute.
317 /// \param val If true, then the shader color attribute is enabled. Otherwise, it's disabled.
318 GLS_EXPORT virtual void ColorArrayEnabled( bool val ) = 0;
319
320 /// Update the vertex shader's position attribute with the new parameters.
321 /// \param size The number of components per generic vertex attribute.
322 /// \param type The data type of each component in the array.
323 /// \param stride The byte offset between consecutive generic vertex attributes.
324 /// \param pointer A pointer to the first component of the first generic vertex attribute in the array.
325 GLS_EXPORT virtual void VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
326
327 /// Update the vertex shader's texture coordinates attribute with the new parameters.
328 /// \param size The number of components per generic vertex attribute.
329 /// \param type The data type of each component in the array.
330 /// \param stride The byte offset between consecutive generic vertex attributes.
331 /// \param pointer A pointer to the first component of the first generic vertex attribute in the array.
332 GLS_EXPORT virtual void TexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
333
334 /// Update the vertex shader's normal attribute with the new parameters.
335 /// \param type The data type of each component in the array.
336 /// \param stride The byte offset between consecutive generic vertex attributes.
337 /// \param pointer A pointer to the first component of the first generic vertex attribute in the array.
338 GLS_EXPORT virtual void NormalPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
339
340 /// Update the vertex shader's color attribute with the new parameters.
341 /// \param size The number of components per generic vertex attribute.
342 /// \param type The data type of each component in the array.
343 /// \param stride The byte offset between consecutive generic vertex attributes.
344 /// \param pointer A pointer to the first component of the first generic vertex attribute in the array.
345 GLS_EXPORT virtual void ColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
346
347 /// Enables or disables antialiasing for lines. If enabled, jagged edges will be smoothed out.
348 /// \param val If true, then lines are antialiased.
349 GLS_EXPORT virtual void LineSmoothEnabled( bool val ) = 0;
350
351 /// Determines the width of aliased and antialiased lines. If antialiasing is disabled, the actual width is determined by rounding the
352 /// nearest integer. The width may be clamped. See GetMaximumLineWidth.
353 /// \param width The number of pixels to fill across the line. This must be a positive value.
354 GLS_EXPORT virtual void LineWidth( float width ) = 0;
355
356 /// \return The implementation-dependent maximum width for aliased lines the current platform supports.
357 GLS_EXPORT virtual float GetMaximumLineWidth() = 0;
358
359 /// Specifies the diameter of rasterized points.
360 /// \param size Determines the point diameter. This value must be a positive number.
361 GLS_EXPORT virtual void PointSize( float size ) = 0;
362
363 /// Specifies the render pattern for lines.
364 /// \param pattern Determines which fragments of a line will be drawn. The default pattern is all 1's.
365 /// \param multiplier Specifies the 'scale' for each bit in the line pattern. For example, if the multiplier is 2,
366 /// then the pattern stretches out twice as large. This value is clamped to the range 1 to 256.
367 GLS_EXPORT virtual void LineStipple( unsigned short pattern, unsigned int multiplier ) = 0;
368
369 /// Updates the color for subsequent drawing commands when rendering primitives.
370 /// \param color Updates the current color with this specified color.
371 GLS_EXPORT virtual void SetColor( const glsColor& color ) = 0;
372
373 /// Sets the current normal vector. Passing in a unit length vector is not required.
374 /// \param x The x-axis of the normal vector.
375 /// \param y The y-axis of the normal vector.
376 /// \param z The z-axis of the normal vector.
377 GLS_EXPORT virtual void Normal3f( float x, float y, float z ) = 0;
378
379 /// Updates the ambient material parameter to the new color.
380 /// \param color The new color to use for the ambient material parameter.
381 GLS_EXPORT virtual void AmbientMaterial( const glsColor& color ) = 0;
382
383 /// Updates the diffuse material parameter to the new color.
384 /// \param color The new color to use for the diffuse material parameter.
385 GLS_EXPORT virtual void DiffuseMaterial( const glsColor& color ) = 0;
386
387 /// Updates the specular material parameter to the new color.
388 /// \param color The new color to use for the specular material parameter.
389 GLS_EXPORT virtual void SpecularMaterial( const glsColor& color ) = 0;
390
391 /// Updates the emission material parameter to the new color.
392 /// \param color The new color to use for the emission material parameter.
393 GLS_EXPORT virtual void EmissionMaterial( const glsColor& color ) = 0;
394
395 /// Updates the shininess material parameter to the new value.
396 /// \param shininess The new shiny value to use for the material. The higher the value, the shinier the material becomes.
397 GLS_EXPORT virtual void ShininessMaterial( float shininess ) = 0;
398
399 /// Enables or disables lighting.
400 /// \param val If true, then lighting is enabled.
401 GLS_EXPORT virtual void LightingEnabled( bool val ) = 0;
402
403 /// Determines if the shading model should be flat or smooth. When smooth, the colors between vertices are interpolated.
404 /// If flat, then only one color from the vertex is chosen for the surface.
405 /// \param val If true, then it'll use smooth shading. Otherwise, it'll use flat shading.
406 GLS_EXPORT virtual void GouraudShadingEnabled( bool val ) = 0;
407
408 /// \return True if lighting is enabled.
409 GLS_EXPORT virtual bool IsLightingEnabled() = 0;
410
411 /// \param index Index to the light source to check.
412 /// \return True if the light source associated with the specified index is enabled.
413 GLS_EXPORT virtual bool IsLightSourceEnabled( unsigned int index ) = 0;
414
415 /// \return The maximum number of possible lights this platform supports.
416 GLS_EXPORT virtual unsigned int GetMaxNumLights() = 0;
417
418 /// Sets the specified light source to be active or not.
419 /// \param index Index to the light source to update.
420 /// \param enabled If true, then the light source will be activated. Otherwise, it'll be deactivated.
421 GLS_EXPORT virtual void SetLightEnabled( unsigned int index, bool enabled ) = 0;
422
423 /// Sets the ambient color parameter for the specified light source.
424 /// \param[in] index Determines which light source should have their ambient color updated.
425 /// \param[in] color The new color to use. There must be four floats for the RGBA.
426 GLS_EXPORT virtual void SetLightAmbientColor( unsigned int index, GLfloat* color ) = 0;
427
428 /// Retrieves the ambient color parameter from the specified light source.
429 /// \param[in] index Determines which light source to access.
430 /// \param[out] color Copies the ambient color value to this parameter.
431 GLS_EXPORT virtual void GetLightAmbientColor( unsigned int index, GLfloat* color ) = 0;
432
433 /// Sets the diffuse color parameter for the specified light source.
434 /// \param[in] index Determines which light source should have their diffuse color updated.
435 /// \param[in] color The new color to use. There must be four floats for the RGBA.
436 GLS_EXPORT virtual void SetLightDiffuseColor( unsigned int index, GLfloat* color ) = 0;
437
438 /// Retrieves the diffuse color parameter from the specified light source.
439 /// \param[in] index Determines which light source to access.
440 /// \param[out] color Copies the diffuse color value to this parameter.
441 GLS_EXPORT virtual void GetLightDiffuseColor( unsigned int index, GLfloat* color ) = 0;
442
443 /// Sets the specular color parameter for the specified light source.
444 /// \param[in] index Determines which light source should have their specular color updated.
445 /// \param[in] color The new color to use. There must be four floats for the RGBA.
446 GLS_EXPORT virtual void SetLightSpecularColor( unsigned int index, GLfloat* color ) = 0;
447
448 /// Retrieves the specular color parameter from the specified light source.
449 /// \param[in] index Determines which light source to access.
450 /// \param[out] color Copies the specular color value to this parameter.
451 GLS_EXPORT virtual void GetLightSpecularColor( unsigned int index, GLfloat* color ) = 0;
452
453 /// Sets the light position. This is set in local space.
454 /// \param[in] index Determines which light source should have their position updated.
455 /// \param[in] position The new position in local space. There must be three floats for the XYZ.
456 GLS_EXPORT virtual void SetLightPosition( unsigned int index, GLfloat* position ) = 0;
457
458 /// Retrieves the position of the specified light source. This is retrieved in eye space.
459 /// The retrieved value is different than the set value unless the modelview matrix is identity.
460 /// \param[in] index Determines which light source to access.
461 /// \param[out] position Copies the position value to this parameter. This is in eye space.
462 GLS_EXPORT virtual void GetLightPosition( unsigned int index, GLfloat* position ) = 0;
463
464 /// Specifies the direction of the light. This is retrieved in eye space.
465 /// The retrieved value is different than the set value unless the modelview matrix is identity.
466 /// \param[in] index Determines which light source to access.
467 /// \param[in] direction The new light direction in local space. There must be three floats for the XYZ.
468 GLS_EXPORT virtual void SetSpotlightDirection( unsigned int index, GLfloat* direction ) = 0;
469
470 /// Retrieves the light direction of the specified light source. This is retrieved in eye space.
471 /// The retrieved value is different than the set value unless the modelview matrix is identity.
472 /// \param[in] index Determines which light source to access.
473 /// \param[out] direction Copies the light direction value to this parameter. This is in eye space.
474 GLS_EXPORT virtual void GetSpotlightDirection( unsigned int index, GLfloat* direction ) = 0;
475
476 /// Specifies the maximum spread angle of the light source.
477 /// \param[in] index Determines which light source to access.
478 /// \param[in] cutoff The maximum spread angle. Only values within 90 and 180 are accepted where 180 results in uniform light distribution.
479 GLS_EXPORT virtual void SetSpotlightCutoff( unsigned int index, GLfloat cutoff ) = 0;
480
481 /// \param[in] index Determines which light source to access.
482 /// \return The light cutoff / maximum spread angle of the light source.
483 GLS_EXPORT virtual GLfloat GetSpotlightCutoff( unsigned int index ) = 0;
484
485 /// Updates the light source's intensity distribution of the light.
486 /// \param[in] index Determines which light source to access.
487 /// \param[in] exponent Specifies the intensity distribution of the light where higher values results in a more focused light source,
488 /// and 0 resulting in a more uniformed light distribution.
489 GLS_EXPORT virtual void SetSpotlightExponent( unsigned int index, GLfloat exponent ) = 0;
490
491 /// \param[in] index Determines which light source to access.
492 /// \return The light source intensity distribution from the specified light.
493 GLS_EXPORT virtual GLfloat GetSpotlightExponent( unsigned int index ) = 0;
494
495 /// Sets the light attenuation factor parameters for the specified light source.
496 /// \param[in] index Determines which light source should have their attenuation factor updated.
497 /// \param[in] constant Set the new constant factor that is independent from the light distance.
498 /// \param[in] linear Sets the new linear attenuation factor.
499 /// \param[in] quadratic Sets the new quadratic attenuation factor.
500 GLS_EXPORT virtual void SetLightAttenuation( unsigned int index, GLfloat constant, GLfloat linear, GLfloat quadratic ) = 0;
501
502 /// Retrieves the light attenuation factors from the specified light.
503 /// \param[in] index Determines which light source to access.
504 /// \param[out] constant The constant attenuation factor is written to this parameter.
505 /// \param[out] linear The linear attenuation factor is written to this parameter.
506 /// \param[out] quadratic The quadratic attenuation factor is written to this parameter.
507 GLS_EXPORT virtual void GetLightAttenuation( unsigned int index, GLfloat& constant, GLfloat& linear, GLfloat& quadratic ) = 0;
508
509 /// \return The maximum number of clip planes supported by the current driver.
510 GLS_EXPORT virtual unsigned int GetMaxClipPlanes() = 0;
511
512 /// Updates the equation of a clip plane. The equation is set in local space and retrieved in eye space.
513 /// The retrieved value is different from the set value unless the modelview matrix is identity.
514 /// \param[in] index Determines which plane to access. This must be less than the GetMaxClipPlanes.
515 /// \param[in] equation The new equation that defines the plane. Four floats are used to define the plane. This is in local space.
516 GLS_EXPORT virtual void ClipPlanef( unsigned int index, float* equation ) = 0;
517
518 /// Retrieves the clip plane equation. This is retrieved in eye space, which may be different from the setter.
519 /// \param[in] index Determines which plane to access.
520 /// \param[out] equation The resulting equation that defines the associated plane is copied to this parameter. There must be four floats.
521 GLS_EXPORT virtual void GetClipPlanef( unsigned int index, float* equation ) = 0;
522
523 /// Activates the plane associated with the specified index.
524 /// \param[in] index Determines which plane to enable.
525 GLS_EXPORT virtual void EnableClipPlane( unsigned int index ) = 0;
526
527 /// Deactivates the plane associated with the specified index.
528 /// \param[in] index Determines which plane to disable.
529 GLS_EXPORT virtual void DisableClipPlane( unsigned int index ) = 0;
530
531 /// \param[in] index Determines which plane to check.
532 /// \return True if the plane associated with the specified index is enabled.
533 GLS_EXPORT virtual bool IsClipPlaneEnabled( unsigned int index ) = 0;
534
535 /// Equivalent to glDrawArrays call.
536 /// \param mode Primitive mode to draw ( GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, or GL_TRIANGLES ).
537 /// \param first Starting index in the enabled arrays.
538 /// \param count The number of indices to be rendered.
539 /// \pre mode must be GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, or GL_TRIANGLES.
540 /// \pre first >= 0.
541 /// \post (GLES20) updated shader program is selected if needed.
542 /// \post Primitives are drawn to GL.
543 GLS_EXPORT virtual void DrawArrays( const GLenum mode, const GLint first, const GLsizei count ) = 0;
544
545 /// Equivalent to glDrawElements call.
546 /// \param mode Primitive mode to draw ( GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, or GL_TRIANGLES ).
547 /// \param count The number of elements to be rendered.
548 /// \param type Specifies the type of the values in indices ( GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT ).
549 /// \param indices Pointer to the location where the indices are stored else an offset in bytes into the
550 /// the currently bound element array buffer.
551 /// \pre mode must be GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, or GL_TRIANGLES.
552 /// \pre type must be GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
553 /// \post (GLES20) updated shader program is selected if needed.
554 /// \post Primitives are drawn to GL.
555 GLS_EXPORT virtual void DrawElements( const GLenum mode, const GLsizei count, const GLenum type, const GLvoid* indices ) = 0;
556#endif
557
558 protected:
559 /** default ctor */
560 IGlsStateManager() {}
561
562 /** dtor is protected but virtual so that users cannot delete instances of it,
563 * but ScopedPtr can inside GlsGlobals.
564 */
565 virtual ~IGlsStateManager() {}
566 friend class ScopedPtr<IGlsStateManager>;
567};
568
569} // namespace disti
570
571#endif // DISTI_GLS_STATE_MANAGER_INTERFACE_H_INCLUDED
IFontImage.h
IFontImage.
disti::GlsColor
Definition: gls_color.h:54
disti::GlsMatrixAffine< double >
disti::IFontImage
Definition: IFontImage.h:54
disti::IGlsStateManager
Definition: gls_state_manager_interface.h:69
disti::IGlsStateManager::SetLightAttenuation
virtual void SetLightAttenuation(unsigned int index, GLfloat constant, GLfloat linear, GLfloat quadratic)=0
disti::IGlsStateManager::SetColor
virtual void SetColor(const glsColor &color)=0
disti::IGlsStateManager::LoadProjectionMatrixf
virtual void LoadProjectionMatrixf(const GlsMatrixType &m)=0
disti::IGlsStateManager::EmissionMaterial
virtual void EmissionMaterial(const glsColor &color)=0
disti::IGlsStateManager::SetLightPosition
virtual void SetLightPosition(unsigned int index, GLfloat *position)=0
disti::IGlsStateManager::SetSpotlightExponent
virtual void SetSpotlightExponent(unsigned int index, GLfloat exponent)=0
disti::IGlsStateManager::NormalPointer
virtual void NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)=0
disti::IGlsStateManager::GetLightPosition
virtual void GetLightPosition(unsigned int index, GLfloat *position)=0
disti::IGlsStateManager::DepthFunc
virtual void DepthFunc(GLenum func)=0
disti::IGlsStateManager::SetTextureMagFilter
virtual void SetTextureMagFilter(GLenum mode)=0
disti::IGlsStateManager::ShininessMaterial
virtual void ShininessMaterial(float shininess)=0
disti::IGlsStateManager::Normal3f
virtual void Normal3f(float x, float y, float z)=0
disti::IGlsStateManager::LightingEnabled
virtual void LightingEnabled(bool val)=0
disti::IGlsStateManager::DepthRange
virtual void DepthRange(GLfloat min, GLfloat max)=0
disti::IGlsStateManager::GetSpotlightDirection
virtual void GetSpotlightDirection(unsigned int index, GLfloat *direction)=0
disti::IGlsStateManager::PointSize
virtual void PointSize(float size)=0
disti::IGlsStateManager::ScaleTextureMatrixf
virtual void ScaleTextureMatrixf(GLfloat x, GLfloat y, GLfloat z)=0
disti::IGlsStateManager::DrawElements
virtual void DrawElements(const GLenum mode, const GLsizei count, const GLenum type, const GLvoid *indices)=0
disti::IGlsStateManager::MultModelViewMatrixf
virtual void MultModelViewMatrixf(const GlsMatrixType &m, const GLboolean pushMatrix)=0
disti::IGlsStateManager::BindTexture
virtual void BindTexture(IFontImage *texture)=0
disti::IGlsStateManager::SetTextureWrapS
virtual void SetTextureWrapS(GLenum mode)=0
disti::IGlsStateManager::AmbientMaterial
virtual void AmbientMaterial(const glsColor &color)=0
disti::IGlsStateManager::~IGlsStateManager
virtual ~IGlsStateManager()
Definition: gls_state_manager_interface.h:565
disti::IGlsStateManager::SetTextureBlendColor
virtual void SetTextureBlendColor(GLfloat *color)=0
disti::IGlsStateManager::IsClipPlaneEnabled
virtual bool IsClipPlaneEnabled(unsigned int index)=0
disti::IGlsStateManager::TexCoordPointer
virtual void TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)=0
disti::IGlsStateManager::IsLightSourceEnabled
virtual bool IsLightSourceEnabled(unsigned int index)=0
disti::IGlsStateManager::SpecularMaterial
virtual void SpecularMaterial(const glsColor &color)=0
disti::IGlsStateManager::SetDefaultAlphaBlendFunc
virtual void SetDefaultAlphaBlendFunc()=0
Sets the default blend function for GL Studio.
disti::IGlsStateManager::IGlsStateManager
IGlsStateManager()
Definition: gls_state_manager_interface.h:560
disti::IGlsStateManager::SetLightSpecularColor
virtual void SetLightSpecularColor(unsigned int index, GLfloat *color)=0
disti::IGlsStateManager::SetTextureEnvMode
virtual void SetTextureEnvMode(GLenum mode)=0
disti::IGlsStateManager::GetLightDiffuseColor
virtual void GetLightDiffuseColor(unsigned int index, GLfloat *color)=0
disti::IGlsStateManager::DiffuseMaterial
virtual void DiffuseMaterial(const glsColor &color)=0
disti::IGlsStateManager::SetSpotlightCutoff
virtual void SetSpotlightCutoff(unsigned int index, GLfloat cutoff)=0
disti::IGlsStateManager::TEXTURE_STACK_DEPTH
@ TEXTURE_STACK_DEPTH
Definition: gls_state_manager_interface.h:116
disti::IGlsStateManager::MATRIX_STACK_DEPTH
@ MATRIX_STACK_DEPTH
Definition: gls_state_manager_interface.h:114
disti::IGlsStateManager::CUSTOM_SHADER_PROGRAM_STACK_DEPTH
@ CUSTOM_SHADER_PROGRAM_STACK_DEPTH
Definition: gls_state_manager_interface.h:117
disti::IGlsStateManager::PROJECTION_STACK_DEPTH
@ PROJECTION_STACK_DEPTH
Definition: gls_state_manager_interface.h:115
disti::IGlsStateManager::GetSpotlightExponent
virtual GLfloat GetSpotlightExponent(unsigned int index)=0
disti::IGlsStateManager::ColorArrayEnabled
virtual void ColorArrayEnabled(bool val)=0
disti::IGlsStateManager::GouraudShadingEnabled
virtual void GouraudShadingEnabled(bool val)=0
disti::IGlsStateManager::AlphaTestFunc
virtual void AlphaTestFunc(GLenum func, GLfloat val)=0
disti::IGlsStateManager::PopModelViewMatrix
virtual void PopModelViewMatrix()=0
disti::IGlsStateManager::GetLightAttenuation
virtual void GetLightAttenuation(unsigned int index, GLfloat &constant, GLfloat &linear, GLfloat &quadratic)=0
disti::IGlsStateManager::PushModelViewMatrix
virtual void PushModelViewMatrix()=0
disti::IGlsStateManager::SetTextureMinFilter
virtual void SetTextureMinFilter(GLenum mode)=0
disti::IGlsStateManager::PushAlphaBlendFunc
virtual void PushAlphaBlendFunc()=0
Pushes the current alpha blend func onto an internal stack. Can restore the pushed alpha blend func b...
disti::IGlsStateManager::PopTextureMatrix
virtual void PopTextureMatrix()=0
disti::IGlsStateManager::AlphaBlendFuncSeparate
virtual void AlphaBlendFuncSeparate(GLenum srcColor, GLenum dstColor, GLenum srcAlpha, GLenum dstAlpha)=0
disti::IGlsStateManager::LoadModelViewMatrixf
virtual void LoadModelViewMatrixf(const GlsMatrixType &m)=0
disti::IGlsStateManager::AlphaTestEnabled
virtual void AlphaTestEnabled(bool val)=0
disti::IGlsStateManager::DepthMaskEnabled
virtual void DepthMaskEnabled(bool val)=0
disti::IGlsStateManager::GetLightSpecularColor
virtual void GetLightSpecularColor(unsigned int index, GLfloat *color)=0
disti::IGlsStateManager::NormalArrayEnabled
virtual void NormalArrayEnabled(bool val)=0
disti::IGlsStateManager::PushProjectionMatrix
virtual void PushProjectionMatrix()=0
disti::IGlsStateManager::DrawArrays
virtual void DrawArrays(const GLenum mode, const GLint first, const GLsizei count)=0
disti::IGlsStateManager::LoadModelViewIdentityMatrix
virtual void LoadModelViewIdentityMatrix()=0
Set the current model view matrix to the identity matrix.
disti::IGlsStateManager::IsLightingEnabled
virtual bool IsLightingEnabled()=0
disti::IGlsStateManager::DisableClipPlane
virtual void DisableClipPlane(unsigned int index)=0
disti::IGlsStateManager::ClipPlanef
virtual void ClipPlanef(unsigned int index, float *equation)=0
disti::IGlsStateManager::SetSpotlightDirection
virtual void SetSpotlightDirection(unsigned int index, GLfloat *direction)=0
disti::IGlsStateManager::DeleteTexture
virtual void DeleteTexture(IFontImage *texture)=0
disti::IGlsStateManager::ColorPointer
virtual void ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)=0
disti::IGlsStateManager::GetClipPlanef
virtual void GetClipPlanef(unsigned int index, float *equation)=0
disti::IGlsStateManager::LoadTextureMatrixf
virtual void LoadTextureMatrixf(const GlsMatrixType &m)=0
disti::IGlsStateManager::LoadProjectionIdentityMatrix
virtual void LoadProjectionIdentityMatrix()=0
disti::IGlsStateManager::LoadTextureIdentityMatrix
virtual void LoadTextureIdentityMatrix()=0
Sets the current texture matrix to the identity matrix.
disti::IGlsStateManager::DepthTestEnabled
virtual void DepthTestEnabled(bool val)=0
disti::IGlsStateManager::TextureArrayEnabled
virtual void TextureArrayEnabled(bool val)=0
disti::IGlsStateManager::LineWidth
virtual void LineWidth(float width)=0
disti::IGlsStateManager::PopProjectionMatrix
virtual void PopProjectionMatrix()=0
disti::IGlsStateManager::TranslateModelViewMatrixf
virtual void TranslateModelViewMatrixf(GLfloat x, GLfloat y, GLfloat z)=0
disti::IGlsStateManager::GetMaxClipPlanes
virtual unsigned int GetMaxClipPlanes()=0
disti::IGlsStateManager::IsDepthMaskEnabled
virtual bool IsDepthMaskEnabled()=0
disti::IGlsStateManager::SetLightAmbientColor
virtual void SetLightAmbientColor(unsigned int index, GLfloat *color)=0
disti::IGlsStateManager::VertexArrayEnabled
virtual void VertexArrayEnabled(bool val)=0
disti::IGlsStateManager::VertexPointer
virtual void VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)=0
disti::IGlsStateManager::AlphaBlendFunc
virtual void AlphaBlendFunc(GLenum src, GLenum dst)=0
disti::IGlsStateManager::GetLightAmbientColor
virtual void GetLightAmbientColor(unsigned int index, GLfloat *color)=0
disti::IGlsStateManager::EnableClipPlane
virtual void EnableClipPlane(unsigned int index)=0
disti::IGlsStateManager::SetDefaultState
virtual void SetDefaultState(bool forceResetUnmanagedState=false)=0
disti::IGlsStateManager::Texture2DEnabled
virtual void Texture2DEnabled(bool val)=0
disti::IGlsStateManager::PushTextureMatrix
virtual void PushTextureMatrix()=0
disti::IGlsStateManager::LineStipple
virtual void LineStipple(unsigned short pattern, unsigned int multiplier)=0
disti::IGlsStateManager::TranslateTextureMatrixf
virtual void TranslateTextureMatrixf(GLfloat x, GLfloat y, GLfloat z)=0
disti::IGlsStateManager::GetSpotlightCutoff
virtual GLfloat GetSpotlightCutoff(unsigned int index)=0
disti::IGlsStateManager::BindIndexBuffer
virtual void BindIndexBuffer(unsigned int handle)=0
disti::IGlsStateManager::AlphaBlendEnabled
virtual void AlphaBlendEnabled(bool val)=0
disti::IGlsStateManager::BackfaceCullingEnabled
virtual void BackfaceCullingEnabled(bool val)=0
disti::IGlsStateManager::LineSmoothEnabled
virtual void LineSmoothEnabled(bool val)=0
disti::IGlsStateManager::GetMaxNumLights
virtual unsigned int GetMaxNumLights()=0
disti::IGlsStateManager::PopAlphaBlendFunc
virtual void PopAlphaBlendFunc()=0
Pops the previously pushed alpha blend func from the stack and restores its state to the opengl conte...
disti::IGlsStateManager::BindVertexBuffer
virtual void BindVertexBuffer(unsigned int handle)=0
disti::IGlsStateManager::SetLightDiffuseColor
virtual void SetLightDiffuseColor(unsigned int index, GLfloat *color)=0
disti::IGlsStateManager::SetLightEnabled
virtual void SetLightEnabled(unsigned int index, bool enabled)=0
disti::IGlsStateManager::SetTextureWrapT
virtual void SetTextureWrapT(GLenum mode)=0
disti::IGlsStateManager::ActiveTexture
virtual void ActiveTexture(GLenum textureUnit)=0
disti::IGlsStateManager::GetMaximumLineWidth
virtual float GetMaximumLineWidth()=0
disti::NonCopyable
Definition: non_copyable.h:47
disti::ScopedPtr
Definition: scoped_ptr.h:54
gls_color.h
The Color class: Implements a 4 component RGBA color.
gls_gl.h
The gls_gl.
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
gls_matrix_affine.h
The GlsMatrixAffine class.
disti
Definition: bmpimage.h:47
non_copyable.h
A base class for objects that are not copyable via the standard C++ copy constructor.
scoped_ptr.h
A smart pointer with unique ownership – poor man's std::unique_ptr.