From e4f8d8023ca64a9ff246d0001e4225143390c36e Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 15 Jul 2019 18:45:41 -0700 Subject: Fixed issue with depth clamping in GL backend --- Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp | 7 ++++++- Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index f6fde626..55fa5435 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -88,7 +88,12 @@ namespace Diligent m_ContextState.SetDepthBias( static_cast( RasterizerDesc.DepthBias ), RasterizerDesc.SlopeScaledDepthBias ); if( RasterizerDesc.DepthBiasClamp != 0 ) LOG_WARNING_MESSAGE( "Depth bias clamp is not supported on OpenGL" ); - m_ContextState.SetDepthClamp( RasterizerDesc.DepthClipEnable ); + + // Enabling depth clamping in GL is the same as disabling clipping in Direct3D. + // https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_rasterizer_desc + // https://www.khronos.org/opengl/wiki/GLAPI/glEnable + m_ContextState.SetDepthClamp( !RasterizerDesc.DepthClipEnable ); + m_ContextState.EnableScissorTest( RasterizerDesc.ScissorEnable ); if( RasterizerDesc.AntialiasedLineEnable ) LOG_WARNING_MESSAGE( "Line antialiasing is not supported on OpenGL" ); diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp index a2163a53..246f1806 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp @@ -517,6 +517,10 @@ namespace Diligent { if( bEnableDepthClamp ) { + // Note that enabling depth clamping in GL is the same as + // disabling clipping in Direct3D. + // https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_rasterizer_desc + // https://www.khronos.org/opengl/wiki/GLAPI/glEnable #pragma warning(push) #pragma warning(disable : 4127) if( GL_DEPTH_CLAMP ) @@ -529,9 +533,6 @@ namespace Diligent { if( GL_DEPTH_CLAMP ) { - // WARNING: on OpenGL, depth clamping is disabled against - // both far and near clip planes. On DirectX, only clipping - // against far clip plane can be disabled glDisable( GL_DEPTH_CLAMP ); CHECK_GL_ERROR( "Failed to disable depth clamp" ); } -- cgit v1.2.3