mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-07 06:43:34 +00:00
Ensure GL state is tracked properly between restarts;
This commit is contained in:
parent
5ebea9db71
commit
f47dccaaa3
|
@ -610,19 +610,39 @@ void lovrGpuInit(bool srgb, gpuProc (*getProcAddress)(const char*)) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
state.srgb = srgb;
|
state.srgb = srgb;
|
||||||
state.blendMode = -1;
|
|
||||||
state.blendAlphaMode = -1;
|
state.blendMode = BLEND_ALPHA;
|
||||||
|
state.blendAlphaMode = BLEND_ALPHA_MULTIPLY;
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
state.culling = false;
|
state.culling = false;
|
||||||
state.depthEnabled = false;
|
glDisable(GL_CULL_FACE);
|
||||||
state.depthTest = COMPARE_LESS;
|
|
||||||
|
state.depthEnabled = true;
|
||||||
|
state.depthTest = COMPARE_LEQUAL;
|
||||||
state.depthWrite = true;
|
state.depthWrite = true;
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(convertCompareMode(state.depthTest));
|
||||||
|
glDepthMask(state.depthWrite);
|
||||||
|
|
||||||
state.lineWidth = 1;
|
state.lineWidth = 1;
|
||||||
|
glLineWidth(state.lineWidth);
|
||||||
|
|
||||||
state.stencilEnabled = false;
|
state.stencilEnabled = false;
|
||||||
state.stencilMode = COMPARE_NONE;
|
state.stencilMode = COMPARE_NONE;
|
||||||
state.stencilValue = 0;
|
state.stencilValue = 0;
|
||||||
state.stencilWriting = false;
|
state.stencilWriting = false;
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
|
||||||
state.winding = WINDING_COUNTERCLOCKWISE;
|
state.winding = WINDING_COUNTERCLOCKWISE;
|
||||||
|
glFrontFace(GL_CCW);
|
||||||
|
|
||||||
state.wireframe = false;
|
state.wireframe = false;
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < MAX_BARRIERS; i++) {
|
for (int i = 0; i < MAX_BARRIERS; i++) {
|
||||||
vec_init(&state.incoherents[i]);
|
vec_init(&state.incoherents[i]);
|
||||||
}
|
}
|
||||||
|
@ -639,6 +659,7 @@ void lovrGpuDestroy() {
|
||||||
for (int i = 0; i < MAX_BARRIERS; i++) {
|
for (int i = 0; i < MAX_BARRIERS; i++) {
|
||||||
vec_deinit(&state.incoherents[i]);
|
vec_deinit(&state.incoherents[i]);
|
||||||
}
|
}
|
||||||
|
memset(&state, 0, sizeof(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGpuBindPipeline(Pipeline* pipeline) {
|
void lovrGpuBindPipeline(Pipeline* pipeline) {
|
||||||
|
|
Loading…
Reference in a new issue