Skip to content

Commit 2ea77de

Browse files
GLContextState: properly check GL_DEPTH_CLAMP support (close #619)
1 parent b30b9aa commit 2ea77de

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Graphics/GraphicsEngineOpenGL/include/GLContextState.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -115,6 +115,7 @@ class GLContextState
115115
{
116116
bool IsFillModeSelectionSupported = true;
117117
bool IsProgramPipelineSupported = true;
118+
bool IsDepthClampSupported = true;
118119
GLint MaxCombinedTexUnits = 0;
119120
GLint MaxDrawBuffers = 0;
120121
GLint MaxUniformBufferBindings = 0;

Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@
878878

879879

880880
#ifndef GL_DEPTH_CLAMP
881-
# define GL_DEPTH_CLAMP 0
881+
# define GL_DEPTH_CLAMP 0x864F
882882
#endif
883883

884884
// Blend functions

Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
#endif
168168

169169
#ifndef GL_DEPTH_CLAMP
170-
# define GL_DEPTH_CLAMP 0
170+
# define GL_DEPTH_CLAMP 0x864F
171171
#endif
172172

173173

Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,6 +47,7 @@ GLContextState::GLContextState(RenderDeviceGLImpl* pDeviceGL)
4747
const auto& AdapterInfo = pDeviceGL->GetAdapterInfo();
4848
m_Caps.IsFillModeSelectionSupported = AdapterInfo.Features.WireframeFill;
4949
m_Caps.IsProgramPipelineSupported = AdapterInfo.Features.SeparablePrograms;
50+
m_Caps.IsDepthClampSupported = AdapterInfo.Features.DepthClamp;
5051

5152
{
5253
m_Caps.MaxCombinedTexUnits = 0;
@@ -669,9 +670,7 @@ void GLContextState::SetDepthClamp(bool bEnableDepthClamp)
669670
// disabling clipping in Direct3D.
670671
// https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_rasterizer_desc
671672
// https://www.khronos.org/opengl/wiki/GLAPI/glEnable
672-
#pragma warning(push)
673-
#pragma warning(disable : 4127)
674-
if (GL_DEPTH_CLAMP)
673+
if (m_Caps.IsDepthClampSupported)
675674
{
676675
glEnable(GL_DEPTH_CLAMP);
677676
DEV_CHECK_GL_ERROR("Failed to enable depth clamp");
@@ -683,12 +682,11 @@ void GLContextState::SetDepthClamp(bool bEnableDepthClamp)
683682
}
684683
else
685684
{
686-
if (GL_DEPTH_CLAMP)
685+
if (m_Caps.IsDepthClampSupported)
687686
{
688687
glDisable(GL_DEPTH_CLAMP);
689688
DEV_CHECK_GL_ERROR("Failed to disable depth clamp");
690689
}
691-
#pragma warning(pop)
692690
}
693691
m_RSState.DepthClampEnable = bEnableDepthClamp;
694692
}

0 commit comments

Comments
 (0)