Skip to content

Commit

Permalink
Fix SharedGRContext.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd authored Jul 31, 2023
1 parent 9432dcf commit bdb33e8
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Beutl.Graphics/Rendering/SharedGRContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public static GRContext GetOrCreate()
{
RenderThread.Dispatcher.VerifyAccess();
GLFW.Init();
ThrowGLFWError();
if (GLFW.GetError(out _) is not ErrorCode.NoError)
return null;

Check warning on line 22 in src/Beutl.Graphics/Rendering/SharedGRContext.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

GLFW.DefaultWindowHints();
GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core);
Expand All @@ -27,9 +28,10 @@ public static GRContext GetOrCreate()
GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 3);
GLFW.WindowHint(WindowHintBool.Visible, false);
s_window = GLFW.CreateWindow(1, 1, string.Empty, null, null);

GLFW.MakeContextCurrent(s_window);
ThrowGLFWError();
if (GLFW.GetError(out _) is not ErrorCode.NoError)
return null;

Check warning on line 34 in src/Beutl.Graphics/Rendering/SharedGRContext.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

GRContext = GRContext.CreateGl();
}
Expand All @@ -49,14 +51,4 @@ public static void Shutdown()
}
});
}

private static void ThrowGLFWError()
{
var result = GLFW.GetError(out var description);

if (result is not ErrorCode.NoError)
{
throw new GraphicsException(description);
}
}
}

0 comments on commit bdb33e8

Please sign in to comment.