in binding/SkiaSharp/GRGlInterface.cs [102:177]
public bool Validate () =>
SkiaApi.gr_glinterface_validate (Handle);
public bool HasExtension (string extension) =>
SkiaApi.gr_glinterface_has_extension (Handle, extension);
//
internal static GRGlInterface GetObject (IntPtr handle) =>
handle == IntPtr.Zero ? null : new GRGlInterface (handle, true);
//
private static class AngleLoader
{
private static readonly IntPtr libEGL;
private static readonly IntPtr libGLESv2;
#if WINDOWS_UWP
// https://msdn.microsoft.com/en-us/library/windows/desktop/mt186421(v=vs.85).aspx
[DllImport ("api-ms-win-core-libraryloader-l2-1-0.dll", SetLastError = true, CharSet = CharSet.Ansi)]
private static extern IntPtr LoadPackagedLibrary ([MarshalAs (UnmanagedType.LPWStr)] string lpFileName, uint Reserved);
[DllImport ("api-ms-win-core-libraryloader-l1-2-0.dll", SetLastError = true, CharSet = CharSet.Ansi)]
private static extern IntPtr GetProcAddress (IntPtr hModule, [MarshalAs (UnmanagedType.LPStr)] string lpProcName);
private static IntPtr LoadLibrary (string lpFileName) => LoadPackagedLibrary(lpFileName, 0);
#else
[DllImport ("Kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
private static extern IntPtr LoadLibrary ([MarshalAs (UnmanagedType.LPStr)] string lpFileName);
[DllImport ("Kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
private static extern IntPtr GetProcAddress (IntPtr hModule, [MarshalAs (UnmanagedType.LPStr)] string lpProcName);
#endif
[DllImport ("libEGL.dll")]
private static extern IntPtr eglGetProcAddress ([MarshalAs (UnmanagedType.LPStr)] string procname);
static AngleLoader()
{
// this is not supported at all on non-Windows platforms
if (!PlatformConfiguration.IsWindows) {
return;
}
libEGL = LoadLibrary ("libEGL.dll");
libGLESv2 = LoadLibrary ("libGLESv2.dll");
}
public static bool IsValid =>
libEGL != IntPtr.Zero && libGLESv2 != IntPtr.Zero;
// function to assemble the ANGLE interface
public static IntPtr GetProc (string name)
{
// this is not supported at all on non-Windows platforms
if (!PlatformConfiguration.IsWindows) {
return IntPtr.Zero;
}
if (!IsValid)
return IntPtr.Zero;
IntPtr proc = GetProcAddress (libGLESv2, name);
if (proc == IntPtr.Zero)
{
proc = GetProcAddress (libEGL, name);
}
if (proc == IntPtr.Zero)
{
proc = eglGetProcAddress (name);
}
return proc;
}
}