Browse Source

[Win32] Use a proper DllImport for libegl.dll

win32-jitter-hack
Nikita Tsukanov 7 years ago
parent
commit
e93853e8b7
  1. 18
      src/Avalonia.OpenGL/EglInterface.cs

18
src/Avalonia.OpenGL/EglInterface.cs

@ -1,4 +1,5 @@
using System; using System;
using System.Runtime.InteropServices;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Platform.Interop; using Avalonia.Platform.Interop;
@ -15,13 +16,28 @@ namespace Avalonia.OpenGL
{ {
} }
[DllImport("libegl.dll", CharSet = CharSet.Ansi)]
static extern IntPtr eglGetProcAddress(string proc);
static Func<string, bool, IntPtr> Load() static Func<string, bool, IntPtr> Load()
{ {
var os = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem; var os = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().OperatingSystem;
if(os == OperatingSystemType.Linux || os == OperatingSystemType.Android) if(os == OperatingSystemType.Linux || os == OperatingSystemType.Android)
return Load("libEGL.so.1"); return Load("libEGL.so.1");
if (os == OperatingSystemType.WinNT) if (os == OperatingSystemType.WinNT)
return Load(@"libegl.dll"); {
var disp = eglGetProcAddress("eglGetPlatformDisplayEXT");
if (disp == IntPtr.Zero)
throw new OpenGlException("libegl.dll doesn't have eglGetPlatformDisplayEXT entry point");
return (name, optional) =>
{
var r = eglGetProcAddress(name);
if (r == IntPtr.Zero && !optional)
throw new OpenGlException($"Entry point {r} is not found");
return r;
};
}
throw new PlatformNotSupportedException(); throw new PlatformNotSupportedException();
} }

Loading…
Cancel
Save