mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-09 12:22:34 +01:00
Introduce depth test render state
This commit is contained in:
parent
7337da3133
commit
2e472dd25c
@ -282,6 +282,7 @@ void OpenGLRenderer::setDrawState(const glm::mat4& model, DrawBuffer* draw,
|
|||||||
|
|
||||||
setBlend(p.blendMode);
|
setBlend(p.blendMode);
|
||||||
setDepthWrite(p.depthWrite);
|
setDepthWrite(p.depthWrite);
|
||||||
|
setDepthMode(p.depthMode);
|
||||||
|
|
||||||
ObjectUniformData objectData{model,
|
ObjectUniformData objectData{model,
|
||||||
glm::vec4(p.colour.r / 255.f, p.colour.g / 255.f,
|
glm::vec4(p.colour.r / 255.f, p.colour.g / 255.f,
|
||||||
@ -369,6 +370,7 @@ void OpenGLRenderer::invalidate() {
|
|||||||
currentTextures.clear();
|
currentTextures.clear();
|
||||||
currentUBO = 0;
|
currentUBO = 0;
|
||||||
setBlend(BlendMode::BLEND_NONE);
|
setBlend(BlendMode::BLEND_NONE);
|
||||||
|
setDepthMode(DepthMode::OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGLRenderer::createUBO(Buffer &out, GLsizei size, GLsizei entrySize)
|
bool OpenGLRenderer::createUBO(Buffer &out, GLsizei size, GLsizei entrySize)
|
||||||
|
@ -62,6 +62,11 @@ enum class BlendMode {
|
|||||||
BLEND_ADDITIVE
|
BLEND_ADDITIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class DepthMode {
|
||||||
|
OFF,
|
||||||
|
LESS,
|
||||||
|
};
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<GLuint> Textures;
|
typedef std::vector<GLuint> Textures;
|
||||||
@ -84,7 +89,9 @@ public:
|
|||||||
Textures textures{};
|
Textures textures{};
|
||||||
/// Blending mode
|
/// Blending mode
|
||||||
BlendMode blendMode = BlendMode::BLEND_NONE;
|
BlendMode blendMode = BlendMode::BLEND_NONE;
|
||||||
// Depth writing state
|
/// Depth
|
||||||
|
DepthMode depthMode = DepthMode::LESS;
|
||||||
|
/// Depth writing state
|
||||||
bool depthWrite = true;
|
bool depthWrite = true;
|
||||||
/// Material
|
/// Material
|
||||||
glm::u8vec4 colour{};
|
glm::u8vec4 colour{};
|
||||||
@ -342,6 +349,7 @@ private:
|
|||||||
DrawBuffer* currentDbuff = nullptr;
|
DrawBuffer* currentDbuff = nullptr;
|
||||||
OpenGLShaderProgram* currentProgram = nullptr;
|
OpenGLShaderProgram* currentProgram = nullptr;
|
||||||
BlendMode blendMode = BlendMode::BLEND_NONE;
|
BlendMode blendMode = BlendMode::BLEND_NONE;
|
||||||
|
DepthMode depthMode = DepthMode::OFF;
|
||||||
bool depthWriteEnabled = false;
|
bool depthWriteEnabled = false;
|
||||||
GLuint currentUBO = 0;
|
GLuint currentUBO = 0;
|
||||||
GLuint currentUnit = 0;
|
GLuint currentUnit = 0;
|
||||||
@ -373,6 +381,17 @@ private:
|
|||||||
blendMode = mode;
|
blendMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setDepthMode(DepthMode mode) {
|
||||||
|
if (mode != depthMode) {
|
||||||
|
if (depthMode == DepthMode::OFF) glEnable(GL_DEPTH_TEST);
|
||||||
|
switch(mode) {
|
||||||
|
case DepthMode::OFF: glDisable(GL_DEPTH_TEST); break;
|
||||||
|
case DepthMode::LESS: glDepthFunc(GL_LESS); break;
|
||||||
|
}
|
||||||
|
depthMode = mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setDepthWrite(bool enable) {
|
void setDepthWrite(bool enable) {
|
||||||
if (enable != depthWriteEnabled) {
|
if (enable != depthWriteEnabled) {
|
||||||
glDepthMask(enable ? GL_TRUE : GL_FALSE);
|
glDepthMask(enable ? GL_TRUE : GL_FALSE);
|
||||||
|
Loading…
Reference in New Issue
Block a user