Add clear colour to GL state manager

This commit is contained in:
wheremyfoodat 2023-08-12 17:02:00 +03:00
parent 4107a84c0d
commit 0f5c41cd69
4 changed files with 138 additions and 128 deletions

View file

@ -34,6 +34,8 @@ struct GLStateManager {
bool redMask, greenMask, blueMask, alphaMask;
bool depthMask;
float clearRed, clearBlue, clearGreen, clearAlpha;
GLuint stencilMask;
GLuint boundVAO;
GLuint boundVBO;
@ -44,6 +46,7 @@ struct GLStateManager {
void reset();
void resetBlend();
void resetClearing();
void resetClipping();
void resetColourMask();
void resetDepth();
@ -209,8 +212,19 @@ struct GLStateManager {
}
}
void setClearColour(float r, float g, float b, float a) {
if (clearRed != r || clearGreen != g || clearBlue != b || clearAlpha != a) {
clearRed = r;
clearGreen = g;
clearBlue = b;
clearAlpha = a;
OpenGL::setClearColor(r, g, b, a);
}
}
void setDepthFunc(OpenGL::DepthFunc func) { setDepthFunc(static_cast<GLenum>(func)); }
};
static_assert(std::is_trivially_constructible<GLStateManager>(), "OpenGL State Manager class is not trivially constructible!");
static_assert(std::is_trivially_destructible<GLStateManager>(), "OpenGL State Manager class is not trivially destructible!");
static_assert(std::is_trivially_destructible<GLStateManager>(), "OpenGL State Manager class is not trivially destructible!");