зеркало из https://github.com/stride3d/opentk.git
[Win] Implemented calli-based interop for WGL
This commit is contained in:
Родитель
c2e3328f59
Коммит
5379deaf63
|
@ -34,8 +34,34 @@ namespace OpenTK.Platform.Windows
|
||||||
#pragma warning disable 3019
|
#pragma warning disable 3019
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
static partial class Wgl
|
partial class Wgl
|
||||||
{
|
{
|
||||||
|
static Wgl()
|
||||||
|
{
|
||||||
|
EntryPointNames = new string[]
|
||||||
|
{
|
||||||
|
"wglCreateContextAttribsARB",
|
||||||
|
"wglGetExtensionsStringARB",
|
||||||
|
"wglGetPixelFormatAttribivARB",
|
||||||
|
"wglGetPixelFormatAttribfvARB",
|
||||||
|
"wglChoosePixelFormatARB",
|
||||||
|
"wglMakeContextCurrentARB",
|
||||||
|
"wglGetCurrentReadDCARB",
|
||||||
|
"wglCreatePbufferARB",
|
||||||
|
"wglGetPbufferDCARB",
|
||||||
|
"wglReleasePbufferDCARB",
|
||||||
|
"wglDestroyPbufferARB",
|
||||||
|
"wglQueryPbufferARB",
|
||||||
|
"wglBindTexImageARB",
|
||||||
|
"wglReleaseTexImageARB",
|
||||||
|
"wglSetPbufferAttribARB",
|
||||||
|
"wglGetExtensionsStringEXT",
|
||||||
|
"wglSwapIntervalEXT",
|
||||||
|
"wglGetSwapIntervalEXT",
|
||||||
|
};
|
||||||
|
EntryPoints = new IntPtr[EntryPointNames.Length];
|
||||||
|
}
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
[SuppressUnmanagedCodeSecurity]
|
||||||
[DllImport(Wgl.Library, EntryPoint = "wglCreateContext", ExactSpelling = true, SetLastError = true)]
|
[DllImport(Wgl.Library, EntryPoint = "wglCreateContext", ExactSpelling = true, SetLastError = true)]
|
||||||
internal extern static IntPtr CreateContext(IntPtr hDc);
|
internal extern static IntPtr CreateContext(IntPtr hDc);
|
||||||
|
@ -78,330 +104,232 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
public static partial class Arb
|
public static partial class Arb
|
||||||
{
|
{
|
||||||
[CLSCompliant(false)]
|
[AutoGenerated(EntryPoint = "wglCreateContextAttribsARB")]
|
||||||
unsafe public static
|
|
||||||
IntPtr CreateContextAttribs(IntPtr hDC, IntPtr hShareContext, int* attribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglCreateContextAttribsARB((IntPtr)hDC, (IntPtr)hShareContext, (int*)attribList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static
|
|
||||||
IntPtr CreateContextAttribs(IntPtr hDC, IntPtr hShareContext, ref int attribList)
|
|
||||||
{
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
fixed (int* attribList_ptr = &attribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglCreateContextAttribsARB((IntPtr)hDC, (IntPtr)hShareContext, (int*)attribList_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static
|
public static
|
||||||
IntPtr CreateContextAttribs(IntPtr hDC, IntPtr hShareContext, int[] attribList)
|
IntPtr CreateContextAttribs(IntPtr hDC, IntPtr hShareContext, int[] attribList)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* attribList_ptr = attribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglCreateContextAttribsARB((IntPtr)hDC, (IntPtr)hShareContext, (int*)attribList_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetExtensionsStringARB")]
|
||||||
public static
|
public static
|
||||||
string GetExtensionsString(IntPtr hdc)
|
string GetExtensionsString(IntPtr hdc)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.wglGetExtensionsStringARB((IntPtr)hdc));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribivARB")]
|
||||||
public static
|
public static
|
||||||
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, int[] piAttributes, [Out] int[] piValues)
|
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, int[] piAttributes, [Out] int[] piValues)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttributes_ptr = piAttributes)
|
|
||||||
fixed (int* piValues_ptr = piValues)
|
|
||||||
{
|
|
||||||
return Delegates.wglGetPixelFormatAttribivARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes_ptr, (int*)piValues_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribivARB")]
|
||||||
public static
|
public static
|
||||||
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, ref int piAttributes, [Out] out int piValues)
|
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, ref int piAttributes, [Out] out int piValues)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttributes_ptr = &piAttributes)
|
|
||||||
fixed (int* piValues_ptr = &piValues)
|
|
||||||
{
|
|
||||||
Boolean retval = Delegates.wglGetPixelFormatAttribivARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes_ptr, (int*)piValues_ptr);
|
|
||||||
piValues = *piValues_ptr;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static
|
|
||||||
unsafe Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, int* piAttributes, [Out] int* piValues)
|
|
||||||
{
|
|
||||||
return Delegates.wglGetPixelFormatAttribivARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes, (int*)piValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribfvARB")]
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int[] piAttributes, [Out] Single[] pfValues)
|
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, int nAttributes, int[] piAttributes, [Out] Single[] pfValues)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttributes_ptr = piAttributes)
|
|
||||||
fixed (Single* pfValues_ptr = pfValues)
|
|
||||||
{
|
|
||||||
return Delegates.wglGetPixelFormatAttribfvARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes_ptr, (Single*)pfValues_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static
|
|
||||||
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, int[] piAttributes, [Out] Single[] pfValues)
|
|
||||||
{
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
fixed (int* piAttributes_ptr = piAttributes)
|
|
||||||
fixed (Single* pfValues_ptr = pfValues)
|
|
||||||
{
|
|
||||||
return Delegates.wglGetPixelFormatAttribfvARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes_ptr, (Single*)pfValues_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetPixelFormatAttribfvARB")]
|
||||||
public static
|
public static
|
||||||
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, ref int piAttributes, [Out] out Single pfValues)
|
Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, ref int piAttributes, [Out] out Single pfValues)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttributes_ptr = &piAttributes)
|
|
||||||
fixed (Single* pfValues_ptr = &pfValues)
|
|
||||||
{
|
|
||||||
Boolean retval = Delegates.wglGetPixelFormatAttribfvARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes_ptr, (Single*)pfValues_ptr);
|
|
||||||
pfValues = *pfValues_ptr;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
|
||||||
public static
|
|
||||||
unsafe Boolean GetPixelFormatAttrib(IntPtr hdc, int iPixelFormat, int iLayerPlane, Int32 nAttributes, int* piAttributes, [Out] Single* pfValues)
|
|
||||||
{
|
|
||||||
return Delegates.wglGetPixelFormatAttribfvARB((IntPtr)hdc, (int)iPixelFormat, (int)iLayerPlane, (UInt32)nAttributes, (int*)piAttributes, (Single*)pfValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglChoosePixelFormatARB")]
|
||||||
public static
|
public static
|
||||||
Boolean ChoosePixelFormat(IntPtr hdc, int[] piAttribIList, Single[] pfAttribFList, Int32 nMaxFormats, [Out] int[] piFormats, out int nNumFormats)
|
Boolean ChoosePixelFormat(IntPtr hdc, int[] piAttribIList, Single[] pfAttribFList, Int32 nMaxFormats, [Out] int[] piFormats, out int nNumFormats)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttribIList_ptr = piAttribIList)
|
|
||||||
fixed (Single* pfAttribFList_ptr = pfAttribFList)
|
|
||||||
fixed (int* piFormats_ptr = piFormats)
|
|
||||||
fixed (Int32* nNumFormats_ptr = &nNumFormats)
|
|
||||||
{
|
|
||||||
return Delegates.wglChoosePixelFormatARB((IntPtr)hdc, (int*)piAttribIList_ptr, (Single*)pfAttribFList_ptr, (UInt32)nMaxFormats, (int*)piFormats_ptr, (UInt32*)nNumFormats_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglChoosePixelFormatARB")]
|
||||||
public static
|
public static
|
||||||
Boolean ChoosePixelFormat(IntPtr hdc, ref int piAttribIList, ref Single pfAttribFList, Int32 nMaxFormats, [Out] out int piFormats, [Out] out Int32 nNumFormats)
|
Boolean ChoosePixelFormat(IntPtr hdc, ref int piAttribIList, ref Single pfAttribFList, Int32 nMaxFormats, [Out] out int piFormats, [Out] out Int32 nNumFormats)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttribIList_ptr = &piAttribIList)
|
|
||||||
fixed (Single* pfAttribFList_ptr = &pfAttribFList)
|
|
||||||
fixed (int* piFormats_ptr = &piFormats)
|
|
||||||
fixed (Int32* nNumFormats_ptr = &nNumFormats)
|
|
||||||
{
|
|
||||||
Boolean retval = Delegates.wglChoosePixelFormatARB((IntPtr)hdc, (int*)piAttribIList_ptr, (Single*)pfAttribFList_ptr, (UInt32)nMaxFormats, (int*)piFormats_ptr, (UInt32*)nNumFormats_ptr);
|
|
||||||
piFormats = *piFormats_ptr;
|
|
||||||
nNumFormats = *nNumFormats_ptr;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
|
||||||
public static
|
|
||||||
unsafe Boolean ChoosePixelFormat(IntPtr hdc, int* piAttribIList, Single* pfAttribFList, Int32 nMaxFormats, [Out] int* piFormats, [Out] Int32* nNumFormats)
|
|
||||||
{
|
|
||||||
return Delegates.wglChoosePixelFormatARB((IntPtr)hdc, (int*)piAttribIList, (Single*)pfAttribFList, (UInt32)nMaxFormats, (int*)piFormats, (UInt32*)nNumFormats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglMakeContextCurrentARB")]
|
||||||
public static
|
public static
|
||||||
Boolean MakeContextCurrent(IntPtr hDrawDC, IntPtr hReadDC, IntPtr hglrc)
|
Boolean MakeContextCurrent(IntPtr hDrawDC, IntPtr hReadDC, IntPtr hglrc)
|
||||||
{
|
{
|
||||||
return Delegates.wglMakeContextCurrentARB((IntPtr)hDrawDC, (IntPtr)hReadDC, (IntPtr)hglrc);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetCurrentReadDCARB")]
|
||||||
public static
|
public static
|
||||||
IntPtr GetCurrentReadDC()
|
IntPtr GetCurrentReadDC()
|
||||||
{
|
{
|
||||||
return Delegates.wglGetCurrentReadDCARB();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglCreatePbufferARB")]
|
||||||
public static
|
public static
|
||||||
IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int[] piAttribList)
|
IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int[] piAttribList)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttribList_ptr = piAttribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglCreatePbufferARB((IntPtr)hDC, (int)iPixelFormat, (int)iWidth, (int)iHeight, (int*)piAttribList_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglCreatePbufferARB")]
|
||||||
public static
|
public static
|
||||||
IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, ref int piAttribList)
|
IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, ref int piAttribList)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttribList_ptr = &piAttribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglCreatePbufferARB((IntPtr)hDC, (int)iPixelFormat, (int)iWidth, (int)iHeight, (int*)piAttribList_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
|
||||||
public static
|
|
||||||
unsafe IntPtr CreatePbuffer(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int* piAttribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglCreatePbufferARB((IntPtr)hDC, (int)iPixelFormat, (int)iWidth, (int)iHeight, (int*)piAttribList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetPbufferDCARB")]
|
||||||
public static
|
public static
|
||||||
IntPtr GetPbufferDC(IntPtr hPbuffer)
|
IntPtr GetPbufferDC(IntPtr hPbuffer)
|
||||||
{
|
{
|
||||||
return Delegates.wglGetPbufferDCARB((IntPtr)hPbuffer);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglReleasePbufferDCARB")]
|
||||||
public static
|
public static
|
||||||
int ReleasePbufferDC(IntPtr hPbuffer, IntPtr hDC)
|
int ReleasePbufferDC(IntPtr hPbuffer, IntPtr hDC)
|
||||||
{
|
{
|
||||||
return Delegates.wglReleasePbufferDCARB((IntPtr)hPbuffer, (IntPtr)hDC);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglDestroyPbufferARB")]
|
||||||
public static
|
public static
|
||||||
Boolean DestroyPbuffer(IntPtr hPbuffer)
|
Boolean DestroyPbuffer(IntPtr hPbuffer)
|
||||||
{
|
{
|
||||||
return Delegates.wglDestroyPbufferARB((IntPtr)hPbuffer);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglQueryPbufferARB")]
|
||||||
public static
|
public static
|
||||||
Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] int[] piValue)
|
Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] int[] piValue)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piValue_ptr = piValue)
|
|
||||||
{
|
|
||||||
return Delegates.wglQueryPbufferARB((IntPtr)hPbuffer, (int)iAttribute, (int*)piValue_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglQueryPbufferARB")]
|
||||||
public static
|
public static
|
||||||
Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] out int piValue)
|
Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] out int piValue)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piValue_ptr = &piValue)
|
|
||||||
{
|
|
||||||
Boolean retval = Delegates.wglQueryPbufferARB((IntPtr)hPbuffer, (int)iAttribute, (int*)piValue_ptr);
|
|
||||||
piValue = *piValue_ptr;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
|
||||||
public static
|
|
||||||
unsafe Boolean QueryPbuffer(IntPtr hPbuffer, int iAttribute, [Out] int* piValue)
|
|
||||||
{
|
|
||||||
return Delegates.wglQueryPbufferARB((IntPtr)hPbuffer, (int)iAttribute, (int*)piValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglBindTexImageARB")]
|
||||||
public static
|
public static
|
||||||
Boolean BindTexImage(IntPtr hPbuffer, int iBuffer)
|
Boolean BindTexImage(IntPtr hPbuffer, int iBuffer)
|
||||||
{
|
{
|
||||||
return Delegates.wglBindTexImageARB((IntPtr)hPbuffer, (int)iBuffer);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglReleaseTexImageARB")]
|
||||||
public static
|
public static
|
||||||
Boolean ReleaseTexImage(IntPtr hPbuffer, int iBuffer)
|
Boolean ReleaseTexImage(IntPtr hPbuffer, int iBuffer)
|
||||||
{
|
{
|
||||||
return Delegates.wglReleaseTexImageARB((IntPtr)hPbuffer, (int)iBuffer);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglSetPbufferAttribARB")]
|
||||||
public static
|
public static
|
||||||
Boolean SetPbufferAttrib(IntPtr hPbuffer, int[] piAttribList)
|
Boolean SetPbufferAttrib(IntPtr hPbuffer, int[] piAttribList)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttribList_ptr = piAttribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglSetPbufferAttribARB((IntPtr)hPbuffer, (int*)piAttribList_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglSetPbufferAttribARB")]
|
||||||
public static
|
public static
|
||||||
Boolean SetPbufferAttrib(IntPtr hPbuffer, ref int piAttribList)
|
Boolean SetPbufferAttrib(IntPtr hPbuffer, ref int piAttribList)
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
fixed (int* piAttribList_ptr = &piAttribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglSetPbufferAttribARB((IntPtr)hPbuffer, (int*)piAttribList_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
|
||||||
public static
|
|
||||||
unsafe Boolean SetPbufferAttrib(IntPtr hPbuffer, int* piAttribList)
|
|
||||||
{
|
|
||||||
return Delegates.wglSetPbufferAttribARB((IntPtr)hPbuffer, (int*)piAttribList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static partial class Ext
|
public static partial class Ext
|
||||||
{
|
{
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetExtensionsStringEXT")]
|
||||||
public static
|
public static
|
||||||
string GetExtensionsString()
|
string GetExtensionsString()
|
||||||
{
|
{
|
||||||
unsafe
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.wglGetExtensionsStringEXT());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglSwapIntervalEXT")]
|
||||||
public static
|
public static
|
||||||
Boolean SwapInterval(int interval)
|
Boolean SwapInterval(int interval)
|
||||||
{
|
{
|
||||||
return Delegates.wglSwapIntervalEXT((int)interval);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AutoGenerated(EntryPoint = "wglGetSwapIntervalEXT")]
|
||||||
public static
|
public static
|
||||||
int GetSwapInterval()
|
int GetSwapInterval()
|
||||||
{
|
{
|
||||||
return Delegates.wglGetSwapIntervalEXT();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Slot(0)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern IntPtr wglCreateContextAttribsARB(IntPtr hDC, IntPtr hShareContext, int* attribList);
|
||||||
|
[Slot(1)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern IntPtr wglGetExtensionsStringARB(IntPtr hdc);
|
||||||
|
[Slot(2)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern Boolean wglGetPixelFormatAttribivARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int* piAttributes, [Out] int* piValues);
|
||||||
|
[Slot(3)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern Boolean wglGetPixelFormatAttribfvARB(IntPtr hdc, int iPixelFormat, int iLayerPlane, UInt32 nAttributes, int* piAttributes, [Out] Single* pfValues);
|
||||||
|
[Slot(4)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern Boolean wglChoosePixelFormatARB(IntPtr hdc, int* piAttribIList, Single* pfAttribFList, UInt32 nMaxFormats, [Out] int* piFormats, [Out] UInt32* nNumFormats);
|
||||||
|
[Slot(5)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern Boolean wglMakeContextCurrentARB(IntPtr hDrawDC, IntPtr hReadDC, IntPtr hglrc);
|
||||||
|
[Slot(6)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern IntPtr wglGetCurrentReadDCARB();
|
||||||
|
[Slot(7)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern IntPtr wglCreatePbufferARB(IntPtr hDC, int iPixelFormat, int iWidth, int iHeight, int* piAttribList);
|
||||||
|
[Slot(8)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern IntPtr wglGetPbufferDCARB(IntPtr hPbuffer);
|
||||||
|
[Slot(9)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern int wglReleasePbufferDCARB(IntPtr hPbuffer, IntPtr hDC);
|
||||||
|
[Slot(10)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern Boolean wglDestroyPbufferARB(IntPtr hPbuffer);
|
||||||
|
[Slot(11)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern Boolean wglQueryPbufferARB(IntPtr hPbuffer, int iAttribute, [Out] int* piValue);
|
||||||
|
[Slot(12)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern Boolean wglBindTexImageARB(IntPtr hPbuffer, int iBuffer);
|
||||||
|
[Slot(13)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern Boolean wglReleaseTexImageARB(IntPtr hPbuffer, int iBuffer);
|
||||||
|
[Slot(14)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal unsafe static extern Boolean wglSetPbufferAttribARB(IntPtr hPbuffer, int* piAttribList);
|
||||||
|
[Slot(15)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern IntPtr wglGetExtensionsStringEXT();
|
||||||
|
[Slot(16)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern Boolean wglSwapIntervalEXT(int interval);
|
||||||
|
[Slot(17)]
|
||||||
|
[DllImport(Library, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
internal static extern int wglGetSwapIntervalEXT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,119 +11,29 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
internal partial class Wgl
|
internal partial class Wgl : GraphicsBindingsBase
|
||||||
{
|
{
|
||||||
#region --- Constructors ---
|
static IntPtr[] EntryPoints;
|
||||||
|
static string[] EntryPointNames;
|
||||||
static Wgl()
|
|
||||||
{
|
|
||||||
assembly = Assembly.GetExecutingAssembly();
|
|
||||||
wglClass = assembly.GetType("OpenTK.Platform.Windows.Wgl");
|
|
||||||
delegatesClass = wglClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
|
|
||||||
|
|
||||||
//// Ensure core entry points are ready prior to accessing any method.
|
|
||||||
//// Resolves bug [#993]: "Possible bug in GraphicsContext.CreateDummyContext()"
|
|
||||||
//LoadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- Fields ---
|
|
||||||
|
|
||||||
internal const string Library = "OPENGL32.DLL";
|
internal const string Library = "OPENGL32.DLL";
|
||||||
|
|
||||||
readonly static Dictionary<string, bool> extensions =
|
readonly static Dictionary<string, bool> extensions =
|
||||||
new Dictionary<string, bool>();
|
new Dictionary<string, bool>();
|
||||||
|
|
||||||
private static Assembly assembly;
|
static readonly object sync = new object();
|
||||||
private static Type wglClass;
|
|
||||||
private static Type delegatesClass;
|
|
||||||
|
|
||||||
private static bool rebuildExtensionList = true;
|
public Wgl()
|
||||||
|
|
||||||
static readonly object SyncRoot = new object();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#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 = GetExtensionDelegate(name, signature);
|
EntryPointsInstance = EntryPoints;
|
||||||
return d;
|
EntryPointNamesInstance = EntryPointNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#region Public Members
|
||||||
|
|
||||||
#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 = 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
|
|
||||||
|
|
||||||
#region public static void LoadAll()
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads all Wgl entry points, core and extensions.
|
|
||||||
/// </summary>
|
|
||||||
public static void LoadAll()
|
|
||||||
{
|
|
||||||
lock (SyncRoot)
|
|
||||||
{
|
|
||||||
OpenTK.Platform.Utilities.LoadExtensions(typeof(Wgl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public static bool Load(string function)
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads the given Wgl entry point.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="function">The name of the function to load.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool Load(string function)
|
|
||||||
{
|
|
||||||
return OpenTK.Platform.Utilities.TryLoadExtension(typeof(Wgl), function);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public static bool SupportsExtension(string name)
|
public static bool SupportsExtension(string name)
|
||||||
{
|
{
|
||||||
|
@ -145,22 +55,15 @@ namespace OpenTK.Platform.Windows
|
||||||
// static WGL/GL classes. Fortunately, this issue is extremely unlikely to arise in practice, as you'd
|
// static WGL/GL classes. Fortunately, this issue is extremely unlikely to arise in practice, as you'd
|
||||||
// have to create one accelerated and one non-accelerated context in the same application, with the
|
// have to create one accelerated and one non-accelerated context in the same application, with the
|
||||||
// non-accelerated context coming second.
|
// non-accelerated context coming second.
|
||||||
Wgl.Delegates.GetExtensionsStringARB get_arb = Wgl.Delegates.wglGetExtensionsStringARB;
|
bool get_arb = SupportsFunction("wglGetExtensionsStringARB");
|
||||||
Wgl.Delegates.GetExtensionsStringEXT get_ext = Wgl.Delegates.wglGetExtensionsStringEXT;
|
bool get_ext = SupportsFunction("wglGetExtensionsStringEXT");
|
||||||
IntPtr str_ptr =
|
string str =
|
||||||
get_arb != null ? get_arb(dc) :
|
get_arb ? Arb.GetExtensionsString(dc) :
|
||||||
get_ext != null ? get_ext() :
|
get_ext ? Ext.GetExtensionsString() :
|
||||||
IntPtr.Zero;
|
String.Empty;
|
||||||
|
|
||||||
if (str_ptr != IntPtr.Zero)
|
if (!String.IsNullOrEmpty(str))
|
||||||
{
|
{
|
||||||
string str;
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
str = new string((sbyte*)str_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string ext in str.Split(' '))
|
foreach (string ext in str.Split(' '))
|
||||||
{
|
{
|
||||||
extensions.Add(ext, true);
|
extensions.Add(ext, true);
|
||||||
|
@ -175,20 +78,67 @@ namespace OpenTK.Platform.Windows
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region public static partial class Arb
|
/// <summary>
|
||||||
|
/// Checks whether an extension function is supported.
|
||||||
/// <summary>Contains ARB extensions for WGL.</summary>
|
/// Do not use with core WGL functions, as this function
|
||||||
public static partial class Arb
|
/// will incorrectly return false.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The extension function to check (e.g. "wglGetExtensionsStringARB"</param>
|
||||||
|
/// <returns>True if the extension function is supported; otherwise, false.</returns>
|
||||||
|
public static bool SupportsFunction(string name)
|
||||||
{
|
{
|
||||||
|
int index = Array.IndexOf(EntryPointNames, name);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
return EntryPoints[index] != IntPtr.Zero;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public static partial class Ext
|
#region Protected Members
|
||||||
|
|
||||||
/// <summary>Contains EXT extensions for WGL.</summary>
|
protected override object SyncRoot
|
||||||
public static partial class Ext
|
|
||||||
{
|
{
|
||||||
|
get { return sync; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IntPtr GetAddress(string function_string)
|
||||||
|
{
|
||||||
|
IntPtr address = Wgl.GetProcAddress(function_string);
|
||||||
|
if (!IsValid(address))
|
||||||
|
{
|
||||||
|
address = Functions.GetProcAddress(WinFactory.OpenGLHandle, function_string);
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Members
|
||||||
|
|
||||||
|
static bool IsValid(IntPtr address)
|
||||||
|
{
|
||||||
|
// See https://www.opengl.org/wiki/Load_OpenGL_Functions
|
||||||
|
long a = address.ToInt64();
|
||||||
|
bool is_valid = (a < -1) || (a > 3);
|
||||||
|
return is_valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Internal Members
|
||||||
|
|
||||||
|
internal override void LoadEntryPoints()
|
||||||
|
{
|
||||||
|
if (Wgl.GetCurrentContext() != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < EntryPointsInstance.Length; i++)
|
||||||
|
{
|
||||||
|
EntryPointsInstance[i] = GetAddress(EntryPointNamesInstance[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Загрузка…
Ссылка в новой задаче