BindAPI() creates a GLx dependency on OSx
Zukapin opened this issue · comments
Not sure if this is a bug, but it took me awhile to track down.
Using BindAPI() in OpenGL.Net/Gl.cs calls QueryVersionContext(), which calls DeviceContext.GetCurrentContext(), to verify a current context exists.
Lines 359 to 361 in 0b30190
On OSx, if you're not using GLx for windowing, DeviceContext.GetCurrentContext() will always fail with a 'NotSupportedException'.
OpenGL.Net/OpenGL.Net/DeviceContext.cs
Lines 688 to 692 in 0b30190
I'm using SDL2 as my windowing and context creation, so BindAPI() always fails.
It seems like I could work around this with an explicit GL version and extension suite call to BindAPI, but is the check to see if a current context exists required?
On this specific issue, I have to say that the check is really pedantic since the context is not effectively used in the method. But, a current context is really required, and the check is used to verify it. The BindAPI
overload taking the GL version works because the BindAPI
must not determine the runtime GL context version.
It is a good catch since BindAPI
should not rely on GL platform API. But I cannot support OSX since I have no such system. Anyway, I think it should work all the same. There are no other GetCurrentContext
references in the solution.
Ah. Wasn't sure if there was going to be a better way of fixing it.
Thank you!
I'm using SDL2 as my windowing and context creation, so BindAPI() always fails.
That's right. There is NO easy way to use OpenGL without also using X11(glx).
Apple gave us NSOpenGL
, which is an Objective-C/Swift API.
And there is no OpenGL API for C.
GLEW creates a wrapper and thus translates the C API call to Objective-C API call(NSOpenGL
).