mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +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);
|
||||
setDepthWrite(p.depthWrite);
|
||||
setDepthMode(p.depthMode);
|
||||
|
||||
ObjectUniformData objectData{model,
|
||||
glm::vec4(p.colour.r / 255.f, p.colour.g / 255.f,
|
||||
@ -369,6 +370,7 @@ void OpenGLRenderer::invalidate() {
|
||||
currentTextures.clear();
|
||||
currentUBO = 0;
|
||||
setBlend(BlendMode::BLEND_NONE);
|
||||
setDepthMode(DepthMode::OFF);
|
||||
}
|
||||
|
||||
bool OpenGLRenderer::createUBO(Buffer &out, GLsizei size, GLsizei entrySize)
|
||||
|
@ -62,6 +62,11 @@ enum class BlendMode {
|
||||
BLEND_ADDITIVE
|
||||
};
|
||||
|
||||
enum class DepthMode {
|
||||
OFF,
|
||||
LESS,
|
||||
};
|
||||
|
||||
class Renderer {
|
||||
public:
|
||||
typedef std::vector<GLuint> Textures;
|
||||
@ -84,7 +89,9 @@ public:
|
||||
Textures textures{};
|
||||
/// Blending mode
|
||||
BlendMode blendMode = BlendMode::BLEND_NONE;
|
||||
// Depth writing state
|
||||
/// Depth
|
||||
DepthMode depthMode = DepthMode::LESS;
|
||||
/// Depth writing state
|
||||
bool depthWrite = true;
|
||||
/// Material
|
||||
glm::u8vec4 colour{};
|
||||
@ -342,6 +349,7 @@ private:
|
||||
DrawBuffer* currentDbuff = nullptr;
|
||||
OpenGLShaderProgram* currentProgram = nullptr;
|
||||
BlendMode blendMode = BlendMode::BLEND_NONE;
|
||||
DepthMode depthMode = DepthMode::OFF;
|
||||
bool depthWriteEnabled = false;
|
||||
GLuint currentUBO = 0;
|
||||
GLuint currentUnit = 0;
|
||||
@ -373,6 +381,17 @@ private:
|
||||
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) {
|
||||
if (enable != depthWriteEnabled) {
|
||||
glDepthMask(enable ? GL_TRUE : GL_FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user