using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace SharpGL
{
public partial class OpenGL
{
///
/// Determines whether a named extension function is supported.
///
/// Name of the extension function.
///
/// true if the extension function is supported; otherwise, false.
///
public bool IsExtensionFunctionSupported(string extensionFunctionName)
{
// Try and get the proc address for the function.
IntPtr procAddress = Win32.wglGetProcAddress(extensionFunctionName);
// As long as the pointer is non-zero, we can invoke the extension function.
return procAddress != IntPtr.Zero;
}
///
/// Returns a delegate for an extension function. This delegate can be called to execute the extension function.
///
/// The extension delegate type.
/// The delegate that points to the extension function.
private T GetDelegateFor() where T : class
{
// Get the type of the extension function.
Type delegateType = typeof(T);
// Get the name of the extension function.
string name = delegateType.Name;
// ftlPhysicsGuy - Better way
if (extensionFunctions.TryGetValue(name, out Delegate del) == false)
{
IntPtr proc = Win32.wglGetProcAddress(name);
if (proc == IntPtr.Zero)
throw new Exception("Extension function " + name + " not supported");
// Get the delegate for the function pointer.
del = Marshal.GetDelegateForFunctionPointer(proc, delegateType);
// Add to the dictionary.
extensionFunctions.Add(name, del);
}
return del as T;
}
///
/// The set of extension functions.
///
private Dictionary extensionFunctions = new Dictionary();
#region OpenGL 1.2
// Methods
public void BlendColor(float red, float green, float blue, float alpha)
{
GetDelegateFor()(red, green, blue, alpha);
}
public void BlendEquation(uint mode)
{
GetDelegateFor()(mode);
}
public void DrawRangeElements(uint mode, uint start, uint end, int count, uint type, IntPtr indices)
{
GetDelegateFor()(mode, start, end, count, type, indices);
}
public void TexImage3D(uint target, int level, int internalformat, int width, int height, int depth, int border, uint format, uint type, IntPtr pixels)
{
GetDelegateFor()(target, level, internalformat, width, height, depth, border, format, type, pixels);
}
public void TexSubImage3D(uint target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, uint type, IntPtr pixels)
{
GetDelegateFor()(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
}
public void CopyTexSubImage3D(uint target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height)
{
GetDelegateFor()(target, level, xoffset, yoffset, zoffset, x, y, width, height);
}
// Deprecated Methods
[Obsolete]
public void ColorTable(uint target, uint internalformat, int width, uint format, uint type, IntPtr table)
{
GetDelegateFor()(target, internalformat, width, format, type, table);
}
[Obsolete]
public void ColorTableParameterfv(uint target, uint pname, float[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void ColorTableParameteriv(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void CopyColorTable(uint target, uint internalformat, int x, int y, int width)
{
GetDelegateFor()(target, internalformat, x, y, width);
}
[Obsolete]
public void GetColorTable(uint target, uint format, uint type, IntPtr table)
{
GetDelegateFor()(target, format, type, table);
}
[Obsolete]
public void GetColorTableParameter(uint target, uint pname, float[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void GetColorTableParameter(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void ColorSubTable(uint target, int start, int count, uint format, uint type, IntPtr data)
{
GetDelegateFor()(target, start, count, format, type, data);
}
[Obsolete]
public void CopyColorSubTable(uint target, int start, int x, int y, int width)
{
GetDelegateFor()(target, start, x, y, width);
}
[Obsolete]
public void ConvolutionFilter1D(uint target, uint internalformat, int width, uint format, uint type, IntPtr image)
{
GetDelegateFor()(target, internalformat, width, format, type, image);
}
[Obsolete]
public void ConvolutionFilter2D(uint target, uint internalformat, int width, int height, uint format, uint type, IntPtr image)
{
GetDelegateFor()(target, internalformat, width, height, format, type, image);
}
[Obsolete]
public void ConvolutionParameter(uint target, uint pname, float parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void ConvolutionParameter(uint target, uint pname, float[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void ConvolutionParameter(uint target, uint pname, int parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void ConvolutionParameter(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void CopyConvolutionFilter1D(uint target, uint internalformat, int x, int y, int width)
{
GetDelegateFor()(target, internalformat, x, y, width);
}
[Obsolete]
public void CopyConvolutionFilter2D(uint target, uint internalformat, int x, int y, int width, int height)
{
GetDelegateFor()(target, internalformat, x, y, width, height);
}
[Obsolete]
public void GetConvolutionFilter(uint target, uint format, uint type, IntPtr image)
{
GetDelegateFor()(target, format, type, image);
}
[Obsolete]
public void GetConvolutionParameter(uint target, uint pname, float[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void GetConvolutionParameter(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void GetSeparableFilter(uint target, uint format, uint type, IntPtr row, IntPtr column, IntPtr span)
{
GetDelegateFor()(target, format, type, row, column, span);
}
[Obsolete]
public void SeparableFilter2D(uint target, uint internalformat, int width, int height, uint format, uint type, IntPtr row, IntPtr column)
{
GetDelegateFor()(target, internalformat, width, height, format, type, row, column);
}
[Obsolete]
public void GetHistogram(uint target, bool reset, uint format, uint type, IntPtr values)
{
GetDelegateFor()(target, reset, format, type, values);
}
[Obsolete]
public void GetHistogramParameter(uint target, uint pname, float[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void GetHistogramParameter(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void GetMinmax(uint target, bool reset, uint format, uint type, IntPtr values)
{
GetDelegateFor()(target, reset, format, type, values);
}
[Obsolete]
public void GetMinmaxParameter(uint target, uint pname, float[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void GetMinmaxParameter(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
[Obsolete]
public void Histogram(uint target, int width, uint internalformat, bool sink)
{
GetDelegateFor()(target, width, internalformat, sink);
}
[Obsolete]
public void Minmax(uint target, uint internalformat, bool sink)
{
GetDelegateFor()(target, internalformat, sink);
}
[Obsolete]
public void ResetHistogram(uint target)
{
GetDelegateFor()(target);
}
[Obsolete]
public void ResetMinmax(uint target)
{
GetDelegateFor()(target);
}
// Delegates
private delegate void glBlendColor (float red, float green, float blue, float alpha);
private delegate void glBlendEquation (uint mode);
private delegate void glDrawRangeElements (uint mode, uint start, uint end, int count, uint type, IntPtr indices);
private delegate void glTexImage3D (uint target, int level, int internalformat, int width, int height, int depth, int border, uint format, uint type, IntPtr pixels);
private delegate void glTexSubImage3D (uint target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, uint type, IntPtr pixels);
private delegate void glCopyTexSubImage3D (uint target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height);
private delegate void glColorTable (uint target, uint internalformat, int width, uint format, uint type, IntPtr table);
private delegate void glColorTableParameterfv (uint target, uint pname, float[] parameters);
private delegate void glColorTableParameteriv (uint target, uint pname, int[] parameters);
private delegate void glCopyColorTable (uint target, uint internalformat, int x, int y, int width);
private delegate void glGetColorTable (uint target, uint format, uint type, IntPtr table);
private delegate void glGetColorTableParameterfv (uint target, uint pname, float[] parameters);
private delegate void glGetColorTableParameteriv (uint target, uint pname, int[] parameters);
private delegate void glColorSubTable (uint target, int start, int count, uint format, uint type, IntPtr data);
private delegate void glCopyColorSubTable (uint target, int start, int x, int y, int width);
private delegate void glConvolutionFilter1D (uint target, uint internalformat, int width, uint format, uint type, IntPtr image);
private delegate void glConvolutionFilter2D (uint target, uint internalformat, int width, int height, uint format, uint type, IntPtr image);
private delegate void glConvolutionParameterf (uint target, uint pname, float parameters);
private delegate void glConvolutionParameterfv (uint target, uint pname, float[] parameters);
private delegate void glConvolutionParameteri (uint target, uint pname, int parameters);
private delegate void glConvolutionParameteriv (uint target, uint pname, int[] parameters);
private delegate void glCopyConvolutionFilter1D (uint target, uint internalformat, int x, int y, int width);
private delegate void glCopyConvolutionFilter2D (uint target, uint internalformat, int x, int y, int width, int height);
private delegate void glGetConvolutionFilter (uint target, uint format, uint type, IntPtr image);
private delegate void glGetConvolutionParameterfv (uint target, uint pname, float[] parameters);
private delegate void glGetConvolutionParameteriv (uint target, uint pname, int[] parameters);
private delegate void glGetSeparableFilter (uint target, uint format, uint type, IntPtr row, IntPtr column, IntPtr span);
private delegate void glSeparableFilter2D (uint target, uint internalformat, int width, int height, uint format, uint type, IntPtr row, IntPtr column);
private delegate void glGetHistogram (uint target, bool reset, uint format, uint type, IntPtr values);
private delegate void glGetHistogramParameterfv (uint target, uint pname, float[] parameters);
private delegate void glGetHistogramParameteriv (uint target, uint pname, int[] parameters);
private delegate void glGetMinmax (uint target, bool reset, uint format, uint type, IntPtr values);
private delegate void glGetMinmaxParameterfv (uint target, uint pname, float[] parameters);
private delegate void glGetMinmaxParameteriv (uint target, uint pname, int[] parameters);
private delegate void glHistogram (uint target, int width, uint internalformat, bool sink);
private delegate void glMinmax (uint target, uint internalformat, bool sink);
private delegate void glResetHistogram (uint target);
private delegate void glResetMinmax (uint target);
// Constants
public const uint GL_UNSIGNED_BYTE_3_3_2 = 0x8032;
public const uint GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
public const uint GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
public const uint GL_UNSIGNED_INT_8_8_8_8 = 0x8035;
public const uint GL_UNSIGNED_INT_10_10_10_2 = 0x8036;
public const uint GL_TEXTURE_BINDING_3D = 0x806A;
public const uint GL_PACK_SKIP_IMAGES = 0x806B;
public const uint GL_PACK_IMAGE_HEIGHT = 0x806C;
public const uint GL_UNPACK_SKIP_IMAGES = 0x806D;
public const uint GL_UNPACK_IMAGE_HEIGHT = 0x806E;
public const uint GL_TEXTURE_3D = 0x806F;
public const uint GL_PROXY_TEXTURE_3D = 0x8070;
public const uint GL_TEXTURE_DEPTH = 0x8071;
public const uint GL_TEXTURE_WRAP_R = 0x8072;
public const uint GL_MAX_3D_TEXTURE_SIZE = 0x8073;
public const uint GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362;
public const uint GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
public const uint GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364;
public const uint GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365;
public const uint GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366;
public const uint GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
public const uint GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;
public const uint GL_BGR = 0x80E0;
public const uint GL_BGRA = 0x80E1;
public const uint GL_MAX_ELEMENTS_VERTICES = 0x80E8;
public const uint GL_MAX_ELEMENTS_INDICES = 0x80E9;
public const uint GL_CLAMP_TO_EDGE = 0x812F;
public const uint GL_TEXTURE_MIN_LOD = 0x813A;
public const uint GL_TEXTURE_MAX_LOD = 0x813B;
public const uint GL_TEXTURE_BASE_LEVEL = 0x813C;
public const uint GL_TEXTURE_MAX_LEVEL = 0x813D;
public const uint GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12;
public const uint GL_SMOOTH_POINT_SIZE_GRANULARITY = 0x0B13;
public const uint GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22;
public const uint GL_SMOOTH_LINE_WIDTH_GRANULARITY = 0x0B23;
public const uint GL_ALIASED_LINE_WIDTH_RANGE = 0x846E;
#endregion
#region OpenGL 1.3
// Methods
public void ActiveTexture(uint texture)
{
GetDelegateFor()(texture);
}
public void SampleCoverage(float value, bool invert)
{
GetDelegateFor()(value, invert);
}
public void CompressedTexImage3D(uint target, int level, uint internalformat, int width, int height, int depth, int border, int imageSize, IntPtr data)
{
GetDelegateFor()(target, level, internalformat, width, height, depth, border, imageSize, data);
}
public void CompressedTexImage2D(uint target, int level, uint internalformat, int width, int height, int border, int imageSize, IntPtr data)
{
GetDelegateFor()(target, level, internalformat, width, height, border, imageSize, data);
}
public void CompressedTexImage1D(uint target, int level, uint internalformat, int width, int border, int imageSize, IntPtr data)
{
GetDelegateFor()(target, level, internalformat, width, border, imageSize, data);
}
public void CompressedTexSubImage3D(uint target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, int imageSize, IntPtr data)
{
GetDelegateFor()(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
}
public void CompressedTexSubImage2D(uint target, int level, int xoffset, int yoffset, int width, int height, uint format, int imageSize, IntPtr data)
{
GetDelegateFor()(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
public void CompressedTexSubImage1D(uint target, int level, int xoffset, int width, uint format, int imageSize, IntPtr data)
{
GetDelegateFor()(target, level, xoffset, width, format, imageSize, data);
}
public void GetCompressedTexImage(uint target, int level, IntPtr img)
{
GetDelegateFor()(target, level, img);
}
// Deprecated Methods
[Obsolete]
public void ClientActiveTexture(uint texture)
{
GetDelegateFor()(texture);
}
[Obsolete]
public void MultiTexCoord1(uint target, double s)
{
GetDelegateFor()(target, s);
}
[Obsolete]
public void MultiTexCoord1(uint target, double[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord1(uint target, float s)
{
GetDelegateFor()(target, s);
}
[Obsolete]
public void MultiTexCoord1(uint target, float[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord1(uint target, int s)
{
GetDelegateFor()(target, s);
}
[Obsolete]
public void MultiTexCoord1(uint target, int[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord1(uint target, short s)
{
GetDelegateFor()(target, s);
}
[Obsolete]
public void MultiTexCoord1(uint target, short[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord2(uint target, double s, double t)
{
GetDelegateFor()(target, s, t);
}
[Obsolete]
public void MultiTexCoord2(uint target, double[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord2(uint target, float s, float t)
{
GetDelegateFor()(target, s, t);
}
[Obsolete]
public void MultiTexCoord2(uint target, float[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord2(uint target, int s, int t)
{
GetDelegateFor()(target, s, t);
}
[Obsolete]
public void MultiTexCoord2(uint target, int[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord2(uint target, short s, short t)
{
GetDelegateFor()(target, s, t);
}
[Obsolete]
public void MultiTexCoord2(uint target, short[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord3(uint target, double s, double t, double r)
{
GetDelegateFor()(target, s, t, r);
}
[Obsolete]
public void MultiTexCoord3(uint target, double[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord3(uint target, float s, float t, float r)
{
GetDelegateFor()(target, s, t, r);
}
[Obsolete]
public void MultiTexCoord3(uint target, float[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord3(uint target, int s, int t, int r)
{
GetDelegateFor()(target, s, t, r);
}
[Obsolete]
public void MultiTexCoord3(uint target, int[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord3(uint target, short s, short t, short r)
{
GetDelegateFor()(target, s, t, r);
}
[Obsolete]
public void MultiTexCoord3(uint target, short[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord4(uint target, double s, double t, double r, double q)
{
GetDelegateFor()(target, s, t, r, q);
}
[Obsolete]
public void MultiTexCoord4(uint target, double[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord4(uint target, float s, float t, float r, float q)
{
GetDelegateFor()(target, s, t, r, q);
}
[Obsolete]
public void MultiTexCoord4(uint target, float[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord4(uint target, int s, int t, int r, int q)
{
GetDelegateFor()(target, s, t, r, q);
}
[Obsolete]
public void MultiTexCoord4(uint target, int[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void MultiTexCoord4(uint target, short s, short t, short r, short q)
{
GetDelegateFor()(target, s, t, r, q);
}
[Obsolete]
public void MultiTexCoord4(uint target, short[] v)
{
GetDelegateFor()(target, v);
}
[Obsolete]
public void LoadTransposeMatrix(float[] m)
{
GetDelegateFor()(m);
}
[Obsolete]
public void LoadTransposeMatrix(double[] m)
{
GetDelegateFor()(m);
}
[Obsolete]
public void MultTransposeMatrix(float[] m)
{
GetDelegateFor()(m);
}
[Obsolete]
public void MultTransposeMatrix(double[] m)
{
GetDelegateFor()(m);
}
// Delegates
private delegate void glActiveTexture (uint texture);
private delegate void glSampleCoverage (float value, bool invert);
private delegate void glCompressedTexImage3D (uint target, int level, uint internalformat, int width, int height, int depth, int border, int imageSize, IntPtr data);
private delegate void glCompressedTexImage2D (uint target, int level, uint internalformat, int width, int height, int border, int imageSize, IntPtr data);
private delegate void glCompressedTexImage1D (uint target, int level, uint internalformat, int width, int border, int imageSize, IntPtr data);
private delegate void glCompressedTexSubImage3D (uint target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, int imageSize, IntPtr data);
private delegate void glCompressedTexSubImage2D (uint target, int level, int xoffset, int yoffset, int width, int height, uint format, int imageSize, IntPtr data);
private delegate void glCompressedTexSubImage1D (uint target, int level, int xoffset, int width, uint format, int imageSize, IntPtr data);
private delegate void glGetCompressedTexImage (uint target, int level, IntPtr img);
private delegate void glClientActiveTexture (uint texture);
private delegate void glMultiTexCoord1d (uint target, double s);
private delegate void glMultiTexCoord1dv (uint target, double[] v);
private delegate void glMultiTexCoord1f (uint target, float s);
private delegate void glMultiTexCoord1fv (uint target, float[] v);
private delegate void glMultiTexCoord1i (uint target, int s);
private delegate void glMultiTexCoord1iv (uint target, int[] v);
private delegate void glMultiTexCoord1s (uint target, short s);
private delegate void glMultiTexCoord1sv (uint target, short[] v);
private delegate void glMultiTexCoord2d (uint target, double s, double t);
private delegate void glMultiTexCoord2dv (uint target, double[] v);
private delegate void glMultiTexCoord2f (uint target, float s, float t);
private delegate void glMultiTexCoord2fv (uint target, float[] v);
private delegate void glMultiTexCoord2i (uint target, int s, int t);
private delegate void glMultiTexCoord2iv (uint target, int[] v);
private delegate void glMultiTexCoord2s (uint target, short s, short t);
private delegate void glMultiTexCoord2sv (uint target, short[] v);
private delegate void glMultiTexCoord3d (uint target, double s, double t, double r);
private delegate void glMultiTexCoord3dv (uint target, double[] v);
private delegate void glMultiTexCoord3f (uint target, float s, float t, float r);
private delegate void glMultiTexCoord3fv (uint target, float[] v);
private delegate void glMultiTexCoord3i (uint target, int s, int t, int r);
private delegate void glMultiTexCoord3iv (uint target, int[] v);
private delegate void glMultiTexCoord3s (uint target, short s, short t, short r);
private delegate void glMultiTexCoord3sv (uint target, short[] v);
private delegate void glMultiTexCoord4d (uint target, double s, double t, double r, double q);
private delegate void glMultiTexCoord4dv (uint target, double[] v);
private delegate void glMultiTexCoord4f (uint target, float s, float t, float r, float q);
private delegate void glMultiTexCoord4fv (uint target, float[] v);
private delegate void glMultiTexCoord4i (uint target, int s, int t, int r, int q);
private delegate void glMultiTexCoord4iv (uint target, int[] v);
private delegate void glMultiTexCoord4s (uint target, short s, short t, short r, short q);
private delegate void glMultiTexCoord4sv (uint target, short[] v);
private delegate void glLoadTransposeMatrixf (float[] m);
private delegate void glLoadTransposeMatrixd (double[] m);
private delegate void glMultTransposeMatrixf (float[] m);
private delegate void glMultTransposeMatrixd (double[] m);
// Constants
public const uint GL_TEXTURE0 = 0x84C0;
public const uint GL_TEXTURE1 = 0x84C1;
public const uint GL_TEXTURE2 = 0x84C2;
public const uint GL_TEXTURE3 = 0x84C3;
public const uint GL_TEXTURE4 = 0x84C4;
public const uint GL_TEXTURE5 = 0x84C5;
public const uint GL_TEXTURE6 = 0x84C6;
public const uint GL_TEXTURE7 = 0x84C7;
public const uint GL_TEXTURE8 = 0x84C8;
public const uint GL_TEXTURE9 = 0x84C9;
public const uint GL_TEXTURE10 = 0x84CA;
public const uint GL_TEXTURE11 = 0x84CB;
public const uint GL_TEXTURE12 = 0x84CC;
public const uint GL_TEXTURE13 = 0x84CD;
public const uint GL_TEXTURE14 = 0x84CE;
public const uint GL_TEXTURE15 = 0x84CF;
public const uint GL_TEXTURE16 = 0x84D0;
public const uint GL_TEXTURE17 = 0x84D1;
public const uint GL_TEXTURE18 = 0x84D2;
public const uint GL_TEXTURE19 = 0x84D3;
public const uint GL_TEXTURE20 = 0x84D4;
public const uint GL_TEXTURE21 = 0x84D5;
public const uint GL_TEXTURE22 = 0x84D6;
public const uint GL_TEXTURE23 = 0x84D7;
public const uint GL_TEXTURE24 = 0x84D8;
public const uint GL_TEXTURE25 = 0x84D9;
public const uint GL_TEXTURE26 = 0x84DA;
public const uint GL_TEXTURE27 = 0x84DB;
public const uint GL_TEXTURE28 = 0x84DC;
public const uint GL_TEXTURE29 = 0x84DD;
public const uint GL_TEXTURE30 = 0x84DE;
public const uint GL_TEXTURE31 = 0x84DF;
public const uint GL_ACTIVE_TEXTURE = 0x84E0;
public const uint GL_MULTISAMPLE = 0x809D;
public const uint GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
public const uint GL_SAMPLE_ALPHA_TO_ONE = 0x809F;
public const uint GL_SAMPLE_COVERAGE = 0x80A0;
public const uint GL_SAMPLE_BUFFERS = 0x80A8;
public const uint GL_SAMPLES = 0x80A9;
public const uint GL_SAMPLE_COVERAGE_VALUE = 0x80AA;
public const uint GL_SAMPLE_COVERAGE_INVERT = 0x80AB;
public const uint GL_TEXTURE_CUBE_MAP = 0x8513;
public const uint GL_TEXTURE_BINDING_CUBE_MAP = 0x8514;
public const uint GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
public const uint GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
public const uint GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
public const uint GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
public const uint GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
public const uint GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
public const uint GL_PROXY_TEXTURE_CUBE_MAP = 0x851B;
public const uint GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
public const uint GL_COMPRESSED_RGB = 0x84ED;
public const uint GL_COMPRESSED_RGBA = 0x84EE;
public const uint GL_TEXTURE_COMPRESSION_HINT = 0x84EF;
public const uint GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86A0;
public const uint GL_TEXTURE_COMPRESSED = 0x86A1;
public const uint GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
public const uint GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
public const uint GL_CLAMP_TO_BORDER = 0x812D;
#endregion
#region OpenGL 1.4
// Methods
public void BlendFuncSeparate(uint sfactorRGB, uint dfactorRGB, uint sfactorAlpha, uint dfactorAlpha)
{
GetDelegateFor()(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
}
public void MultiDrawArrays(uint mode, int[] first, int[] count, int primcount)
{
GetDelegateFor()(mode, first, count, primcount);
}
public void MultiDrawElements(uint mode, int[] count, uint type, IntPtr indices, int primcount)
{
GetDelegateFor()(mode, count, type, indices, primcount);
}
public void PointParameter(uint pname, float parameter)
{
GetDelegateFor()(pname, parameter);
}
public void PointParameter(uint pname, float[] parameters)
{
GetDelegateFor()(pname, parameters);
}
public void PointParameter(uint pname, int parameter)
{
GetDelegateFor()(pname, parameter);
}
public void PointParameter(uint pname, int[] parameters)
{
GetDelegateFor()(pname, parameters);
}
// Deprecated Methods
[Obsolete]
public void FogCoord(float coord)
{
GetDelegateFor()(coord);
}
[Obsolete]
public void FogCoord(float[] coord)
{
GetDelegateFor()(coord);
}
[Obsolete]
public void FogCoord(double coord)
{
GetDelegateFor()(coord);
}
[Obsolete]
public void FogCoord(double[] coord)
{
GetDelegateFor()(coord);
}
[Obsolete]
public void FogCoordPointer(uint type, int stride, IntPtr pointer)
{
GetDelegateFor()(type, stride, pointer);
}
[Obsolete]
public void SecondaryColor3(sbyte red, sbyte green, sbyte blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(sbyte[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(double red, double green, double blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(double[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(float red, float green, float blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(float[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(int red, int green, int blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(int[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(short red, short green, short blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(short[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(byte red, byte green, byte blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(byte[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(uint red, uint green, uint blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(uint[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColor3(ushort red, ushort green, ushort blue)
{
GetDelegateFor()(red, green, blue);
}
[Obsolete]
public void SecondaryColor3(ushort[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void SecondaryColorPointer(int size, uint type, int stride, IntPtr pointer)
{
GetDelegateFor()(size, type, stride, pointer);
}
[Obsolete]
public void WindowPos2(double x, double y)
{
GetDelegateFor()(x, y);
}
[Obsolete]
public void WindowPos2(double[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos2(float x, float y)
{
GetDelegateFor()(x, y);
}
[Obsolete]
public void WindowPos2(float[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos2(int x, int y)
{
GetDelegateFor()(x, y);
}
[Obsolete]
public void WindowPos2(int[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos2(short x, short y)
{
GetDelegateFor()(x, y);
}
[Obsolete]
public void WindowPos2(short[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos3(double x, double y, double z)
{
GetDelegateFor()(x, y, z);
}
[Obsolete]
public void WindowPos3(double[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos3(float x, float y, float z)
{
GetDelegateFor()(x, y, z);
}
[Obsolete]
public void WindowPos3(float[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos3(int x, int y, int z)
{
GetDelegateFor()(x, y, z);
}
[Obsolete]
public void WindowPos3(int[] v)
{
GetDelegateFor()(v);
}
[Obsolete]
public void WindowPos3(short x, short y, short z)
{
GetDelegateFor()(x, y, z);
}
[Obsolete]
public void WindowPos3(short[] v)
{
GetDelegateFor()(v);
}
// Delegates
private delegate void glBlendFuncSeparate (uint sfactorRGB, uint dfactorRGB, uint sfactorAlpha, uint dfactorAlpha);
private delegate void glMultiDrawArrays (uint mode, int[] first, int[] count, int primcount);
private delegate void glMultiDrawElements (uint mode, int[] count, uint type, IntPtr indices, int primcount);
private delegate void glPointParameterf (uint pname, float parameter);
private delegate void glPointParameterfv (uint pname, float[] parameters);
private delegate void glPointParameteri (uint pname, int parameter);
private delegate void glPointParameteriv (uint pname, int[] parameters);
private delegate void glFogCoordf (float coord);
private delegate void glFogCoordfv (float[] coord);
private delegate void glFogCoordd (double coord);
private delegate void glFogCoorddv (double[] coord);
private delegate void glFogCoordPointer (uint type, int stride, IntPtr pointer);
private delegate void glSecondaryColor3b (sbyte red, sbyte green, sbyte blue);
private delegate void glSecondaryColor3bv (sbyte[] v);
private delegate void glSecondaryColor3d (double red, double green, double blue);
private delegate void glSecondaryColor3dv (double[] v);
private delegate void glSecondaryColor3f (float red, float green, float blue);
private delegate void glSecondaryColor3fv (float[] v);
private delegate void glSecondaryColor3i (int red, int green, int blue);
private delegate void glSecondaryColor3iv (int[] v);
private delegate void glSecondaryColor3s (short red, short green, short blue);
private delegate void glSecondaryColor3sv (short[] v);
private delegate void glSecondaryColor3ub (byte red, byte green, byte blue);
private delegate void glSecondaryColor3ubv (byte[] v);
private delegate void glSecondaryColor3ui (uint red, uint green, uint blue);
private delegate void glSecondaryColor3uiv (uint[] v);
private delegate void glSecondaryColor3us (ushort red, ushort green, ushort blue);
private delegate void glSecondaryColor3usv (ushort[] v);
private delegate void glSecondaryColorPointer (int size, uint type, int stride, IntPtr pointer);
private delegate void glWindowPos2d (double x, double y);
private delegate void glWindowPos2dv (double[] v);
private delegate void glWindowPos2f (float x, float y);
private delegate void glWindowPos2fv (float[] v);
private delegate void glWindowPos2i (int x, int y);
private delegate void glWindowPos2iv (int[] v);
private delegate void glWindowPos2s (short x, short y);
private delegate void glWindowPos2sv (short[] v);
private delegate void glWindowPos3d (double x, double y, double z);
private delegate void glWindowPos3dv (double[] v);
private delegate void glWindowPos3f (float x, float y, float z);
private delegate void glWindowPos3fv (float[] v);
private delegate void glWindowPos3i (int x, int y, int z);
private delegate void glWindowPos3iv (int[] v);
private delegate void glWindowPos3s (short x, short y, short z);
private delegate void glWindowPos3sv (short[] v);
// Constants
public const uint GL_BLEND_DST_RGB = 0x80C8;
public const uint GL_BLEND_SRC_RGB = 0x80C9;
public const uint GL_BLEND_DST_ALPHA = 0x80CA;
public const uint GL_BLEND_SRC_ALPHA = 0x80CB;
public const uint GL_POINT_FADE_THRESHOLD_SIZE = 0x8128;
public const uint GL_DEPTH_COMPONENT16 = 0x81A5;
public const uint GL_DEPTH_COMPONENT24 = 0x81A6;
public const uint GL_DEPTH_COMPONENT32 = 0x81A7;
public const uint GL_MIRRORED_REPEAT = 0x8370;
public const uint GL_MAX_TEXTURE_LOD_BIAS = 0x84FD;
public const uint GL_TEXTURE_LOD_BIAS = 0x8501;
public const uint GL_INCR_WRAP = 0x8507;
public const uint GL_DECR_WRAP = 0x8508;
public const uint GL_TEXTURE_DEPTH_SIZE = 0x884A;
public const uint GL_TEXTURE_COMPARE_MODE = 0x884C;
public const uint GL_TEXTURE_COMPARE_FUNC = 0x884D;
#endregion
#region OpenGL 1.5
// Methods
public void GenQueries(int n, uint[] ids)
{
GetDelegateFor()(n, ids);
}
public void DeleteQueries(int n, uint[] ids)
{
GetDelegateFor()(n, ids);
}
public bool IsQuery(uint id)
{
return (bool)GetDelegateFor()(id);
}
public void BeginQuery(uint target, uint id)
{
GetDelegateFor()(target, id);
}
public void EndQuery(uint target)
{
GetDelegateFor()(target);
}
public void GetQuery(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
public void GetQueryObject(uint id, uint pname, int[] parameters)
{
GetDelegateFor()(id, pname, parameters);
}
public void GetQueryObject(uint id, uint pname, uint[] parameters)
{
GetDelegateFor()(id, pname, parameters);
}
public void BindBuffer(uint target, uint buffer)
{
GetDelegateFor()(target, buffer);
}
public void DeleteBuffers(int n, uint[] buffers)
{
GetDelegateFor()(n, buffers);
}
public void GenBuffers(int n, uint[] buffers)
{
GetDelegateFor()(n, buffers);
}
public bool IsBuffer(uint buffer)
{
return (bool)GetDelegateFor()(buffer);
}
public void BufferData(uint target, int size, IntPtr data, uint usage)
{
GetDelegateFor()(target, size, data, usage);
}
public void BufferData(uint target, float[] data, uint usage)
{
IntPtr p = Marshal.AllocHGlobal(data.Length * sizeof(float));
Marshal.Copy(data, 0, p, data.Length);
GetDelegateFor()(target, data.Length * sizeof(float), p, usage);
Marshal.FreeHGlobal(p);
}
public void BufferData(uint target, ushort[] data, uint usage)
{
var dataSize = data.Length * sizeof(ushort);
IntPtr p = Marshal.AllocHGlobal(dataSize);
var shortData = new short[data.Length];
Buffer.BlockCopy(data, 0, shortData, 0, dataSize);
Marshal.Copy(shortData, 0, p, data.Length);
GetDelegateFor()(target, dataSize, p, usage);
Marshal.FreeHGlobal(p);
}
public void BufferSubData(uint target, int offset, int size, IntPtr data)
{
GetDelegateFor()(target, offset, size, data);
}
public void GetBufferSubData(uint target, int offset, int size, IntPtr data)
{
GetDelegateFor()(target, offset, size, data);
}
public IntPtr MapBuffer(uint target, uint access)
{
return (IntPtr)GetDelegateFor()(target, access);
}
public bool UnmapBuffer(uint target)
{
return (bool)GetDelegateFor()(target);
}
public void GetBufferParameter(uint target, uint pname, int[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
public void GetBufferPointer(uint target, uint pname, IntPtr[] parameters)
{
GetDelegateFor()(target, pname, parameters);
}
// Delegates
private delegate void glGenQueries (int n, uint[] ids);
private delegate void glDeleteQueries (int n, uint[] ids);
private delegate bool glIsQuery (uint id);
private delegate void glBeginQuery (uint target, uint id);
private delegate void glEndQuery (uint target);
private delegate void glGetQueryiv (uint target, uint pname, int[] parameters);
private delegate void glGetQueryObjectiv (uint id, uint pname, int[] parameters);
private delegate void glGetQueryObjectuiv (uint id, uint pname, uint[] parameters);
private delegate void glBindBuffer (uint target, uint buffer);
private delegate void glDeleteBuffers (int n, uint[] buffers);
private delegate void glGenBuffers (int n, uint[] buffers);
private delegate bool glIsBuffer (uint buffer);
private delegate void glBufferData(uint target, int size, IntPtr data, uint usage);
private delegate void glBufferSubData (uint target, int offset, int size, IntPtr data);
private delegate void glGetBufferSubData (uint target, int offset, int size, IntPtr data);
private delegate IntPtr glMapBuffer (uint target, uint access);
private delegate bool glUnmapBuffer (uint target);
private delegate void glGetBufferParameteriv (uint target, uint pname, int[] parameters);
private delegate void glGetBufferPointerv (uint target, uint pname, IntPtr[] parameters);
// Constants
public const uint GL_BUFFER_SIZE = 0x8764;
public const uint GL_BUFFER_USAGE = 0x8765;
public const uint GL_QUERY_COUNTER_BITS = 0x8864;
public const uint GL_CURRENT_QUERY = 0x8865;
public const uint GL_QUERY_RESULT = 0x8866;
public const uint GL_QUERY_RESULT_AVAILABLE = 0x8867;
public const uint GL_ARRAY_BUFFER = 0x8892;
public const uint GL_ELEMENT_ARRAY_BUFFER = 0x8893;
public const uint GL_ARRAY_BUFFER_BINDING = 0x8894;
public const uint GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
public const uint GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
public const uint GL_READ_ONLY = 0x88B8;
public const uint GL_WRITE_ONLY = 0x88B9;
public const uint GL_READ_WRITE = 0x88BA;
public const uint GL_BUFFER_ACCESS = 0x88BB;
public const uint GL_BUFFER_MAPPED = 0x88BC;
public const uint GL_BUFFER_MAP_POINTER = 0x88BD;
public const uint GL_STREAM_DRAW = 0x88E0;
public const uint GL_STREAM_READ = 0x88E1;
public const uint GL_STREAM_COPY = 0x88E2;
public const uint GL_STATIC_DRAW = 0x88E4;
public const uint GL_STATIC_READ = 0x88E5;
public const uint GL_STATIC_COPY = 0x88E6;
public const uint GL_DYNAMIC_DRAW = 0x88E8;
public const uint GL_DYNAMIC_READ = 0x88E9;
public const uint GL_DYNAMIC_COPY = 0x88EA;
public const uint GL_SAMPLES_PASSED = 0x8914;
#endregion
#region OpenGL 2.0
// Methods
public void BlendEquationSeparate (uint modeRGB, uint modeAlpha)
{
GetDelegateFor()(modeRGB, modeAlpha);
}
public void DrawBuffers (int n, uint[] bufs)
{
GetDelegateFor()(n, bufs);
}
public void StencilOpSeparate (uint face, uint sfail, uint dpfail, uint dppass)
{
GetDelegateFor()(face, sfail, dpfail, dppass);
}
public void StencilFuncSeparate (uint face, uint func, int reference, uint mask)
{
GetDelegateFor()(face, func, reference, mask);
}
public void StencilMaskSeparate (uint face, uint mask)
{
GetDelegateFor()(face, mask);
}
public void AttachShader (uint program, uint shader)
{
GetDelegateFor()(program, shader);
}
public void BindAttribLocation (uint program, uint index, string name)
{
GetDelegateFor()(program, index, name);
}
///
/// Compile a shader object
///
/// Specifies the shader object to be compiled.
public void CompileShader (uint shader)
{
GetDelegateFor()(shader);
}
public uint CreateProgram ()
{
return (uint)GetDelegateFor()();
}
///
/// Create a shader object
///
/// Specifies the type of shader to be created. Must be either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
/// This function returns 0 if an error occurs creating the shader object. Otherwise the shader id is returned.
public uint CreateShader (uint type)
{
return (uint)GetDelegateFor()(type);
}
public void DeleteProgram (uint program)
{
GetDelegateFor()(program);
}
public void DeleteShader (uint shader)
{
GetDelegateFor()(shader);
}
public void DetachShader (uint program, uint shader)
{
GetDelegateFor()(program, shader);
}
public void DisableVertexAttribArray (uint index)
{
GetDelegateFor()(index);
}
public void EnableVertexAttribArray (uint index)
{
GetDelegateFor()(index);
}
///
/// Return information about an active attribute variable
///
/// Specifies the program object to be queried.
/// Specifies the index of the attribute variable to be queried.
/// Specifies the maximum number of characters OpenGL is allowed to write in the character buffer indicated by .
/// Returns the number of characters actually written by OpenGL in the string indicated by name (excluding the null terminator) if a value other than NULL is passed.
/// Returns the size of the attribute variable.
/// Returns the data type of the attribute variable.
/// Returns a null terminated string containing the name of the attribute variable.
public void GetActiveAttrib (uint program, uint index, int bufSize, out int length, out int size, out uint type, out string name)
{
var builder = new StringBuilder(bufSize);
GetDelegateFor()(program, index, bufSize, out length, out size, out type, builder);
name = builder.ToString();
}
///
/// Return information about an active uniform variable
///
/// Specifies the program object to be queried.
/// Specifies the index of the uniform variable to be queried.
/// Specifies the maximum number of characters OpenGL is allowed
/// to write in the character buffer indicated by .
/// Returns the number of characters actually written by OpenGL in the string indicated by name
/// (excluding the null terminator) if a value other than NULL is passed.
/// Returns the size of the uniform variable.
/// Returns the data type of the uniform variable.
/// Returns a null terminated string containing the name of the uniform variable.
public void GetActiveUniform (uint program, uint index, int bufSize, out int length, out int size, out uint type, out string name)
{
var builder = new StringBuilder(bufSize);
GetDelegateFor()(program, index, bufSize, out length, out size, out type, builder);
name = builder.ToString();
}
public void GetAttachedShaders (uint program, int maxCount, int[] count, uint[] obj)
{
GetDelegateFor()(program, maxCount, count, obj);
}
public int GetAttribLocation (uint program, string name)
{
return (int)GetDelegateFor()(program, name);
}
public void GetProgram (uint program, uint pname, int[] parameters)
{
GetDelegateFor()(program, pname, parameters);
}
public void GetProgramInfoLog(uint program, int bufSize, IntPtr length, StringBuilder infoLog)
{
GetDelegateFor()(program, bufSize, length, infoLog);
}
public void GetShader (uint shader, uint pname, int[] parameters)
{
GetDelegateFor()(shader, pname, parameters);
}
public void GetShaderInfoLog (uint shader, int bufSize, IntPtr length, StringBuilder infoLog)
{
GetDelegateFor()(shader, bufSize, length, infoLog);
}
public void GetShaderSource(uint shader, int bufSize, IntPtr length, StringBuilder source)
{
GetDelegateFor()(shader, bufSize, length, source);
}
///
/// Returns an integer that represents the location of a specific uniform variable within a program object. name must be a null terminated string that contains no white space. name must be an active uniform variable name in program that is not a structure, an array of structures, or a subcomponent of a vector or a matrix. This function returns -1 if name does not correspond to an active uniform variable in program, if name starts with the reserved prefix "gl_", or if name is associated with an atomic counter or a named uniform block.
///
/// Specifies the program object to be queried.
/// Points to a null terminated string containing the name of the uniform variable whose location is to be queried.
///
public int GetUniformLocation (uint program, string name)
{
return (int)GetDelegateFor()(program, name);
}
public void GetUniform (uint program, int location, float[] parameters)
{
GetDelegateFor()(program, location, parameters);
}
public void GetUniform (uint program, int location, int[] parameters)
{
GetDelegateFor()(program, location, parameters);
}
public void GetVertexAttrib (uint index, uint pname, double[] parameters)
{
GetDelegateFor()(index, pname, parameters);
}
public void GetVertexAttrib (uint index, uint pname, float[] parameters)
{
GetDelegateFor()(index, pname, parameters);
}
public void GetVertexAttrib (uint index, uint pname, int[] parameters)
{
GetDelegateFor()(index, pname, parameters);
}
public void GetVertexAttribPointer(uint index, uint pname, IntPtr pointer)
{
GetDelegateFor()(index, pname, pointer);
}
public bool IsProgram (uint program)
{
return (bool)GetDelegateFor()(program);
}
public bool IsShader (uint shader)
{
return (bool)GetDelegateFor()(shader);
}
public void LinkProgram (uint program)
{
GetDelegateFor()(program);
}
///
/// Replace the source code in a shader object
///
/// Specifies the handle of the shader object whose source code is to be replaced.
/// The source.
public void ShaderSource (uint shader, string source)
{
// Remember, the function takes an array of strings but concatenates them, so we should NOT split into lines!
GetDelegateFor()(shader, 1, new[] { source }, new[] { source.Length });
}
public static IntPtr StringToPtrAnsi(string str)
{
if (string.IsNullOrEmpty(str))
return IntPtr.Zero;
byte[] bytes = Encoding.ASCII.GetBytes(str + '\0');
IntPtr strPtr = Marshal.AllocHGlobal(bytes.Length);
Marshal.Copy(bytes, 0, strPtr, bytes.Length);
return strPtr;
}
public void UseProgram (uint program)
{
GetDelegateFor()(program);
}
public void Uniform1 (int location, float v0)
{
GetDelegateFor()(location, v0);
}
public void Uniform2 (int location, float v0, float v1)
{
GetDelegateFor()(location, v0, v1);
}
public void Uniform3 (int location, float v0, float v1, float v2)
{
GetDelegateFor()(location, v0, v1, v2);
}
public void Uniform4 (int location, float v0, float v1, float v2, float v3)
{
GetDelegateFor()(location, v0, v1, v2, v3);
}
public void Uniform1 (int location, int v0)
{
GetDelegateFor()(location, v0);
}
public void Uniform2 (int location, int v0, int v1)
{
GetDelegateFor()(location, v0, v1);
}
public void Uniform3(int location, int v0, int v1, int v2)
{
GetDelegateFor()(location, v0, v1, v2);
}
public void Uniform (int location, int v0, int v1, int v2, int v3)
{
GetDelegateFor()(location, v0, v1, v2, v3);
}
public void Uniform1 (int location, int count, float[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform2 (int location, int count, float[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform3 (int location, int count, float[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform4 (int location, int count, float[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform1 (int location, int count, int[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform2 (int location, int count, int[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform3 (int location, int count, int[] value)
{
GetDelegateFor()(location, count, value);
}
public void Uniform4 (int location, int count, int[] value)
{
GetDelegateFor()(location, count, value);
}
public void UniformMatrix2 (int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix3 (int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix4 (int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void ValidateProgram (uint program)
{
GetDelegateFor()(program);
}
public void VertexAttrib1 (uint index, double x)
{
GetDelegateFor()(index, x);
}
public void VertexAttrib1 (uint index, double[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib (uint index, float x)
{
GetDelegateFor()(index, x);
}
public void VertexAttrib1 (uint index, float[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib (uint index, short x)
{
GetDelegateFor()(index, x);
}
public void VertexAttrib1 (uint index, short[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib2 (uint index, double x, double y)
{
GetDelegateFor()(index, x, y);
}
public void VertexAttrib2 (uint index, double[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib2 (uint index, float x, float y)
{
GetDelegateFor()(index, x, y);
}
public void VertexAttrib2 (uint index, float[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib2 (uint index, short x, short y)
{
GetDelegateFor()(index, x, y);
}
public void VertexAttrib2 (uint index, short[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib3 (uint index, double x, double y, double z)
{
GetDelegateFor()(index, x, y, z);
}
public void VertexAttrib3 (uint index, double[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib3 (uint index, float x, float y, float z)
{
GetDelegateFor()(index, x, y, z);
}
public void VertexAttrib3 (uint index, float[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib3 (uint index, short x, short y, short z)
{
GetDelegateFor()(index, x, y, z);
}
public void VertexAttrib3 (uint index, short[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4N (uint index, sbyte[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4N (uint index, int[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4N (uint index, short[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4N (uint index, byte x, byte y, byte z, byte w)
{
GetDelegateFor()(index, x, y, z, w);
}
public void VertexAttrib4N (uint index, byte[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4N (uint index, uint[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4N (uint index, ushort[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, sbyte[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, double x, double y, double z, double w)
{
GetDelegateFor()(index, x, y, z, w);
}
public void VertexAttrib4 (uint index, double[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, float x, float y, float z, float w)
{
GetDelegateFor()(index, x, y, z, w);
}
public void VertexAttrib4 (uint index, float[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, int[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, short x, short y, short z, short w)
{
GetDelegateFor()(index, x, y, z, w);
}
public void VertexAttrib4 (uint index, short[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, byte[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, uint[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttrib4 (uint index, ushort[] v)
{
GetDelegateFor()(index, v);
}
public void VertexAttribPointer (uint index, int size, uint type, bool normalized, int stride, IntPtr pointer)
{
GetDelegateFor()(index, size, type, normalized, stride, pointer);
}
// Delegates
private delegate void glBlendEquationSeparate (uint modeRGB, uint modeAlpha);
private delegate void glDrawBuffers (int n, uint[] bufs);
private delegate void glStencilOpSeparate (uint face, uint sfail, uint dpfail, uint dppass);
private delegate void glStencilFuncSeparate (uint face, uint func, int reference, uint mask);
private delegate void glStencilMaskSeparate (uint face, uint mask);
private delegate void glAttachShader (uint program, uint shader);
private delegate void glBindAttribLocation (uint program, uint index, string name);
private delegate void glCompileShader (uint shader);
private delegate uint glCreateProgram ();
private delegate uint glCreateShader (uint type);
private delegate void glDeleteProgram (uint program);
private delegate void glDeleteShader (uint shader);
private delegate void glDetachShader (uint program, uint shader);
private delegate void glDisableVertexAttribArray (uint index);
private delegate void glEnableVertexAttribArray (uint index);
private delegate void glGetActiveAttrib (uint program, uint index, int bufSize, out int length, out int size, out uint type, StringBuilder name);
private delegate void glGetActiveUniform (uint program, uint index, int bufSize, out int length, out int size, out uint type, StringBuilder name);
private delegate void glGetAttachedShaders (uint program, int maxCount, int[] count, uint[] obj);
private delegate int glGetAttribLocation (uint program, string name);
private delegate void glGetProgramiv (uint program, uint pname, int[] parameters);
private delegate void glGetProgramInfoLog(uint program, int bufSize, IntPtr length, StringBuilder infoLog);
private delegate void glGetShaderiv (uint shader, uint pname, int[] parameters);
private delegate void glGetShaderInfoLog (uint shader, int bufSize, IntPtr length, StringBuilder infoLog);
private delegate void glGetShaderSource (uint shader, int bufSize, IntPtr length, StringBuilder source);
private delegate int glGetUniformLocation (uint program, string name);
private delegate void glGetUniformfv (uint program, int location, float[] parameters);
private delegate void glGetUniformiv (uint program, int location, int[] parameters);
private delegate void glGetVertexAttribdv (uint index, uint pname, double[] parameters);
private delegate void glGetVertexAttribfv (uint index, uint pname, float[] parameters);
private delegate void glGetVertexAttribiv (uint index, uint pname, int[] parameters);
private delegate void glGetVertexAttribPointerv (uint index, uint pname, IntPtr pointer);
private delegate bool glIsProgram (uint program);
private delegate bool glIsShader (uint shader);
private delegate void glLinkProgram (uint program);
// By specifying 'ThrowOnUnmappableChar' we protect ourselves from inadvertantly using a unicode character
// in the source which the marshaller cannot map. Without this, it maps it to '?' leading to long and pointless
// sessions of trying to find bugs in the shader, which are most often just copied and pasted unicode characters!
// If you're getting exceptions here, remove all unicode crap from your input files (remember, some unicode
// characters you can't even see).
[UnmanagedFunctionPointer(CallingConvention.StdCall, ThrowOnUnmappableChar = true)]
private delegate void glShaderSource (uint shader, int count, string[] source, int[] length);
private delegate void glUseProgram (uint program);
private delegate void glUniform1f (int location, float v0);
private delegate void glUniform2f (int location, float v0, float v1);
private delegate void glUniform3f (int location, float v0, float v1, float v2);
private delegate void glUniform4f (int location, float v0, float v1, float v2, float v3);
private delegate void glUniform1i (int location, int v0);
private delegate void glUniform2i (int location, int v0, int v1);
private delegate void glUniform3i (int location, int v0, int v1, int v2);
private delegate void glUniform4i (int location, int v0, int v1, int v2, int v3);
private delegate void glUniform1fv (int location, int count, float[] value);
private delegate void glUniform2fv (int location, int count, float[] value);
private delegate void glUniform3fv (int location, int count, float[] value);
private delegate void glUniform4fv (int location, int count, float[] value);
private delegate void glUniform1iv (int location, int count, int[] value);
private delegate void glUniform2iv (int location, int count, int[] value);
private delegate void glUniform3iv (int location, int count, int[] value);
private delegate void glUniform4iv (int location, int count, int[] value);
private delegate void glUniformMatrix2fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix3fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix4fv (int location, int count, bool transpose, float[] value);
private delegate void glValidateProgram (uint program);
private delegate void glVertexAttrib1d (uint index, double x);
private delegate void glVertexAttrib1dv (uint index, double[] v);
private delegate void glVertexAttrib1f (uint index, float x);
private delegate void glVertexAttrib1fv (uint index, float[] v);
private delegate void glVertexAttrib1s (uint index, short x);
private delegate void glVertexAttrib1sv (uint index, short[] v);
private delegate void glVertexAttrib2d (uint index, double x, double y);
private delegate void glVertexAttrib2dv (uint index, double[] v);
private delegate void glVertexAttrib2f (uint index, float x, float y);
private delegate void glVertexAttrib2fv (uint index, float[] v);
private delegate void glVertexAttrib2s (uint index, short x, short y);
private delegate void glVertexAttrib2sv (uint index, short[] v);
private delegate void glVertexAttrib3d (uint index, double x, double y, double z);
private delegate void glVertexAttrib3dv (uint index, double[] v);
private delegate void glVertexAttrib3f (uint index, float x, float y, float z);
private delegate void glVertexAttrib3fv (uint index, float[] v);
private delegate void glVertexAttrib3s (uint index, short x, short y, short z);
private delegate void glVertexAttrib3sv (uint index, short[] v);
private delegate void glVertexAttrib4Nbv (uint index, sbyte[] v);
private delegate void glVertexAttrib4Niv (uint index, int[] v);
private delegate void glVertexAttrib4Nsv (uint index, short[] v);
private delegate void glVertexAttrib4Nub (uint index, byte x, byte y, byte z, byte w);
private delegate void glVertexAttrib4Nubv (uint index, byte[] v);
private delegate void glVertexAttrib4Nuiv (uint index, uint[] v);
private delegate void glVertexAttrib4Nusv (uint index, ushort[] v);
private delegate void glVertexAttrib4bv (uint index, sbyte[] v);
private delegate void glVertexAttrib4d (uint index, double x, double y, double z, double w);
private delegate void glVertexAttrib4dv (uint index, double[] v);
private delegate void glVertexAttrib4f (uint index, float x, float y, float z, float w);
private delegate void glVertexAttrib4fv (uint index, float[] v);
private delegate void glVertexAttrib4iv (uint index, int[] v);
private delegate void glVertexAttrib4s (uint index, short x, short y, short z, short w);
private delegate void glVertexAttrib4sv (uint index, short[] v);
private delegate void glVertexAttrib4ubv (uint index, byte[] v);
private delegate void glVertexAttrib4uiv (uint index, uint[] v);
private delegate void glVertexAttrib4usv (uint index, ushort[] v);
private delegate void glVertexAttribPointer (uint index, int size, uint type, bool normalized, int stride, IntPtr pointer);
// Constants
public const uint GL_BLEND_EQUATION_RGB = 0x8009;
public const uint GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
public const uint GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
public const uint GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
public const uint GL_VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
public const uint GL_CURRENT_VERTEX_ATTRIB = 0x8626;
public const uint GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642;
public const uint GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
public const uint GL_STENCIL_BACK_FUNC = 0x8800;
public const uint GL_STENCIL_BACK_FAIL = 0x8801;
public const uint GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
public const uint GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
public const uint GL_MAX_DRAW_BUFFERS = 0x8824;
public const uint GL_DRAW_BUFFER0 = 0x8825;
public const uint GL_DRAW_BUFFER1 = 0x8826;
public const uint GL_DRAW_BUFFER2 = 0x8827;
public const uint GL_DRAW_BUFFER3 = 0x8828;
public const uint GL_DRAW_BUFFER4 = 0x8829;
public const uint GL_DRAW_BUFFER5 = 0x882A;
public const uint GL_DRAW_BUFFER6 = 0x882B;
public const uint GL_DRAW_BUFFER7 = 0x882C;
public const uint GL_DRAW_BUFFER8 = 0x882D;
public const uint GL_DRAW_BUFFER9 = 0x882E;
public const uint GL_DRAW_BUFFER10 = 0x882F;
public const uint GL_DRAW_BUFFER11 = 0x8830;
public const uint GL_DRAW_BUFFER12 = 0x8831;
public const uint GL_DRAW_BUFFER13 = 0x8832;
public const uint GL_DRAW_BUFFER14 = 0x8833;
public const uint GL_DRAW_BUFFER15 = 0x8834;
public const uint GL_BLEND_EQUATION_ALPHA = 0x883D;
public const uint GL_MAX_VERTEX_ATTRIBS = 0x8869;
public const uint GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
public const uint GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872;
public const uint GL_FRAGMENT_SHADER = 0x8B30;
public const uint GL_VERTEX_SHADER = 0x8B31;
public const uint GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49;
public const uint GL_MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A;
public const uint GL_MAX_VARYING_FLOATS = 0x8B4B;
public const uint GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
public const uint GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
public const uint GL_SHADER_TYPE = 0x8B4F;
public const uint GL_FLOAT_VEC2 = 0x8B50;
public const uint GL_FLOAT_VEC3 = 0x8B51;
public const uint GL_FLOAT_VEC4 = 0x8B52;
public const uint GL_INT_VEC2 = 0x8B53;
public const uint GL_INT_VEC3 = 0x8B54;
public const uint GL_INT_VEC4 = 0x8B55;
public const uint GL_BOOL = 0x8B56;
public const uint GL_BOOL_VEC2 = 0x8B57;
public const uint GL_BOOL_VEC3 = 0x8B58;
public const uint GL_BOOL_VEC4 = 0x8B59;
public const uint GL_FLOAT_MAT2 = 0x8B5A;
public const uint GL_FLOAT_MAT3 = 0x8B5B;
public const uint GL_FLOAT_MAT4 = 0x8B5C;
public const uint GL_SAMPLER_1D = 0x8B5D;
public const uint GL_SAMPLER_2D = 0x8B5E;
public const uint GL_SAMPLER_3D = 0x8B5F;
public const uint GL_SAMPLER_CUBE = 0x8B60;
public const uint GL_SAMPLER_1D_SHADOW = 0x8B61;
public const uint GL_SAMPLER_2D_SHADOW = 0x8B62;
public const uint GL_DELETE_STATUS = 0x8B80;
public const uint GL_COMPILE_STATUS = 0x8B81;
public const uint GL_LINK_STATUS = 0x8B82;
public const uint GL_VALIDATE_STATUS = 0x8B83;
public const uint GL_INFO_LOG_LENGTH = 0x8B84;
public const uint GL_ATTACHED_SHADERS = 0x8B85;
public const uint GL_ACTIVE_UNIFORMS = 0x8B86;
public const uint GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87;
public const uint GL_SHADER_SOURCE_LENGTH = 0x8B88;
public const uint GL_ACTIVE_ATTRIBUTES = 0x8B89;
public const uint GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A;
public const uint GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B;
public const uint GL_SHADING_LANGUAGE_VERSION = 0x8B8C;
public const uint GL_CURRENT_PROGRAM = 0x8B8D;
public const uint GL_POINT_SPRITE_COORD_ORIGIN = 0x8CA0;
public const uint GL_LOWER_LEFT = 0x8CA1;
public const uint GL_UPPER_LEFT = 0x8CA2;
public const uint GL_STENCIL_BACK_REF = 0x8CA3;
public const uint GL_STENCIL_BACK_VALUE_MASK = 0x8CA4;
public const uint GL_STENCIL_BACK_WRITEMASK = 0x8CA5;
#endregion
#region OpenGL 2.1
// Methods
public void UniformMatrix2x3(int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix3x2(int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix2x4(int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix4x2(int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix3x4(int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
public void UniformMatrix4x3(int location, int count, bool transpose, float[] value)
{
GetDelegateFor()(location, count, transpose, value);
}
// Delegates
private delegate void glUniformMatrix2x3fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix3x2fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix2x4fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix4x2fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix3x4fv (int location, int count, bool transpose, float[] value);
private delegate void glUniformMatrix4x3fv (int location, int count, bool transpose, float[] value);
// Constants
public const uint GL_PIXEL_PACK_BUFFER = 0x88EB;
public const uint GL_PIXEL_UNPACK_BUFFER = 0x88EC;
public const uint GL_PIXEL_PACK_BUFFER_BINDING = 0x88ED;
public const uint GL_PIXEL_UNPACK_BUFFER_BINDING = 0x88EF;
public const uint GL_FLOAT_MAT2x3 = 0x8B65;
public const uint GL_FLOAT_MAT2x4 = 0x8B66;
public const uint GL_FLOAT_MAT3x2 = 0x8B67;
public const uint GL_FLOAT_MAT3x4 = 0x8B68;
public const uint GL_FLOAT_MAT4x2 = 0x8B69;
public const uint GL_FLOAT_MAT4x3 = 0x8B6A;
public const uint GL_SRGB = 0x8C40;
public const uint GL_SRGB8 = 0x8C41;
public const uint GL_SRGB_ALPHA = 0x8C42;
public const uint GL_SRGB8_ALPHA8 = 0x8C43;
public const uint GL_COMPRESSED_SRGB = 0x8C48;
public const uint GL_COMPRESSED_SRGB_ALPHA = 0x8C49;
#endregion
#region OpenGL 3.0
// Methods
public void ColorMask(uint index, bool r, bool g, bool b, bool a)
{
GetDelegateFor()(index, r, g, b, a);
}
public void GetBoolean(uint target, uint index, bool[] data)
{
GetDelegateFor()(target, index, data);
}
public void GetInteger(uint target, uint index, int[] data)
{
GetDelegateFor