mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 07:35:41 +12:00
[OpenGL] Same for depth mask
This commit is contained in:
parent
d80785cbb5
commit
7307bd270b
4 changed files with 18 additions and 5 deletions
|
@ -22,8 +22,9 @@ struct GLStateManager {
|
||||||
bool depthEnabled;
|
bool depthEnabled;
|
||||||
bool scissorEnabled;
|
bool scissorEnabled;
|
||||||
|
|
||||||
// Colour mask
|
// Colour/depth masks
|
||||||
bool redMask, greenMask, blueMask, alphaMask;
|
bool redMask, greenMask, blueMask, alphaMask;
|
||||||
|
bool depthMask;
|
||||||
|
|
||||||
GLuint boundVAO;
|
GLuint boundVAO;
|
||||||
GLuint boundVBO;
|
GLuint boundVBO;
|
||||||
|
@ -108,7 +109,14 @@ struct GLStateManager {
|
||||||
b = blueMask;
|
b = blueMask;
|
||||||
a = alphaMask;
|
a = alphaMask;
|
||||||
|
|
||||||
glColorMask(r, g, b, a);
|
OpenGL::setColourMask(r, g, b, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDepthMask(bool mask) {
|
||||||
|
if (depthMask != mask) {
|
||||||
|
depthMask = mask;
|
||||||
|
OpenGL::setDepthMask(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -528,6 +528,8 @@ namespace OpenGL {
|
||||||
static void disableClipPlane(GLuint index) { glDisable(GL_CLIP_DISTANCE0 + index); }
|
static void disableClipPlane(GLuint index) { glDisable(GL_CLIP_DISTANCE0 + index); }
|
||||||
|
|
||||||
static void setDepthFunc(DepthFunc func) { glDepthFunc(static_cast<GLenum>(func)); }
|
static void setDepthFunc(DepthFunc func) { glDepthFunc(static_cast<GLenum>(func)); }
|
||||||
|
static void setColourMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) { glColorMask(r, g, b, a); }
|
||||||
|
static void setDepthMask(GLboolean mask) { glDepthMask(mask); }
|
||||||
|
|
||||||
enum Primitives {
|
enum Primitives {
|
||||||
Triangle = GL_TRIANGLES,
|
Triangle = GL_TRIANGLES,
|
||||||
|
|
|
@ -896,14 +896,14 @@ void Renderer::drawVertices(PICA::PrimType primType, std::span<const Vertex> ver
|
||||||
// Because it attaches a depth texture to the aforementioned colour buffer
|
// Because it attaches a depth texture to the aforementioned colour buffer
|
||||||
if (depthEnable) {
|
if (depthEnable) {
|
||||||
gl.enableDepth();
|
gl.enableDepth();
|
||||||
|
gl.setDepthMask(depthWriteEnable ? GL_TRUE : GL_FALSE);
|
||||||
glDepthFunc(depthModes[depthFunc]);
|
glDepthFunc(depthModes[depthFunc]);
|
||||||
glDepthMask(depthWriteEnable ? GL_TRUE : GL_FALSE);
|
|
||||||
bindDepthBuffer();
|
bindDepthBuffer();
|
||||||
} else {
|
} else {
|
||||||
if (depthWriteEnable) {
|
if (depthWriteEnable) {
|
||||||
gl.enableDepth();
|
gl.enableDepth();
|
||||||
|
gl.setDepthMask(GL_TRUE);
|
||||||
glDepthFunc(GL_ALWAYS);
|
glDepthFunc(GL_ALWAYS);
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
bindDepthBuffer();
|
bindDepthBuffer();
|
||||||
} else {
|
} else {
|
||||||
gl.disableDepth();
|
gl.disableDepth();
|
||||||
|
|
|
@ -7,12 +7,15 @@ void GLStateManager::resetBlend() {
|
||||||
|
|
||||||
void GLStateManager::resetColourMask() {
|
void GLStateManager::resetColourMask() {
|
||||||
redMask = greenMask = blueMask = alphaMask = true;
|
redMask = greenMask = blueMask = alphaMask = true;
|
||||||
glColorMask(redMask, greenMask, blueMask, alphaMask);
|
OpenGL::setColourMask(redMask, greenMask, blueMask, alphaMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLStateManager::resetDepth() {
|
void GLStateManager::resetDepth() {
|
||||||
depthEnabled = false;
|
depthEnabled = false;
|
||||||
|
depthMask = true;
|
||||||
|
|
||||||
OpenGL::disableDepth();
|
OpenGL::disableDepth();
|
||||||
|
OpenGL::setDepthMask(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLStateManager::resetScissor() {
|
void GLStateManager::resetScissor() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue