diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-07-16 01:45:41 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-07-16 01:45:41 +0000 |
| commit | e4f8d8023ca64a9ff246d0001e4225143390c36e (patch) | |
| tree | 6416c37f36d82d35afaca2eb0d83e6d04ee04b04 /Graphics/GraphicsEngineOpenGL | |
| parent | ShaderMacroHelper: added RemoveMacro and UpdateMacro methods (diff) | |
| download | DiligentCore-e4f8d8023ca64a9ff246d0001e4225143390c36e.tar.gz DiligentCore-e4f8d8023ca64a9ff246d0001e4225143390c36e.zip | |
Fixed issue with depth clamping in GL backend
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp | 7 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp | 7 |
2 files changed, 10 insertions, 4 deletions
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<Float32>( 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" ); } |
