mirror of https://github.com/bjornbytes/lovr.git
Allow disabling of depth test;
This commit is contained in:
parent
43b7592989
commit
9f4a441bf1
|
@ -42,5 +42,4 @@ void initGlfw(GLFWerrorfun onError, GLFWwindowclosefun onClose, void* userPointe
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ void lovrGraphicsInit() {
|
|||
glGenVertexArrays(1, &state.shapeArray);
|
||||
vec_init(&state.shapeData);
|
||||
vec_init(&state.shapeIndices);
|
||||
state.depthTest = -1;
|
||||
lovrGraphicsReset();
|
||||
}
|
||||
|
||||
|
@ -235,6 +236,11 @@ void lovrGraphicsSetDepthTest(CompareMode depthTest) {
|
|||
if (state.depthTest != depthTest) {
|
||||
state.depthTest = depthTest;
|
||||
glDepthFunc(depthTest);
|
||||
if (depthTest) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
} else {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef enum {
|
|||
} PolygonWinding;
|
||||
|
||||
typedef enum {
|
||||
COMPARE_NONE = 0,
|
||||
COMPARE_EQUAL = GL_EQUAL,
|
||||
COMPARE_NOT_EQUAL = GL_NOTEQUAL,
|
||||
COMPARE_LESS = GL_LESS,
|
||||
|
|
|
@ -327,13 +327,22 @@ int l_lovrGraphicsSetPolygonWinding(lua_State* L) {
|
|||
}
|
||||
|
||||
int l_lovrGraphicsGetDepthTest(lua_State* L) {
|
||||
lua_pushstring(L, map_int_find(&CompareModes, lovrGraphicsGetDepthTest()));
|
||||
CompareMode depthTest = lovrGraphicsGetDepthTest();
|
||||
if (depthTest) {
|
||||
lua_pushstring(L, map_int_find(&CompareModes, depthTest));
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrGraphicsSetDepthTest(lua_State* L) {
|
||||
CompareMode* depthTest = (CompareMode*) luax_checkenum(L, 1, &CompareModes, "compare mode");
|
||||
lovrGraphicsSetDepthTest(*depthTest);
|
||||
if (lua_isnoneornil(L, 1)) {
|
||||
lovrGraphicsSetDepthTest(COMPARE_NONE);
|
||||
} else {
|
||||
CompareMode* depthTest = (CompareMode*) luax_checkenum(L, 1, &CompareModes, "compare mode");
|
||||
lovrGraphicsSetDepthTest(*depthTest);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue