PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureGLsnippets Class Reference

Pure useful functions for OpenGL. More...

Detailed Description

Pure useful functions for OpenGL.

Definition at line 22 of file PureGLsnippets.h.

#include <PureGLsnippets.h>

Static Public Member Functions

static void Init ()
 Initialize static class instance.
 
static const char * getGLErrorTextFromEnum (GLenum err)
 Gets the string representation of the given GL error.
 
static TPureBool isGLErrorPresent ()
 Gets whether there is an error in OpenGL or not.
 
static GLenum getLastSavedGLError ()
 Gets the last saved GL error.
 
static void ClearGLError ()
 Clears GL error state.
 
static TPureUInt getSizeofIndexType (GLenum iType)
 Returns the size in Bytes of the given OpenGL index type.
 
static TPureUInt getVertexIndex (const void *arr, TPureUInt index, GLenum iType)
 Returns arr[index] element from the given array of iType type elements.
 
static TPureBool setVertexIndex (void *arr, TPureUInt index, TPureUInt value, GLenum iType)
 Sets arr[index] element of the given array of iType type elements to value.
 
static void SetGLBoundingBoxRendering (TPureBool state)
 Sets GL states up for bounding box rendering or resets them.
 
static void glPrepareBeforeDrawBoundingBox ()
 
static void SetZPassRendering (TPureBool state)
 
static TPURE_BLENDFACTOR getPureBlendFromGLBlend (GLenum glb)
 Gets the appropriate Pure blend factor for the given GL enum.
 
static GLenum getGLBlendFromPureBlend (TPURE_BLENDFACTOR bf)
 Gets the appropriate GL enum for the given Pure blend factor.
 
static void glLoadTextureIntoTMU (const PureTexture *tex, TPureUInt iTMU, TPureBool bSticked)
 Loads the given texture into the texture mapping unit.
 
static void glLoadTexturesAndSetBlendState (const PureMaterial *mat, TPureBool bObjLevel1Sticked, TPureBool bObjLevel1Blended)
 Loads all textures into texture mapping units and sets blending if needed for single-pass multitexturing.
 

Static Private Attributes

static const char *const GL_ERR_STR_NO_ERROR = "No Error"
 
static const char *const GL_ERR_STR_INVALID_ENUM = "Invalid Enum"
 
static const char *const GL_ERR_STR_INVALID_VALUE = "Invalid Value"
 
static const char *const GL_ERR_STR_INVALID_OPERATION = "Invalid Operation"
 
static const char *const GL_ERR_STR_STACK_OVERFLOW = "Stack Overflow"
 
static const char *const GL_ERR_STR_STACK_UNDERFLOW = "Stack Underflow"
 
static const char *const GL_ERR_STR_OUT_OF_MEMORY = "Out of Memory"
 
static GLenum errLast = GL_NO_ERROR
 
static std::vector< GLuint > iLastTex
 Last loaded texture in TMU, where vector elem 0 is for TMU0, elem 1 is for TMU1 and so on ...
 

Member Function Documentation

◆ ClearGLError()

void PureGLsnippets::ClearGLError ( )
static

Clears GL error state.

Clears OpenGL error state.

Error code is not saved, so this function has no impact on return code of getLastSavedGLError().

Definition at line 90 of file PureGLsnippets.cpp.

◆ getGLBlendFromPureBlend()

GLenum PureGLsnippets::getGLBlendFromPureBlend ( TPURE_BLENDFACTOR bf)
static

Gets the appropriate GL enum for the given Pure blend factor.

Returns
The appropriate GL enum for the given Pure blend factor. GL_ZERO for invalid Pure blend factor.

Definition at line 256 of file PureGLsnippets.cpp.

◆ getGLErrorTextFromEnum()

const char * PureGLsnippets::getGLErrorTextFromEnum ( GLenum err)
static

Gets the string representation of the given GL error.

Parameters
errOpenGL error code. These are defined in GL.h.
Returns
A string representing the given GL error.

Definition at line 44 of file PureGLsnippets.cpp.

◆ getLastSavedGLError()

GLenum PureGLsnippets::getLastSavedGLError ( )
static

Gets the last saved GL error.

Gets the last saved OpenGL error.

The last saved OpenGL error code is GL_NO_ERROR by default so it is recommended to call isGLErrorPresent() first.

Returns
The last OpenGL error code saved by isGLErrorPresent().

Definition at line 80 of file PureGLsnippets.cpp.

◆ getPureBlendFromGLBlend()

TPURE_BLENDFACTOR PureGLsnippets::getPureBlendFromGLBlend ( GLenum glb)
static

Gets the appropriate Pure blend factor for the given GL enum.

Returns
The appropriate Pure blend factor for the given GL enum. PURE_ZERO for invalid GL enum.

Definition at line 230 of file PureGLsnippets.cpp.

◆ getSizeofIndexType()

TPureUInt PureGLsnippets::getSizeofIndexType ( GLenum iType)
static

Returns the size in Bytes of the given OpenGL index type.

Useful when allocating index/element buffer/array for a specific index type.

Returns
Size in Bytes of the given OpenGL index type.

Definition at line 102 of file PureGLsnippets.cpp.

◆ getVertexIndex()

TPureUInt PureGLsnippets::getVertexIndex ( const void * arr,
TPureUInt index,
GLenum iType )
static

Returns arr[index] element from the given array of iType type elements.

Useful when the size of an index/element buffer/array is not known at compilation time, but we want to minimize its total size at runtime, thus we allocate its size based on the required element type selected at runtime.

Returns
An iType type element from arr[index] position, casted to TPureUInt.

Definition at line 120 of file PureGLsnippets.cpp.

◆ glLoadTextureIntoTMU()

void PureGLsnippets::glLoadTextureIntoTMU ( const PureTexture * tex,
TPureUInt iTMU,
TPureBool bSticked )
static

Loads the given texture into the texture mapping unit.

Parameters
texTexture to be loaded. If NULL, texturing will be disabled on the specified texture mapping unit.
iTMUInto which texture mapping unit we want to load the texture. Currently it must be either 0 or 1.
bStickedTrue if object is sticked to screen, false otherwise.

Definition at line 283 of file PureGLsnippets.cpp.

◆ glLoadTexturesAndSetBlendState()

void PureGLsnippets::glLoadTexturesAndSetBlendState ( const PureMaterial * mat,
TPureBool bObjLevel1Sticked,
TPureBool bObjLevel1Blended )
static

Loads all textures into texture mapping units and sets blending if needed for single-pass multitexturing.

This function is called per subobject. So if this is buggy, then it can cause problems around blending: even though level-1 object set blending state properly, this one may accidentally change it if it messes up some checks around multitexturing and such, this is also a reason why it must be aware of the blending state of the subobject's level-1 parent object!

Parameters
matMaterial from where textures should be loaded. If it is PGENULL, texturing will be disabled.
bObjLevel1StickedTrue if the manager Object3D is sticked to screen, false otherwise.
bObjLevel1BlendedTrue if the manager Object3D's material is blended, false otherwise.

Definition at line 344 of file PureGLsnippets.cpp.

◆ glPrepareBeforeDrawBoundingBox()

void PureGLsnippets::glPrepareBeforeDrawBoundingBox ( )
static

Definition at line 192 of file PureGLsnippets.cpp.

◆ Init()

void PureGLsnippets::Init ( )
static

Initialize static class instance.

Definition at line 28 of file PureGLsnippets.cpp.

◆ isGLErrorPresent()

TPureBool PureGLsnippets::isGLErrorPresent ( )
static

Gets whether there is an error in OpenGL or not.

The error gets saved by this function and can be further evaluated later by calling getLastSavedGLError(). OpenGL error state is also cleared.

Returns
True if there is an OpenGL error, false otherwise.

Definition at line 67 of file PureGLsnippets.cpp.

◆ SetGLBoundingBoxRendering()

void PureGLsnippets::SetGLBoundingBoxRendering ( TPureBool state)
static

Sets GL states up for bounding box rendering or resets them.

Parameters
stateIf true, GL states are set for bounding box rendering. If false, some states are reset for normal rendering (rest of states are controlled by Object3D in such case).

Definition at line 169 of file PureGLsnippets.cpp.

◆ setVertexIndex()

TPureBool PureGLsnippets::setVertexIndex ( void * arr,
TPureUInt index,
TPureUInt value,
GLenum iType )
static

Sets arr[index] element of the given array of iType type elements to value.

If the given value doesn't fit into given iType element type, an error message will be logged to console and no change to array will be done.

Returns
True on success, false otherwise.

Definition at line 137 of file PureGLsnippets.cpp.

◆ SetZPassRendering()

void PureGLsnippets::SetZPassRendering ( TPureBool state)
static

Definition at line 204 of file PureGLsnippets.cpp.

Member Data Documentation

◆ errLast

GLenum PureGLsnippets::errLast = GL_NO_ERROR
staticprivate

Definition at line 59 of file PureGLsnippets.h.

◆ GL_ERR_STR_INVALID_ENUM

const char *const PureGLsnippets::GL_ERR_STR_INVALID_ENUM = "Invalid Enum"
staticprivate

Definition at line 52 of file PureGLsnippets.h.

◆ GL_ERR_STR_INVALID_OPERATION

const char *const PureGLsnippets::GL_ERR_STR_INVALID_OPERATION = "Invalid Operation"
staticprivate

Definition at line 54 of file PureGLsnippets.h.

◆ GL_ERR_STR_INVALID_VALUE

const char *const PureGLsnippets::GL_ERR_STR_INVALID_VALUE = "Invalid Value"
staticprivate

Definition at line 53 of file PureGLsnippets.h.

◆ GL_ERR_STR_NO_ERROR

const char *const PureGLsnippets::GL_ERR_STR_NO_ERROR = "No Error"
staticprivate

Definition at line 51 of file PureGLsnippets.h.

◆ GL_ERR_STR_OUT_OF_MEMORY

const char *const PureGLsnippets::GL_ERR_STR_OUT_OF_MEMORY = "Out of Memory"
staticprivate

Definition at line 57 of file PureGLsnippets.h.

◆ GL_ERR_STR_STACK_OVERFLOW

const char *const PureGLsnippets::GL_ERR_STR_STACK_OVERFLOW = "Stack Overflow"
staticprivate

Definition at line 55 of file PureGLsnippets.h.

◆ GL_ERR_STR_STACK_UNDERFLOW

const char *const PureGLsnippets::GL_ERR_STR_STACK_UNDERFLOW = "Stack Underflow"
staticprivate

Definition at line 56 of file PureGLsnippets.h.

◆ iLastTex

std::vector< GLuint > PureGLsnippets::iLastTex
staticprivate

Last loaded texture in TMU, where vector elem 0 is for TMU0, elem 1 is for TMU1 and so on ...

Definition at line 61 of file PureGLsnippets.h.


The documentation for this class was generated from the following files: