From 1399341eaf35e271284c35cea46c9b796f10498a Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 7 Dec 2023 16:39:08 +0100 Subject: [PATCH] [GL] Check for errors when enabling default states --- src/Aardvark.Rendering.GL/Core/ContextHandles.fs | 11 +++++++++++ src/Aardvark.Rendering.GL/Core/DebugOutput.fs | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Aardvark.Rendering.GL/Core/ContextHandles.fs b/src/Aardvark.Rendering.GL/Core/ContextHandles.fs index 467c0f6f..5cfe273a 100644 --- a/src/Aardvark.Rendering.GL/Core/ContextHandles.fs +++ b/src/Aardvark.Rendering.GL/Core/ContextHandles.fs @@ -31,12 +31,23 @@ module ContextHandleGLExtensions = type GL with static member SetDefaultStates() = GL.Enable(EnableCap.TextureCubeMapSeamless) + GL.Check "cannot enable GL_TEXTURE_CUBE_MAP_SEAMLESS" + + // Note: This is supposed to be deprecated since OpenGL 3.2 and enabled by default. + // However, for some AMD drivers you still need to enable it even though it should not exist anymore. GL.Enable(EnableCap.PointSprite) + GL.GetError() |> ignore + GL.Disable(EnableCap.PolygonSmooth) + GL.Check "cannot disable GL_POLYGON_SMOOTH" + GL.Hint(HintTarget.FragmentShaderDerivativeHint, HintMode.Nicest) + GL.Check "cannot set GL_FRAGMENT_SHADER_DERIVATIVE_HINT to GL_NICEST" + if RuntimeConfig.DepthRange = DepthRange.ZeroToOne then if GL.ARB_clip_control then GL.ClipControl(ClipOrigin.LowerLeft, ClipDepthMode.ZeroToOne) + GL.Check "failed to set depth range to [0, 1]" else failf "cannot set depth range to [0, 1] without GL_ARB_clip_control or OpenGL 4.5" diff --git a/src/Aardvark.Rendering.GL/Core/DebugOutput.fs b/src/Aardvark.Rendering.GL/Core/DebugOutput.fs index 254f6734..eec12dad 100644 --- a/src/Aardvark.Rendering.GL/Core/DebugOutput.fs +++ b/src/Aardvark.Rendering.GL/Core/DebugOutput.fs @@ -21,10 +21,11 @@ module Error = if mode <> ErrorFlagCheck.Disabled then let err = GL.GetError() if err <> ErrorCode.NoError then - Report.Error("{0}: {1}", err, str) + let message = $"[GL] {str} ({err})" + Report.Error(message) if mode = ErrorFlagCheck.ThrowOnError then - raise <| OpenGLException(err, sprintf "%A" str) + raise <| OpenGLException(err, message) [] module private IGraphicsContextDebugExtensions =