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