diff --git a/src/Avalonia.Base/Platform/Storage/PickerOptions.cs b/src/Avalonia.Base/Platform/Storage/PickerOptions.cs
index ed061aa2d5..07f99f32c8 100644
--- a/src/Avalonia.Base/Platform/Storage/PickerOptions.cs
+++ b/src/Avalonia.Base/Platform/Storage/PickerOptions.cs
@@ -6,7 +6,7 @@
public class PickerOptions
{
///
- /// Gets or sets the text that appears in the title bar of a folder dialog.
+ /// Gets or sets the text that appears in the title bar of a picker.
///
public string? Title { get; set; }
diff --git a/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs b/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs
index e207bc23ab..85cab1d18e 100644
--- a/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs
+++ b/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs
@@ -38,12 +38,10 @@ namespace Avalonia.Win32.OpenGl
[MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))]
[MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))]
- [MemberNotNullWhen(true, nameof(s_glDebugMessageCallback))]
private static bool Initialize() => _initialized ??= InitializeCore();
[MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))]
[MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))]
- [MemberNotNullWhen(true, nameof(s_glDebugMessageCallback))]
private static bool InitializeCore()
{
Dispatcher.UIThread.VerifyAccess();
@@ -74,9 +72,9 @@ namespace Avalonia.Win32.OpenGl
Marshal.GetDelegateForFunctionPointer(
wglGetProcAddress("wglChoosePixelFormatARB"));
- s_glDebugMessageCallback =
- Marshal.GetDelegateForFunctionPointer(
- wglGetProcAddress("glDebugMessageCallback"));
+ s_glDebugMessageCallback = wglGetProcAddress("glDebugMessageCallback") is { } setDebugCallback && setDebugCallback != default ?
+ Marshal.GetDelegateForFunctionPointer(setDebugCallback) :
+ null;
var formats = new int[1];
@@ -144,8 +142,12 @@ namespace Avalonia.Win32.OpenGl
});
}
- using(new WglRestoreContext(dc, context, null))
- s_glDebugMessageCallback(Marshal.GetFunctionPointerForDelegate(_debugCallback), IntPtr.Zero);
+ if (s_glDebugMessageCallback is not null)
+ {
+ using (new WglRestoreContext(dc, context, null))
+ s_glDebugMessageCallback(Marshal.GetFunctionPointerForDelegate(_debugCallback), IntPtr.Zero);
+ }
+
if (context != IntPtr.Zero)
return new WglContext(shareContext, version, context, window, dc,
_defaultPixelFormat, _defaultPfd);
diff --git a/src/Windows/Avalonia.Win32/Win32GlManager.cs b/src/Windows/Avalonia.Win32/Win32GlManager.cs
index b3760a37e1..ebb708f4c5 100644
--- a/src/Windows/Avalonia.Win32/Win32GlManager.cs
+++ b/src/Windows/Avalonia.Win32/Win32GlManager.cs
@@ -20,6 +20,10 @@ static class Win32GlManager
{
AvaloniaLocator.CurrentMutable.Bind().ToConstant(gl);
}
+ if (gl is IPlatformGraphicsOpenGlContextFactory openGlFactory)
+ {
+ AvaloniaLocator.CurrentMutable.Bind().ToConstant(openGlFactory);
+ }
return gl;
}