OpenGL State Helper

group FnGLStateHelper

Enums

enum Bit

Each client is responsible for setting up their own renderstate before submitting draw jobs. Often a client will need to temporarily change state for their purpose. The purpose of GLStateRestore is to provide a RAII mechanism to do this. The various bits to restore.

See
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glPushAttrib.xml

Values:

Enable = GL_ENABLE_BIT
AccumuBuffer = GL_ACCUM_BUFFER_BIT
ColorBuffer = GL_COLOR_BUFFER_BIT
Current = GL_CURRENT_BIT
DepthBuffer = GL_DEPTH_BUFFER_BIT
Eval = GL_EVAL_BIT
Fog = GL_FOG_BIT
Hint = GL_HINT_BIT
Lighting = GL_LIGHTING_BIT
Line = GL_LINE_BIT
List = GL_LIST_BIT
Multisample = GL_MULTISAMPLE_BIT
PixelMode = GL_PIXEL_MODE_BIT
Point = GL_POINT_BIT
Polygon = GL_POLYGON_BIT
PolygonStipple = GL_POLYGON_STIPPLE_BIT
Scissor = GL_SCISSOR_BIT
StencilBuffer = GL_STENCIL_BUFFER_BIT
Texture = GL_TEXTURE_BIT
Transform = GL_TRANSFORM_BIT
Viewport = GL_VIEWPORT_BIT
enum Binding

Bindings to unbind on destruction.

Values:

UnbindArrayBuffer = 1u << 0u
UnbindTexture = 1u << 1u
UnbindVertexArray = 1u << 2u
UnbindProgram = 1u << 3u
UnbindAll = UnbindArrayBuffer | UnbindTexture | UnbindVertexArray | UnbindProgram
class GLStateRestore
#include <FnGLStateHelper.h>

Provide a RAII mechanism to temporarily change the OpenGL state.

Public Functions

GLStateRestore(GLbitfield mask, Bindings bindings = 0)

Constructor. mask should be any combination of the Bit enumeration values.

glPushAttrib(mask)
~GLStateRestore()

Destructor.