Opentk/Source/OpenTK/Platform/X11/GlxHelper.cs

146 lines
3.9 KiB
C#
Raw Normal View History

#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
2007-08-20 10:46:37 +00:00
using System.Collections.Generic;
using System.Text;
2008-01-23 00:26:58 +00:00
using System.Reflection;
using System.Runtime.InteropServices;
2007-08-20 10:46:37 +00:00
namespace OpenTK.Platform.X11
{
2008-01-23 00:01:03 +00:00
internal static partial class Glx
2007-08-20 10:46:37 +00:00
{
internal const string Library = "libGL.so.1";
// Disable BeforeFieldInit optimization.
static Glx() { }
2008-01-23 00:01:03 +00:00
2008-01-23 00:26:58 +00:00
#region static Delegate LoadDelegate(string name, Type signature)
/// <summary>
/// Creates a System.Delegate that can be used to call an OpenGL function, core or extension.
/// </summary>
/// <param name="name">The name of the Wgl function (eg. "wglNewList")</param>
/// <param name="signature">The signature of the OpenGL function.</param>
/// <returns>
/// A System.Delegate that can be used to call this OpenGL function, or null if the specified
/// function name did not correspond to an OpenGL function.
/// </returns>
static Delegate LoadDelegate(string name, Type signature)
{
Delegate d;
string realName = name.StartsWith("glx") ? name.Substring(3) : name;
if (typeof(Glx).GetMethod(realName,
BindingFlags.NonPublic | BindingFlags.Static) != null)
d = GetExtensionDelegate(name, signature) ??
Delegate.CreateDelegate(signature, typeof(Glx), realName);
else
d = GetExtensionDelegate(name, signature);
return d;
}
#endregion
#region private static Delegate GetExtensionDelegate(string name, Type signature)
/// <summary>
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
/// </summary>
/// <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
/// <param name="signature">The signature of the OpenGL function.</param>
/// <returns>
/// A System.Delegate that can be used to call this OpenGL function or null
/// if the function is not available in the current OpenGL context.
/// </returns>
private static Delegate GetExtensionDelegate(string name, Type signature)
{
IntPtr address = Glx.GetProcAddress(name);
if (address == IntPtr.Zero ||
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
return null;
else
return Marshal.GetDelegateForFunctionPointer(address, signature);
}
#endregion
2008-01-23 00:01:03 +00:00
#region internal static void LoadAll
internal static void LoadAll()
{
OpenTK.Platform.Utilities.LoadExtensions(typeof(Glx));
}
#endregion
2008-01-23 00:18:18 +00:00
#region internal static bool SupportsExtension(string p)
internal static bool SupportsExtension(string p)
{
throw new NotImplementedException();
}
#endregion
2007-08-20 10:46:37 +00:00
}
2008-01-23 00:01:03 +00:00
internal struct Status
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXFBConfig
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXPbuffer
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXContextID
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXHyperpipeNetworkPointer
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXHyperpipeConfig
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXHyperpipeConfigSGIX
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXHyperpipeConfigPointer
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXVideoSourceSGIX
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXFBConfigSGIX
{
}
2008-01-23 00:01:03 +00:00
internal struct GLXPbufferSGIX
{
}
2008-01-23 00:01:03 +00:00
internal struct DMparams
{
}
2008-01-23 00:01:03 +00:00
internal struct DMbuffer
{
}
2007-08-20 10:46:37 +00:00
}