From 1b34c7d6b9aef78b8c182f29cfa3c01cb85d2178 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 22 Feb 2013 23:29:34 +1300 Subject: [PATCH] Expose depth buffer to render code. --- OpenRA.FileFormats/Graphics/IGraphicsDevice.cs | 3 +++ OpenRA.Game/Graphics/Renderer.cs | 12 ++++++++++++ OpenRA.Renderer.Null/NullGraphicsDevice.cs | 3 +++ OpenRA.Renderer.SdlCommon/SdlGraphics.cs | 14 ++++++++++++++ 4 files changed, 32 insertions(+) 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;