/ src / Ryujinx.Graphics.OpenGL / Helper / GLXHelper.cs
GLXHelper.cs
 1  using System;
 2  using System.Runtime.InteropServices;
 3  using System.Runtime.Versioning;
 4  
 5  namespace Ryujinx.Graphics.OpenGL.Helper
 6  {
 7      [SupportedOSPlatform("linux")]
 8      internal static partial class GLXHelper
 9      {
10          private const string LibraryName = "glx.dll";
11  
12          static GLXHelper()
13          {
14              NativeLibrary.SetDllImportResolver(typeof(GLXHelper).Assembly, (name, assembly, path) =>
15              {
16                  if (name != LibraryName)
17                  {
18                      return IntPtr.Zero;
19                  }
20  
21                  if (!NativeLibrary.TryLoad("libGL.so.1", assembly, path, out IntPtr result))
22                  {
23                      if (!NativeLibrary.TryLoad("libGL.so", assembly, path, out result))
24                      {
25                          return IntPtr.Zero;
26                      }
27                  }
28  
29                  return result;
30              });
31          }
32  
33          [LibraryImport(LibraryName, EntryPoint = "glXGetCurrentContext")]
34          public static partial IntPtr GetCurrentContext();
35      }
36  }