diff --git a/graphics/tinygl/misc.cpp b/graphics/tinygl/misc.cpp index 101194a701e..ca08e96683d 100644 --- a/graphics/tinygl/misc.cpp +++ b/graphics/tinygl/misc.cpp @@ -60,6 +60,7 @@ void glopEnableDisable(GLContext *c, GLParam *p) { break; case TGL_DEPTH_TEST: c->depth_test = v; + c->fb->enableDepthTest(v); break; case TGL_ALPHA_TEST: c->_alphaTestEnabled = v; diff --git a/graphics/tinygl/zbuffer.cpp b/graphics/tinygl/zbuffer.cpp index c60df2d645c..f83636b68fc 100644 --- a/graphics/tinygl/zbuffer.cpp +++ b/graphics/tinygl/zbuffer.cpp @@ -87,6 +87,7 @@ FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelBuffer &fra this->buffer.zbuf = this->zbuf; _blendingEnabled = false; _alphaTestEnabled = false; + _depthTestEnabled = false; _depthFunc = TGL_LESS; } @@ -182,6 +183,10 @@ void FrameBuffer::enableAlphaTest(bool enable) { _alphaTestEnabled = enable; } +void FrameBuffer::enableDepthTest(bool enable) { + _depthTestEnabled = enable; +} + void FrameBuffer::setDepthFunc(int func) { _depthFunc = func; } diff --git a/graphics/tinygl/zbuffer.h b/graphics/tinygl/zbuffer.h index e1a9f287be7..a347aab01d4 100644 --- a/graphics/tinygl/zbuffer.h +++ b/graphics/tinygl/zbuffer.h @@ -67,6 +67,9 @@ struct FrameBuffer { } FORCEINLINE bool compareDepth(unsigned int &zSrc, unsigned int &zDst) { + if (!_depthTestEnabled) + return true; + switch (_depthFunc) { case TGL_NEVER: break; @@ -271,6 +274,7 @@ struct FrameBuffer { void enableBlending(bool enable); void setBlendingFactors(int sfactor, int dfactor); void enableAlphaTest(bool enable); + void enableDepthTest(bool enable); void setAlphaTestFunc(int func, float ref); void setDepthFunc(int func); void enableDepthWrite(bool enable) { @@ -338,6 +342,7 @@ private: int _sourceBlendingFactor; int _destinationBlendingFactor; bool _alphaTestEnabled; + bool _depthTestEnabled; int _alphaTestFunc; int _alphaTestRefVal; int _depthFunc;