diff --git a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs index bb57b64c1c..ae7c76df0c 100755 --- a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs +++ b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs @@ -50,6 +50,9 @@ namespace OpenRA.FileFormats.Graphics void SetLineWidth( float width ); void EnableScissor( int left, int top, int width, int height ); void DisableScissor(); + + void EnableDepthBuffer(); + void DisableDepthBuffer(); } public interface IVertexBuffer diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index 6509778669..e129851745 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -186,5 +186,17 @@ namespace OpenRA.Graphics Flush(); Device.DisableScissor(); } + + public void EnableDepthBuffer() + { + Flush(); + Device.EnableDepthBuffer(); + } + + public void DisableDepthBuffer() + { + Flush(); + Device.DisableDepthBuffer(); + } } } diff --git a/OpenRA.Renderer.Null/NullGraphicsDevice.cs b/OpenRA.Renderer.Null/NullGraphicsDevice.cs index a98c6db52c..61c7878caf 100644 --- a/OpenRA.Renderer.Null/NullGraphicsDevice.cs +++ b/OpenRA.Renderer.Null/NullGraphicsDevice.cs @@ -38,6 +38,9 @@ namespace OpenRA.Renderer.Null public void EnableScissor(int left, int top, int width, int height) { } public void DisableScissor() { } + public void EnableDepthBuffer() { } + public void DisableDepthBuffer() { } + public void Clear() { } public void Present() { } diff --git a/OpenRA.Renderer.SdlCommon/SdlGraphics.cs b/OpenRA.Renderer.SdlCommon/SdlGraphics.cs index e274c54a78..ccd7ca08aa 100644 --- a/OpenRA.Renderer.SdlCommon/SdlGraphics.cs +++ b/OpenRA.Renderer.SdlCommon/SdlGraphics.cs @@ -133,6 +133,20 @@ namespace OpenRA.Renderer.SdlCommon ErrorHandler.CheckGlError(); } + public void EnableDepthBuffer() + { + Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT); + ErrorHandler.CheckGlError(); + Gl.glEnable(Gl.GL_DEPTH_TEST); + ErrorHandler.CheckGlError(); + } + + public void DisableDepthBuffer() + { + Gl.glDisable(Gl.GL_DEPTH_TEST); + ErrorHandler.CheckGlError(); + } + public void EnableScissor(int left, int top, int width, int height) { if (width < 0) width = 0;