Temp context not necessary for GLX

GLX entry points are not bound to a specific context. This means that, unlike WGL, GLX does not require a temporary context in order to load its entry points!
This commit is contained in:
Stefanos A 2013-11-09 11:07:37 +01:00
parent 6edaf8c3cf
commit 3c71634667

View file

@ -64,37 +64,22 @@ namespace OpenTK.Platform.X11
if (!glx_loaded) if (!glx_loaded)
{ {
Debug.WriteLine("Creating temporary context to load GLX extensions."); // GLX entry points are not bound to a context.
// This means we can load them without creating
// Create a temporary context to obtain the necessary function pointers. // a context first! (unlike WGL)
XVisualInfo visual = currentWindow.VisualInfo; // See http://dri.freedesktop.org/wiki/glXGetProcAddressNeverReturnsNULL/
IntPtr ctx = IntPtr.Zero; // for more details.
Debug.WriteLine("Loading GLX entry points.");
using (new XLock(Display)) new Glx().LoadEntryPoints();
{ glx_loaded = true;
ctx = Glx.CreateContext(Display, ref visual, IntPtr.Zero, true);
if (ctx == IntPtr.Zero)
ctx = Glx.CreateContext(Display, ref visual, IntPtr.Zero, false);
}
if (ctx != IntPtr.Zero)
{
new Glx().LoadEntryPoints();
using (new XLock(Display))
{
Glx.MakeCurrent(Display, IntPtr.Zero, IntPtr.Zero);
//Glx.DestroyContext(Display, ctx);
}
glx_loaded = true;
}
} }
// Try using the new context creation method. If it fails, fall back to the old one. // Try using the new context creation method. If it fails, fall back to the old one.
// For each of these methods, we try two times to create a context: // For each of these methods, we try two times to create a context:
// one with the "direct" flag intact, the other with the flag inversed. // one with the "direct" flag intact, the other with the flag inversed.
// HACK: It seems that Catalyst 9.1 - 9.4 on Linux have problems with contexts created through // HACK: It seems that Catalyst 9.1 - 9.4 on Linux have problems with contexts created through
// GLX_ARB_create_context, including hideous input lag, no vsync and other. Use legacy context // GLX_ARB_create_context, including hideous input lag, no vsync and other madness.
// creation if the user doesn't request a 3.0+ context. // Use legacy context creation if the user doesn't request a 3.0+ context.
if ((major * 10 + minor >= 30) && Glx.Delegates.glXCreateContextAttribsARB != null) if ((major * 10 + minor >= 30) && Glx.Delegates.glXCreateContextAttribsARB != null)
{ {
Debug.Write("Using GLX_ARB_create_context... "); Debug.Write("Using GLX_ARB_create_context... ");