SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
Singleton class holding all OpenGL states. More...
#include <SLGLState.h>
Static Public Member Functions | |
static SLGLState * | instance () |
Public static instance getter for singleton pattern. More... | |
static void | deleteInstance () |
global destruction More... | |
static void | getGLError (const char *file, int line, bool quit) |
Checks if an OpenGL error occurred. More... | |
Public Attributes | |
SLMat4f | modelMatrix |
Init all states. More... | |
SLMat4f | projectionMatrix |
matrix for projection transform More... | |
SLMat4f | viewMatrix |
matrix for the active cameras view transform More... | |
SLMat4f | textureMatrix |
matrix for the texture transform More... | |
Private Member Functions | |
SLGLState () | |
private onetime constructor More... | |
~SLGLState () | |
destruction in ~SLScene More... | |
Private Attributes | |
SLbool | _isInitialized |
flag for first init More... | |
SLstring | _glVersion |
OpenGL Version string. More... | |
SLstring | _glVersionNO |
OpenGL Version number string. More... | |
SLfloat | _glVersionNOf |
OpenGL Version number as float. More... | |
SLstring | _glVendor |
OpenGL Vendor string. More... | |
SLstring | _glRenderer |
OpenGL Renderer string. More... | |
SLstring | _glSLVersion |
GLSL Version string. More... | |
SLstring | _glSLVersionNO |
GLSL Version number string. More... | |
SLstring | _glExtensions |
OpenGL extensions string. More... | |
SLbool | _glIsES2 |
Flag if OpenGL ES2. More... | |
SLbool | _glIsES3 |
Flag if OpenGL ES3. More... | |
SLint | _glMaxTexUnits |
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_glMaxTexUnits); More... | |
SLint | _glMaxTexSize |
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_glMaxTexSize); More... | |
SLbool | _blend |
blending default false; More... | |
SLenum | _blendFuncSfactor |
blend function source factor enum More... | |
SLenum | _blendFuncDfactor |
blend function destination factor enum More... | |
SLbool | _depthTest |
GL_DEPTH_TEST state. More... | |
SLbool | _depthMask |
glDepthMask state More... | |
SLenum | _depthFunc |
depth buffer comparison function More... | |
SLbool | _cullFace |
Face culling state. More... | |
SLbool | _multisample |
Multisampling state. More... | |
SLint | _multiSampleSamples |
NO. of multisampling samples. More... | |
SLbool | _polygonLine |
Line polygon state. More... | |
SLbool | _polygonOffsetPointEnabled |
GL_POLYGON_OFFSET_POINT state enabled. More... | |
SLbool | _polygonOffsetLineEnabled |
GL_POLYGON_OFFSET_LINE state enabled. More... | |
SLbool | _polygonOffsetFillEnabled |
GL_POLYGON_OFFSET_FILL state enabled. More... | |
SLVec4i | _viewport |
viewport size (x,y,w,h) of the framebuffer More... | |
SLCol4f | _clearColor |
clear color More... | |
SLuint | _programID |
current shader program id More... | |
SLenum | _textureUnit |
current texture unit More... | |
SLenum | _textureTarget |
current texture target More... | |
SLuint | _textureID |
current texture id More... | |
GLboolean | _colorMaskR |
current color mask for R More... | |
GLboolean | _colorMaskG |
current color mask for G More... | |
GLboolean | _colorMaskB |
current color mask for B More... | |
GLboolean | _colorMaskA |
current color mask for A More... | |
SLVstring | errorTexts |
vector for error texts collected in getGLError More... | |
SLVlong | errorCounts |
vector for counts for the corresponding errorTexts More... | |
SLMaterial * | _currentMaterial |
Static Private Attributes | |
static SLGLState * | _instance = nullptr |
global singleton object More... | |
Singleton class holding all OpenGL states.
The main purpose of the SLGLState class is to replace all the OpenGL states and functionality that has been removed from the core profile of OpenGL. The core profile started from OpenGL version 3.0 has e.g. no more internal matrices, lighting or material states. It also has no more fixed function pipeline on the GPU witch means, that core profile OpenGL only works with custom shader programs written in OpenGL Shading Language (GLSL). The second purpose is to concentrate OpenGL functionality and to reduce redundant state changes.
Definition at line 70 of file SLGLState.h.
|
private |
private onetime constructor
Private constructor should be called only once for a singleton class.
Definition at line 35 of file SLGLState.cpp.
|
private |
destruction in ~SLScene
The destructor only empties the stacks
Definition at line 123 of file SLGLState.cpp.
SLGLState::activeTexture sets the current active texture unit
Definition at line 445 of file SLGLState.cpp.
SLGLState::bindTexture sets the current active texture.
Definition at line 423 of file SLGLState.cpp.
|
inline |
Definition at line 126 of file SLGLState.h.
SLGLState::blend enables or disables alpha blending but only if the state really changes.
Definition at line 236 of file SLGLState.cpp.
Sets new blend function source and destination factors.
Definition at line 250 of file SLGLState.cpp.
Definition at line 157 of file SLGLState.cpp.
|
inline |
Definition at line 121 of file SLGLState.h.
|
inline |
Definition at line 123 of file SLGLState.h.
|
inline |
Definition at line 122 of file SLGLState.h.
void SLGLState::colorMask | ( | GLboolean | r, |
GLboolean | g, | ||
GLboolean | b, | ||
GLboolean | a | ||
) |
SLGLState::colorMask sets the OpenGL colorMask for framebuffer masking
Definition at line 394 of file SLGLState.cpp.
SLGLState::cullFace sets the GL_CULL_FACE state but only if the state really changes. If face culling is turned on no back faces are processed.
Definition at line 219 of file SLGLState.cpp.
|
inline |
Definition at line 152 of file SLGLState.h.
|
inline |
Definition at line 120 of file SLGLState.h.
|
static |
SLGLState::depthFunc specifies the depth comparison function. Symbolic constants GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, and GL_ALWAYS are accepted. The initial value is GL_LESS.
Definition at line 205 of file SLGLState.cpp.
SLGLState::depthTest enables or disables depth buffer writing but only if the state really changes. Turning on depth masking freezes the depth test but keeps all values in the depth buffer.
Definition at line 190 of file SLGLState.cpp.
SLGLState::depthTest enables or disables depth testing but only if the state really changes. The depth test decides for each pixel in the depth buffer which polygon is the closest to the eye.
Definition at line 172 of file SLGLState.cpp.
|
static |
Checks if an OpenGL error occurred.
Definition at line 484 of file SLGLState.cpp.
SLstring SLGLState::getGLVersionNO | ( | ) |
Returns the OpenGL version number as a string.
The string returned by glGetString can contain additional vendor information such as the build number and the brand name. For the OpenGL version string "4.5.0 NVIDIA 347.68" the function returns "4.5"
Definition at line 552 of file SLGLState.cpp.
SLstring SLGLState::getSLVersionNO | ( | ) |
Returns the OpenGL Shading Language version number as a string.
The string returned by glGetString can contain additional vendor information such as the build number and the brand name. For the shading language string "Nvidia GLSL 4.5" the function returns "450"
Definition at line 575 of file SLGLState.cpp.
|
inline |
Definition at line 139 of file SLGLState.h.
|
inline |
Definition at line 134 of file SLGLState.h.
|
inline |
Definition at line 135 of file SLGLState.h.
|
inline |
Definition at line 136 of file SLGLState.h.
|
inline |
Definition at line 138 of file SLGLState.h.
|
inline |
Definition at line 137 of file SLGLState.h.
|
inline |
Definition at line 131 of file SLGLState.h.
|
inline |
Definition at line 132 of file SLGLState.h.
|
inline |
Definition at line 133 of file SLGLState.h.
|
inline |
Definition at line 130 of file SLGLState.h.
|
inline |
Definition at line 127 of file SLGLState.h.
|
inline |
Definition at line 128 of file SLGLState.h.
|
inline |
Definition at line 129 of file SLGLState.h.
Definition at line 141 of file SLGLState.h.
|
inline |
Definition at line 95 of file SLGLState.h.
void SLGLState::initAll | ( | ) |
Initializes all states.
Definition at line 42 of file SLGLState.cpp.
|
inlinestatic |
SLGLState::multiSample enables or disables multisampling but only if the state really changes. Multisampling turns on fullscreen anti aliasing on the GPU witch produces smooth polygon edges, lines and points.
Definition at line 267 of file SLGLState.cpp.
Returns true if the according GL pixel format is valid in the GL context.
Definition at line 588 of file SLGLState.cpp.
SLGLState::polygonMode sets the polygonMode to GL_LINE but only if the state really changes. OpenGL ES doesn't support glPolygonMode. It has to be mimicked with GL_LINE_LOOP drawing.
Definition at line 290 of file SLGLState.cpp.
SLGLState::polygonOffsetFill turns on/off polygon offset for filled polygons and sets the factor and unit for glPolygonOffset but only if the state really changes. Polygon offset is used to reduce z-fighting due to parallel planes or lines. See: http://www.zeuscmd.com/tutorials/opengl/15-PolygonOffset.php
Definition at line 359 of file SLGLState.cpp.
SLGLState::polygonOffsetLine turns on/off polygon offset for lines and sets the factor and unit for glPolygonOffset but only if the state really changes. Polygon offset is used to reduce z-fighting due to parallel planes or lines. See: http://www.zeuscmd.com/tutorials/opengl/15-PolygonOffset.php
Definition at line 335 of file SLGLState.cpp.
void SLGLState::polygonOffsetPoint | ( | SLbool | enabled, |
SLfloat | factor = -1.0f , |
||
SLfloat | units = -1.0f |
||
) |
SLGLState::polygonOffsetPoint turns on/off polygon offset for points and sets the factor and unit for glPolygonOffset but only if the state really changes. Polygon offset is used to reduce z-fighting due to parallel planes or lines. See: http://www.zeuscmd.com/tutorials/opengl/15-PolygonOffset.php
Definition at line 311 of file SLGLState.cpp.
Reads the front framebuffer pixels into the passed buffer.
buffer | Pointer to a 4 byte aligned buffer with the correct size. |
Definition at line 639 of file SLGLState.cpp.
void SLGLState::unbindAnythingAndFlush | ( | ) |
finishes all GL commands
SLGLState::unbindAnythingAndFlush unbinds all shaderprograms and buffers in use and calls glFinish. This should be the last call to GL before buffer swapping.
Definition at line 465 of file SLGLState.cpp.
SLGLState::useProgram sets the _rent active shader program
Definition at line 410 of file SLGLState.cpp.
|
inline |
Definition at line 142 of file SLGLState.h.
SLGLState::viewport sets the OpenGL viewport position and size
Definition at line 378 of file SLGLState.cpp.
|
inline |
Definition at line 143 of file SLGLState.h.
|
private |
blending default false;
Definition at line 182 of file SLGLState.h.
|
private |
blend function destination factor enum
Definition at line 184 of file SLGLState.h.
|
private |
blend function source factor enum
Definition at line 183 of file SLGLState.h.
|
private |
clear color
Definition at line 196 of file SLGLState.h.
|
private |
current color mask for A
Definition at line 206 of file SLGLState.h.
|
private |
current color mask for B
Definition at line 205 of file SLGLState.h.
|
private |
current color mask for G
Definition at line 204 of file SLGLState.h.
|
private |
current color mask for R
Definition at line 203 of file SLGLState.h.
|
private |
Face culling state.
Definition at line 188 of file SLGLState.h.
|
private |
Definition at line 211 of file SLGLState.h.
|
private |
depth buffer comparison function
Definition at line 187 of file SLGLState.h.
|
private |
glDepthMask state
Definition at line 186 of file SLGLState.h.
|
private |
GL_DEPTH_TEST state.
Definition at line 185 of file SLGLState.h.
|
private |
OpenGL extensions string.
Definition at line 175 of file SLGLState.h.
|
private |
Flag if OpenGL ES2.
Definition at line 176 of file SLGLState.h.
|
private |
Flag if OpenGL ES3.
Definition at line 177 of file SLGLState.h.
|
private |
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_glMaxTexSize);
Definition at line 179 of file SLGLState.h.
|
private |
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_glMaxTexUnits);
Definition at line 178 of file SLGLState.h.
|
private |
OpenGL Renderer string.
Definition at line 172 of file SLGLState.h.
|
private |
GLSL Version string.
Definition at line 173 of file SLGLState.h.
|
private |
GLSL Version number string.
Definition at line 174 of file SLGLState.h.
|
private |
OpenGL Vendor string.
Definition at line 171 of file SLGLState.h.
|
private |
OpenGL Version string.
Definition at line 168 of file SLGLState.h.
|
private |
OpenGL Version number string.
Definition at line 169 of file SLGLState.h.
|
private |
OpenGL Version number as float.
Definition at line 170 of file SLGLState.h.
|
staticprivate |
global singleton object
Definition at line 164 of file SLGLState.h.
|
private |
flag for first init
Definition at line 166 of file SLGLState.h.
|
private |
Multisampling state.
Definition at line 189 of file SLGLState.h.
|
private |
NO. of multisampling samples.
Definition at line 190 of file SLGLState.h.
|
private |
Line polygon state.
Definition at line 191 of file SLGLState.h.
|
private |
GL_POLYGON_OFFSET_FILL state enabled.
Definition at line 194 of file SLGLState.h.
|
private |
GL_POLYGON_OFFSET_LINE state enabled.
Definition at line 193 of file SLGLState.h.
|
private |
GL_POLYGON_OFFSET_POINT state enabled.
Definition at line 192 of file SLGLState.h.
|
private |
current shader program id
Definition at line 199 of file SLGLState.h.
|
private |
current texture id
Definition at line 202 of file SLGLState.h.
|
private |
current texture target
Definition at line 201 of file SLGLState.h.
|
private |
current texture unit
Definition at line 200 of file SLGLState.h.
|
private |
viewport size (x,y,w,h) of the framebuffer
Definition at line 195 of file SLGLState.h.
|
private |
vector for counts for the corresponding errorTexts
Definition at line 209 of file SLGLState.h.
|
private |
vector for error texts collected in getGLError
Definition at line 208 of file SLGLState.h.
SLMat4f SLGLState::modelMatrix |
SLMat4f SLGLState::projectionMatrix |
matrix for projection transform
Definition at line 90 of file SLGLState.h.
SLMat4f SLGLState::textureMatrix |
matrix for the texture transform
Definition at line 92 of file SLGLState.h.
SLMat4f SLGLState::viewMatrix |
matrix for the active cameras view transform
Definition at line 91 of file SLGLState.h.