OpenGL.Net: Does not seem to work on Linux targeting .NET Core

Seems like the initialization is failing on Linux, I’m targeting netcoreapp2.0, using the NuGet package, and a simple call to any GL API crashes the app (ie. Gl.Initialize will crash it as well).

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 28 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Any fix on the horizon for this? Somewhat related would be the addition of allow users to supply their own loader. For example, a handler that could be passed to the bindings instead of trying to load the natives itself.

public delegate IntPtr GetProcAddressHandler(string functionName);

Popular libraries for context creation such as GLFW handle this responsibility reliably across platforms, and are pretty much the standard for creating native windows/contexts, and would allow easily bypassing this issue.

Had made my own quick/dirty bindings by auto-generated them from the registry, and uses GLFW as the loader works without any issues, where as this can’t even initialize, and BindAPI fails.

And just to make it quick, set OPENGL_NET_INIT to NO. The initialization process should be optional.

And we are back to square one:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'OpenGL.GetGLProcAddressGLX' threw an exception. ---> System.InvalidOperationException: unable to load library at libGL.so.1 ---> System.InvalidOperationException: Exception of type 'System.InvalidOperationException' was thrown.
   --- End of inner exception stack trace ---
   at Khronos.GetProcAddressLinux.GetLibraryHandle(String libraryPath, Boolean throws) in /mnt/Data/GitHub/OpenGL.Net/Khronos.Net/GetProcAddressOS.cs:line 387
   at Khronos.GetProcAddressLinux.GetLibraryHandle(String libraryPath) in /mnt/Data/GitHub/OpenGL.Net/Khronos.Net/GetProcAddressOS.cs:line 376
   at Khronos.GetProcAddressLinux.GetProcAddress(String library, String function) in /mnt/Data/GitHub/OpenGL.Net/Khronos.Net/GetProcAddressOS.cs:line 347
   at Khronos.GetProcAddressOS.GetProcAddress(String library, String function) in /mnt/Data/GitHub/OpenGL.Net/Khronos.Net/GetProcAddressOS.cs:line 149
   at OpenGL.GetGLProcAddressGLX..cctor() in /mnt/Data/GitHub/OpenGL.Net/OpenGL.Net/GetProcAddressGL.cs:line 154
   --- End of inner exception stack trace ---
   at OpenGL.GetProcAddressGL.GetProcAddress(String function) in /mnt/Data/GitHub/OpenGL.Net/OpenGL.Net/GetProcAddressGL.cs:line 73
   at OpenGL.KhronosApi.GetProcAddressGLOS(String path, String function) in /mnt/Data/GitHub/OpenGL.Net/OpenGL.Net/KhronosApi.cs:line 118
   at Khronos.KhronosApi.BindAPIFunction(String path, GetAddressDelegate getAddress, FieldInfo function, KhronosVersion version, ExtensionsCollection extensions) in /mnt/Data/GitHub/OpenGL.Net/Khronos.Net/KhronosApi.cs:line 313
   at Khronos.KhronosApi.BindAPIFunction[T](String path, String functionName, GetAddressDelegate getProcAddress, KhronosVersion version, ExtensionsCollection extensions) in /mnt/Data/GitHub/OpenGL.Net/Khronos.Net/KhronosApi.cs:line 164
   at OpenGL.Gl.BindAPIFunction(KhronosVersion version, ExtensionsCollection extensions, String functionName) in /mnt/Data/GitHub/OpenGL.Net/OpenGL.Net/Gl.cs:line 427
   at OpenGL.Gl.QueryContextVersionCore() in /mnt/Data/GitHub/OpenGL.Net/OpenGL.Net/Gl.cs:line 400
   at OpenGL.Gl.BindAPI() in /mnt/Data/GitHub/OpenGL.Net/OpenGL.Net/Gl.cs:line 337
   at Demo.Program.Main(String[] args) in /mnt/Data/Projects/SdlSharp/Demo/Program.cs:line 22

How did you solved the previous issue?

Just changed the dlopen flags.

Indeed your system lacks of libGL.so.1, maybe you can create a symbolic link to the actual GL library. On Windows the library opengl32.dll is found.

Look at the last code block 😐, its there.

> ls -l /usr/lib | grep libGL.so.1
lrwxrwxrwx.  1 root root       14 Nov 11 09:17 libGL.so.1 -> libGL.so.1.0.0
-rwxr-xr-x.  1 root root   404616 Nov 11 09:17 libGL.so.1.0.0