![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/StateGuard.h>
Guard to easily save and restore critical (modern) OpenGL state. More...
Guard to easily save and restore critical (modern) OpenGL state.
On instantiation StateGuard will store selected parts of the current OpenGL state. On destruction StateGuard will restore those settings, no matter of what has been happened in the meantime.
Usage example:
Public Types | |
enum | SaveFlags { None = 0 , Viewport = 1 << 0 , FBO = 1 << 1 , Program = 1 << 2 , Blending = 1 << 3 , DepthTest = 1 << 4 , ScissorTest = 1 << 5 , Smoothing = 1 << 6 , Stencil = 1 << 7 , Everything = Viewport | FBO | Program | Blending | DepthTest | ScissorTest | Smoothing | Stencil } |
Public Member Functions | |
StateGuard (Flags< SaveFlags > saveFlags=Everything) | |
Constructor, initializes the guard and saves the current state. | |
StateGuard (StateGuard &&rhs) | |
Move constructor needed to avoid double deletion when returning by value. | |
~StateGuard () | |
Destructor, restores the state of all save flags given originally, if not done before. | |
void | restoreState (Flags< SaveFlags > saveFlagsToClear) |
Restores the state of the given save flags. | |
void | release (Flags< SaveFlags > saveFlagsToRelease) |
Marks the given save flags as restored without actually restoring them. | |
enum SaveFlags |
Restores the state of the given save flags.
Marks the given save flags as restored without actually restoring them.
In rare occasions you may want to delete a StateGuard without actually restoring the original state.