16 #if defined(SL_OS_MACIOS)
17 # include <OpenGLES/ES3/gl.h>
18 # include <OpenGLES/ES3/glext.h>
19 #elif defined(SL_OS_MACOS)
21 #elif defined(SL_OS_ANDROID)
23 # include <GLES3/gl3.h>
24 # include <GLES2/gl2ext.h>
25 # ifndef GL_CLAMP_TO_BORDER
26 # define GL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER_OES
30 #elif defined(SL_OS_WINDOWS)
32 #elif defined(SL_OS_LINUX)
34 #elif defined(SL_EMSCRIPTEN)
35 # include <GLES3/gl3.h>
37 # error "SL has not been ported to this OS"
53 #if (defined(DEBUG) || defined(_DEBUG)) && !defined(SL_EMSCRIPTEN)
54 # define GET_GL_ERROR SLGLState::getGLError((const char*)__FILE__, __LINE__, false)
115 void colorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a);
155 static void getGLError(
const char* file,
int line,
bool quit);
vector< SLstring > SLVstring
static const SLint SL_MAX_LIGHTS
max. number of used lights
Drawing states stored in the bits of an unsigned int.
Singleton class holding all OpenGL states.
void clearColor(const SLCol4f &c)
static void deleteInstance()
global destruction
SLMaterial * currentMaterial()
static SLGLState * _instance
global singleton object
SLbool _depthMask
glDepthMask state
SLMat4f textureMatrix
matrix for the texture transform
SLVec4i _viewport
viewport size (x,y,w,h) of the framebuffer
void activeTexture(SLenum textureUnit)
SLuint _textureID
current texture id
SLMat4f modelMatrix
Init all states.
void polygonOffsetPoint(SLbool enabled, SLfloat factor=-1.0f, SLfloat units=-1.0f)
void depthMask(SLbool state)
SLCol4f _clearColor
clear color
SLbool _depthTest
GL_DEPTH_TEST state.
void multiSample(SLbool state)
static SLGLState * instance()
Public static instance getter for singleton pattern.
void polygonOffsetLine(SLbool enabled, SLfloat factor=-1.0f, SLfloat units=-1.0f)
~SLGLState()
destruction in ~SLScene
SLGLState()
private onetime constructor
SLbool _multisample
Multisampling state.
SLbool _isInitialized
flag for first init
SLbool _glIsES2
Flag if OpenGL ES2.
SLMat4f viewMatrix
matrix for the active cameras view transform
SLstring _glSLVersion
GLSL Version string.
void unbindAnythingAndFlush()
finishes all GL commands
SLVstring errorTexts
vector for error texts collected in getGLError
SLenum _textureTarget
current texture target
GLboolean _colorMaskA
current color mask for A
SLenum _blendFuncSfactor
blend function source factor enum
void blendFunc(SLenum blendFuncSFactor, SLenum blendFuncDFactor)
Sets new blend function source and destination factors.
void colorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a)
SLbool hasExtension(const SLstring &e)
SLenum _blendFuncDfactor
blend function destination factor enum
SLstring getSLVersionNO()
Returns the OpenGL Shading Language version number as a string.
SLstring _glVendor
OpenGL Vendor string.
GLboolean _colorMaskR
current color mask for R
SLstring _glVersionNO
OpenGL Version number string.
SLstring _glSLVersionNO
GLSL Version number string.
SLstring _glExtensions
OpenGL extensions string.
SLbool _polygonOffsetFillEnabled
GL_POLYGON_OFFSET_FILL state enabled.
SLstring _glRenderer
OpenGL Renderer string.
SLbool _blend
blending default false;
SLint glMaxTexUnits() const
SLbool _polygonOffsetLineEnabled
GL_POLYGON_OFFSET_LINE state enabled.
SLbool glHasGeometryShaders() const
SLstring getGLVersionNO()
Returns the OpenGL version number as a string.
SLenum _textureUnit
current texture unit
bool hasMultiSampling() const
SLint _glMaxTexUnits
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_glMaxTexUnits);
SLbool pixelFormatIsSupported(SLint pixelFormat)
Returns true if the according GL pixel format is valid in the GL context.
void depthFunc(SLenum func)
SLbool _polygonOffsetPointEnabled
GL_POLYGON_OFFSET_POINT state enabled.
SLfloat glVersionNOf() const
SLenum _depthFunc
depth buffer comparison function
void bindTexture(SLenum target, SLuint textureID)
SLfloat _glVersionNOf
OpenGL Version number as float.
static void getGLError(const char *file, int line, bool quit)
Checks if an OpenGL error occurred.
void polygonOffsetFill(SLbool enabled, SLfloat factor=-1.0f, SLfloat units=-1.0f)
SLbool _glIsES3
Flag if OpenGL ES3.
void onInitialize(const SLCol4f &clearColor)
On init GL.
SLbool _polygonLine
Line polygon state.
SLMat4f projectionMatrix
matrix for projection transform
SLVlong errorCounts
vector for counts for the corresponding errorTexts
SLstring _glVersion
OpenGL Version string.
void useProgram(SLuint progID)
SLMaterial * _currentMaterial
void polygonLine(SLbool state)
SLint _glMaxTexSize
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_glMaxTexSize);
SLbool _cullFace
Face culling state.
SLint _multiSampleSamples
NO. of multisampling samples.
void readPixels(void *buffer)
Reads the front framebuffer pixels into the passed buffer.
void clearColorDepthBuffer()
GLboolean _colorMaskB
current color mask for B
SLint glMaxTexSize() const
void currentMaterial(SLMaterial *mat)
GLboolean _colorMaskG
current color mask for G
void cullFace(SLbool state)
void depthTest(SLbool state)
SLuint _programID
current shader program id
void viewport(T x, T y, T ww, T wh, T n=0.0f, T f=1.0f)
Defines the viewport matrix.
Defines a standard CG material with textures and a shader program.