diff --git a/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp index 54d0557b..aa1fe5a1 100644 --- a/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp +++ b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp @@ -649,7 +649,9 @@ namespace MobileGL::MG_Impl::GLImpl { } void ClearDepth_State(GLclampd depth) { - MG_State::pGLContext->SetClearDepth(static_cast(depth)); + // GL 3.3 ยง4.2.3: the clear depth is clamped to [0,1] at specification time (Vulkan clear + // values additionally require it: VUID-VkClearDepthStencilValue-depth-00022). + MG_State::pGLContext->SetClearDepth(ClampUnitFloat(static_cast(depth))); } void ClearColor_State(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {