Browse Source

Merge pull request #12056 from AvaloniaUI/ogl-bug

Fix EGL OpenGLControlBase on Win32
pull/12073/head
Max Katz 3 years ago
committed by GitHub
parent
commit
856ce39314
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Base/Platform/Storage/PickerOptions.cs
  2. 16
      src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs
  3. 4
      src/Windows/Avalonia.Win32/Win32GlManager.cs

2
src/Avalonia.Base/Platform/Storage/PickerOptions.cs

@ -6,7 +6,7 @@
public class PickerOptions public class PickerOptions
{ {
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public string? Title { get; set; } public string? Title { get; set; }

16
src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs

@ -38,12 +38,10 @@ namespace Avalonia.Win32.OpenGl
[MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))] [MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))]
[MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))] [MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))]
[MemberNotNullWhen(true, nameof(s_glDebugMessageCallback))]
private static bool Initialize() => _initialized ??= InitializeCore(); private static bool Initialize() => _initialized ??= InitializeCore();
[MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))] [MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))]
[MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))] [MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))]
[MemberNotNullWhen(true, nameof(s_glDebugMessageCallback))]
private static bool InitializeCore() private static bool InitializeCore()
{ {
Dispatcher.UIThread.VerifyAccess(); Dispatcher.UIThread.VerifyAccess();
@ -74,9 +72,9 @@ namespace Avalonia.Win32.OpenGl
Marshal.GetDelegateForFunctionPointer<WglChoosePixelFormatARBDelegate>( Marshal.GetDelegateForFunctionPointer<WglChoosePixelFormatARBDelegate>(
wglGetProcAddress("wglChoosePixelFormatARB")); wglGetProcAddress("wglChoosePixelFormatARB"));
s_glDebugMessageCallback = s_glDebugMessageCallback = wglGetProcAddress("glDebugMessageCallback") is { } setDebugCallback && setDebugCallback != default ?
Marshal.GetDelegateForFunctionPointer<GlDebugMessageCallbackDelegate>( Marshal.GetDelegateForFunctionPointer<GlDebugMessageCallbackDelegate>(setDebugCallback) :
wglGetProcAddress("glDebugMessageCallback")); null;
var formats = new int[1]; var formats = new int[1];
@ -144,8 +142,12 @@ namespace Avalonia.Win32.OpenGl
}); });
} }
using(new WglRestoreContext(dc, context, null)) if (s_glDebugMessageCallback is not null)
s_glDebugMessageCallback(Marshal.GetFunctionPointerForDelegate(_debugCallback), IntPtr.Zero); {
using (new WglRestoreContext(dc, context, null))
s_glDebugMessageCallback(Marshal.GetFunctionPointerForDelegate(_debugCallback), IntPtr.Zero);
}
if (context != IntPtr.Zero) if (context != IntPtr.Zero)
return new WglContext(shareContext, version, context, window, dc, return new WglContext(shareContext, version, context, window, dc,
_defaultPixelFormat, _defaultPfd); _defaultPixelFormat, _defaultPfd);

4
src/Windows/Avalonia.Win32/Win32GlManager.cs

@ -20,6 +20,10 @@ static class Win32GlManager
{ {
AvaloniaLocator.CurrentMutable.Bind<IPlatformGraphics>().ToConstant(gl); AvaloniaLocator.CurrentMutable.Bind<IPlatformGraphics>().ToConstant(gl);
} }
if (gl is IPlatformGraphicsOpenGlContextFactory openGlFactory)
{
AvaloniaLocator.CurrentMutable.Bind<IPlatformGraphicsOpenGlContextFactory>().ToConstant(openGlFactory);
}
return gl; return gl;
} }

Loading…
Cancel
Save