Skip to content

Commit

Permalink
[GL] Check for errors when enabling default states
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Dec 7, 2023
1 parent d482b3d commit 1399341
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/Aardvark.Rendering.GL/Core/ContextHandles.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 3 additions & 2 deletions src/Aardvark.Rendering.GL/Core/DebugOutput.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

[<AutoOpen>]
module private IGraphicsContextDebugExtensions =
Expand Down

0 comments on commit 1399341

Please sign in to comment.