Use glXGetProcAddressARB

According to the Linux OpenGL ABI, glXGetProcAddressARB must be statically exported by libGL. This does *not* hold true for glXGetProcAddress. We must used the ARB version instead.
Furthermore, glx entry points, unlike wgl, do not depend on any specific OpenGL context. This means we can load them in the constructor of the Glx class.
This commit is contained in:
parallels 2013-11-09 18:50:53 +01:00
parent 0bf8565c0f
commit 62d6791736
2 changed files with 29 additions and 5 deletions

View file

@ -352,7 +352,7 @@ namespace OpenTK.Platform.X11
public partial class Arb
{
#region CreateContextAttribs
#region CreateContextAttri
unsafe public static IntPtr CreateContextAttribs(IntPtr display, IntPtr fbconfig, IntPtr share_context, bool direct, int* attribs)
{
@ -371,6 +371,19 @@ namespace OpenTK.Platform.X11
}
#endregion
#region GetProcAddress
// The linux OpenGL ABI 3.6 (1999) requires
// that glXGetProcAddressARB be available as
// a static export. The same is *not* true
// for glXGetProcAddress, so we should use
// glXGetProcAddressARB instead.
// See http://www.opengl.org/registry/ABI/
[DllImport(Library, EntryPoint = "glXGetProcAddressARB")]
public static extern IntPtr GetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
#endregion
}
internal static partial class Delegates

View file

@ -20,17 +20,28 @@ namespace OpenTK.Platform.X11
const string Library = "libGL.so.1";
static readonly object sync_root = new object();
// Disable BeforeFieldInit optimization.
static Glx() { }
static Glx()
{
// GLX entry points are not bound to a context.
// This means we can load them without creating
// a context first! (unlike WGL)
// See
// for more details.
Debug.WriteLine("Loading GLX entry points.");
new Glx().LoadEntryPoints();
}
protected override object SyncRoot
{
get { return sync_root; }
}
protected override IntPtr GetAddress (string funcname)
protected override IntPtr GetAddress(string funcname)
{
return Glx.GetProcAddress(funcname);
// We must use glXGetProcAddressARB, *not*
// glXGetProcAddress. See comment on function
// signature.
return Glx.Arb.GetProcAddress(funcname);
}
#if false