mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 11:25:27 +00:00
Changed API.* to * in order to reflect changes in OpenTK.Platform.Windows.API.
Improved Disposable pattern implementation in most Windows classes.
This commit is contained in:
parent
1d72cb7ab9
commit
5144535b8e
File diff suppressed because it is too large
Load diff
|
@ -45,32 +45,32 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor* pPfd)
|
unsafe int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor* pPfd)
|
||||||
{
|
{
|
||||||
unsafe { return Delegates.wglChoosePixelFormat((IntPtr)hDc, (API.PixelFormatDescriptor*)pPfd); }
|
unsafe { return Delegates.wglChoosePixelFormat((IntPtr)hDc, (PixelFormatDescriptor*)pPfd); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor[] pPfd)
|
int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor[] pPfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* pPfd_ptr = pPfd)
|
fixed (PixelFormatDescriptor* pPfd_ptr = pPfd)
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (API.PixelFormatDescriptor*)pPfd_ptr);
|
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (PixelFormatDescriptor*)pPfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
int ChoosePixelFormat(IntPtr hDc, ref API.PixelFormatDescriptor pPfd)
|
int ChoosePixelFormat(IntPtr hDc, ref PixelFormatDescriptor pPfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* pPfd_ptr = &pPfd)
|
fixed (PixelFormatDescriptor* pPfd_ptr = &pPfd)
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (API.PixelFormatDescriptor*)pPfd_ptr);
|
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (PixelFormatDescriptor*)pPfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,44 +78,44 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor* ppfd)
|
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor* ppfd)
|
||||||
{
|
{
|
||||||
unsafe { return Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd); }
|
unsafe { return Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd); }
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, API.PixelFormatDescriptor* ppfd)
|
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, PixelFormatDescriptor* ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd);
|
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor[] ppfd)
|
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor[] ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* ppfd_ptr = ppfd)
|
fixed (PixelFormatDescriptor* ppfd_ptr = ppfd)
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
|
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, API.PixelFormatDescriptor[] ppfd)
|
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, PixelFormatDescriptor[] ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* ppfd_ptr = ppfd)
|
fixed (PixelFormatDescriptor* ppfd_ptr = ppfd)
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
|
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,26 +123,26 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, ref API.PixelFormatDescriptor ppfd)
|
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, ref PixelFormatDescriptor ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* ppfd_ptr = &ppfd)
|
fixed (PixelFormatDescriptor* ppfd_ptr = &ppfd)
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
|
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, ref API.PixelFormatDescriptor ppfd)
|
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, ref PixelFormatDescriptor ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* ppfd_ptr = &ppfd)
|
fixed (PixelFormatDescriptor* ppfd_ptr = &ppfd)
|
||||||
{
|
{
|
||||||
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
|
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,32 +174,32 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor* ppfd)
|
unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor* ppfd)
|
||||||
{
|
{
|
||||||
unsafe { return Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (API.PixelFormatDescriptor*)ppfd); }
|
unsafe { return Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (PixelFormatDescriptor*)ppfd); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor[] ppfd)
|
Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor[] ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* ppfd_ptr = ppfd)
|
fixed (PixelFormatDescriptor* ppfd_ptr = ppfd)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (API.PixelFormatDescriptor*)ppfd_ptr);
|
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (PixelFormatDescriptor*)ppfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean SetPixelFormat(IntPtr hdc, int ipfd, ref API.PixelFormatDescriptor ppfd)
|
Boolean SetPixelFormat(IntPtr hdc, int ipfd, ref PixelFormatDescriptor ppfd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.PixelFormatDescriptor* ppfd_ptr = &ppfd)
|
fixed (PixelFormatDescriptor* ppfd_ptr = &ppfd)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (API.PixelFormatDescriptor*)ppfd_ptr);
|
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (PixelFormatDescriptor*)ppfd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,44 +225,44 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor* plpd)
|
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor* plpd)
|
||||||
{
|
{
|
||||||
unsafe { return Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd); }
|
unsafe { return Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd); }
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, API.LayerPlaneDescriptor* plpd)
|
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, LayerPlaneDescriptor* plpd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd);
|
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor[] plpd)
|
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor[] plpd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.LayerPlaneDescriptor* plpd_ptr = plpd)
|
fixed (LayerPlaneDescriptor* plpd_ptr = plpd)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
|
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, API.LayerPlaneDescriptor[] plpd)
|
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, LayerPlaneDescriptor[] plpd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.LayerPlaneDescriptor* plpd_ptr = plpd)
|
fixed (LayerPlaneDescriptor* plpd_ptr = plpd)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
|
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,26 +270,26 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, ref API.LayerPlaneDescriptor plpd)
|
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, ref LayerPlaneDescriptor plpd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.LayerPlaneDescriptor* plpd_ptr = &plpd)
|
fixed (LayerPlaneDescriptor* plpd_ptr = &plpd)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
|
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, ref API.LayerPlaneDescriptor plpd)
|
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, ref LayerPlaneDescriptor plpd)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.LayerPlaneDescriptor* plpd_ptr = &plpd)
|
fixed (LayerPlaneDescriptor* plpd_ptr = &plpd)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
|
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,32 +394,32 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics)
|
unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics)
|
||||||
{
|
{
|
||||||
unsafe { return Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics); }
|
unsafe { return Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat[] glyphMetrics)
|
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat[] glyphMetrics)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
|
fixed (GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
|
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref API.GlyphMetricsFloat glyphMetrics)
|
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref GlyphMetricsFloat glyphMetrics)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
|
fixed (GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
|
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,32 +427,32 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.CLSCompliant(false)]
|
[System.CLSCompliant(false)]
|
||||||
public static
|
public static
|
||||||
unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics)
|
unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics)
|
||||||
{
|
{
|
||||||
unsafe { return Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics); }
|
unsafe { return Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat[] glyphMetrics)
|
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat[] glyphMetrics)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
|
fixed (GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
|
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
public static
|
||||||
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref API.GlyphMetricsFloat glyphMetrics)
|
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref GlyphMetricsFloat glyphMetrics)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
|
fixed (GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
|
||||||
{
|
{
|
||||||
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
|
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ namespace OpenTK.Platform.Windows
|
||||||
internal extern static Boolean CopyContext(IntPtr hglrcSrc, IntPtr hglrcDst, UInt32 mask);
|
internal extern static Boolean CopyContext(IntPtr hglrcSrc, IntPtr hglrcDst, UInt32 mask);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglChoosePixelFormat", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglChoosePixelFormat", ExactSpelling = true)]
|
||||||
internal extern static unsafe int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor* pPfd);
|
internal extern static unsafe int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor* pPfd);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglDescribePixelFormat", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglDescribePixelFormat", ExactSpelling = true)]
|
||||||
internal extern static unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor* ppfd);
|
internal extern static unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor* ppfd);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglGetCurrentDC", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglGetCurrentDC", ExactSpelling = true)]
|
||||||
internal extern static IntPtr GetCurrentDC();
|
internal extern static IntPtr GetCurrentDC();
|
||||||
|
@ -45,7 +45,7 @@ namespace OpenTK.Platform.Windows
|
||||||
internal extern static int GetPixelFormat(IntPtr hdc);
|
internal extern static int GetPixelFormat(IntPtr hdc);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSetPixelFormat", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSetPixelFormat", ExactSpelling = true)]
|
||||||
internal extern static unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor* ppfd);
|
internal extern static unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor* ppfd);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSwapBuffers", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSwapBuffers", ExactSpelling = true)]
|
||||||
internal extern static Boolean SwapBuffers(IntPtr hdc);
|
internal extern static Boolean SwapBuffers(IntPtr hdc);
|
||||||
|
@ -57,7 +57,7 @@ namespace OpenTK.Platform.Windows
|
||||||
internal extern static IntPtr CreateLayerContext(IntPtr hDc, int level);
|
internal extern static IntPtr CreateLayerContext(IntPtr hDc, int level);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglDescribeLayerPlane", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglDescribeLayerPlane", ExactSpelling = true)]
|
||||||
internal extern static unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor* plpd);
|
internal extern static unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor* plpd);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSetLayerPaletteEntries", ExactSpelling = true)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSetLayerPaletteEntries", ExactSpelling = true)]
|
||||||
internal extern static unsafe int SetLayerPaletteEntries(IntPtr hdc, int iLayerPlane, int iStart, int cEntries, Int32* pcr);
|
internal extern static unsafe int SetLayerPaletteEntries(IntPtr hdc, int iLayerPlane, int iStart, int cEntries, Int32* pcr);
|
||||||
|
@ -78,10 +78,10 @@ namespace OpenTK.Platform.Windows
|
||||||
internal extern static Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
|
internal extern static Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglUseFontOutlinesA", CharSet = CharSet.Auto)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglUseFontOutlinesA", CharSet = CharSet.Auto)]
|
||||||
internal extern static unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
|
internal extern static unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglUseFontOutlinesW", CharSet = CharSet.Auto)]
|
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglUseFontOutlinesW", CharSet = CharSet.Auto)]
|
||||||
internal extern static unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
|
internal extern static unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,10 @@ namespace OpenTK.Platform.Windows
|
||||||
internal delegate Boolean CopyContext(IntPtr hglrcSrc, IntPtr hglrcDst, UInt32 mask);
|
internal delegate Boolean CopyContext(IntPtr hglrcSrc, IntPtr hglrcDst, UInt32 mask);
|
||||||
internal static CopyContext wglCopyContext = null;
|
internal static CopyContext wglCopyContext = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor* pPfd);
|
internal unsafe delegate int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor* pPfd);
|
||||||
internal unsafe static ChoosePixelFormat wglChoosePixelFormat = null;
|
internal unsafe static ChoosePixelFormat wglChoosePixelFormat = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor* ppfd);
|
internal unsafe delegate int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor* ppfd);
|
||||||
internal unsafe static DescribePixelFormat wglDescribePixelFormat = null;
|
internal unsafe static DescribePixelFormat wglDescribePixelFormat = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal delegate IntPtr GetCurrentDC();
|
internal delegate IntPtr GetCurrentDC();
|
||||||
|
@ -46,7 +46,7 @@ namespace OpenTK.Platform.Windows
|
||||||
internal delegate int GetPixelFormat(IntPtr hdc);
|
internal delegate int GetPixelFormat(IntPtr hdc);
|
||||||
internal static GetPixelFormat wglGetPixelFormat = null;
|
internal static GetPixelFormat wglGetPixelFormat = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor* ppfd);
|
internal unsafe delegate Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor* ppfd);
|
||||||
internal unsafe static SetPixelFormat wglSetPixelFormat = null;
|
internal unsafe static SetPixelFormat wglSetPixelFormat = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal delegate Boolean SwapBuffers(IntPtr hdc);
|
internal delegate Boolean SwapBuffers(IntPtr hdc);
|
||||||
|
@ -58,7 +58,7 @@ namespace OpenTK.Platform.Windows
|
||||||
internal delegate IntPtr CreateLayerContext(IntPtr hDc, int level);
|
internal delegate IntPtr CreateLayerContext(IntPtr hDc, int level);
|
||||||
internal static CreateLayerContext wglCreateLayerContext = null;
|
internal static CreateLayerContext wglCreateLayerContext = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor* plpd);
|
internal unsafe delegate Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor* plpd);
|
||||||
internal unsafe static DescribeLayerPlane wglDescribeLayerPlane = null;
|
internal unsafe static DescribeLayerPlane wglDescribeLayerPlane = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate int SetLayerPaletteEntries(IntPtr hdc, int iLayerPlane, int iStart, int cEntries, Int32* pcr);
|
internal unsafe delegate int SetLayerPaletteEntries(IntPtr hdc, int iLayerPlane, int iStart, int cEntries, Int32* pcr);
|
||||||
|
@ -79,10 +79,10 @@ namespace OpenTK.Platform.Windows
|
||||||
internal delegate Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
|
internal delegate Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
|
||||||
internal static UseFontBitmapsW wglUseFontBitmapsW = null;
|
internal static UseFontBitmapsW wglUseFontBitmapsW = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
|
internal unsafe delegate Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
|
||||||
internal unsafe static UseFontOutlinesA wglUseFontOutlinesA = null;
|
internal unsafe static UseFontOutlinesA wglUseFontOutlinesA = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal unsafe delegate Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
|
internal unsafe delegate Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
|
||||||
internal unsafe static UseFontOutlinesW wglUseFontOutlinesW = null;
|
internal unsafe static UseFontOutlinesW wglUseFontOutlinesW = null;
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||||
internal delegate IntPtr CreateBufferRegionARB(IntPtr hDC, int iLayerPlane, UInt32 uType);
|
internal delegate IntPtr CreateBufferRegionARB(IntPtr hDC, int iLayerPlane, UInt32 uType);
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace OpenTK.Platform.Windows
|
||||||
#region --- Contructors ---
|
#region --- Contructors ---
|
||||||
|
|
||||||
public WinGLContext()
|
public WinGLContext()
|
||||||
: this(new DisplayMode(640, 480, new ColorDepth(32), 16, 0, 0, 2, false, false, false, 0.0f))
|
: this(new DisplayMode(640, 480, new ColorMode(32), 16, 0, 0, 2, false, false, false, 0.0f))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,20 +72,20 @@ namespace OpenTK.Platform.Windows
|
||||||
Debug.WriteLine(String.Format("Device context: {0}", deviceContext));
|
Debug.WriteLine(String.Format("Device context: {0}", deviceContext));
|
||||||
|
|
||||||
Debug.Write("Setting pixel format... ");
|
Debug.Write("Setting pixel format... ");
|
||||||
API.PixelFormatDescriptor pixelFormat = new API.PixelFormatDescriptor();
|
PixelFormatDescriptor pixelFormat = new PixelFormatDescriptor();
|
||||||
pixelFormat.Size = API.PixelFormatDescriptorSize;
|
pixelFormat.Size = API.PixelFormatDescriptorSize;
|
||||||
pixelFormat.Version = API.PixelFormatDescriptorVersion;
|
pixelFormat.Version = API.PixelFormatDescriptorVersion;
|
||||||
pixelFormat.Flags =
|
pixelFormat.Flags =
|
||||||
API.PixelFormatDescriptorFlags.SUPPORT_OPENGL |
|
PixelFormatDescriptorFlags.SUPPORT_OPENGL |
|
||||||
API.PixelFormatDescriptorFlags.DRAW_TO_WINDOW;
|
PixelFormatDescriptorFlags.DRAW_TO_WINDOW;
|
||||||
pixelFormat.ColorBits = (byte)(mode.Color.Red + mode.Color.Green + mode.Color.Blue);
|
pixelFormat.ColorBits = (byte)(mode.Color.Red + mode.Color.Green + mode.Color.Blue);
|
||||||
if (mode.Color.IsIndexed)
|
if (mode.Color.IsIndexed)
|
||||||
{
|
{
|
||||||
pixelFormat.PixelType = API.PixelType.INDEXED;
|
pixelFormat.PixelType = PixelType.INDEXED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pixelFormat.PixelType = API.PixelType.RGBA;
|
pixelFormat.PixelType = PixelType.RGBA;
|
||||||
pixelFormat.RedBits = (byte)mode.Color.Red;
|
pixelFormat.RedBits = (byte)mode.Color.Red;
|
||||||
pixelFormat.GreenBits = (byte)mode.Color.Green;
|
pixelFormat.GreenBits = (byte)mode.Color.Green;
|
||||||
pixelFormat.BlueBits = (byte)mode.Color.Blue;
|
pixelFormat.BlueBits = (byte)mode.Color.Blue;
|
||||||
|
@ -107,17 +107,17 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
if (mode.DepthBits <= 0)
|
if (mode.DepthBits <= 0)
|
||||||
{
|
{
|
||||||
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.DEPTH_DONTCARE;
|
pixelFormat.Flags |= PixelFormatDescriptorFlags.DEPTH_DONTCARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.Stereo)
|
if (mode.Stereo)
|
||||||
{
|
{
|
||||||
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.STEREO;
|
pixelFormat.Flags |= PixelFormatDescriptorFlags.STEREO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.Buffers > 1)
|
if (mode.Buffers > 1)
|
||||||
{
|
{
|
||||||
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.DOUBLEBUFFER;
|
pixelFormat.Flags |= PixelFormatDescriptorFlags.DOUBLEBUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: More elaborate mode setting, using DescribePixelFormat.
|
// TODO: More elaborate mode setting, using DescribePixelFormat.
|
||||||
|
@ -209,8 +209,8 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
API.DeviceMode currentMode = new API.DeviceMode();
|
DeviceMode currentMode = new DeviceMode();
|
||||||
IntPtr handle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(API.DeviceMode)));
|
IntPtr handle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DeviceMode)));
|
||||||
Marshal.StructureToPtr(currentMode, handle, true);
|
Marshal.StructureToPtr(currentMode, handle, true);
|
||||||
|
|
||||||
done = (API.EnumDisplaySettings(null, index++, handle) != 0) ? false : true;
|
done = (API.EnumDisplaySettings(null, index++, handle) != 0) ? false : true;
|
||||||
|
@ -231,7 +231,7 @@ namespace OpenTK.Platform.Windows
|
||||||
DisplayMode mode = new DisplayMode(
|
DisplayMode mode = new DisplayMode(
|
||||||
currentMode.PelsWidth,
|
currentMode.PelsWidth,
|
||||||
currentMode.PelsHeight,
|
currentMode.PelsHeight,
|
||||||
new ColorDepth(currentMode.BitsPerPel),
|
new ColorMode(currentMode.BitsPerPel),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -256,7 +256,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Debug.Print("Manually disposing WinGLContext {0}.", this.renderContext);
|
//Debug.Print("Manually disposing WinGLContext {0}.", this.renderContext);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,8 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
// Clean unmanaged resources here:
|
// Clean unmanaged resources here
|
||||||
|
// The following call uses the Debug and Wgl classes, making it unsafe?
|
||||||
ReleaseResources();
|
ReleaseResources();
|
||||||
|
|
||||||
if (calledManually)
|
if (calledManually)
|
||||||
|
@ -290,9 +291,8 @@ namespace OpenTK.Platform.Windows
|
||||||
Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
|
Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
|
||||||
if (!Wgl.Imports.DeleteContext(renderContext))
|
if (!Wgl.Imports.DeleteContext(renderContext))
|
||||||
{
|
{
|
||||||
throw new ApplicationException(
|
//throw new ApplicationException("Could not destroy the OpenGL render context. Error: " + Marshal.GetLastWin32Error());
|
||||||
"Could not destroy the OpenGL render context. Error: " + Marshal.GetLastWin32Error()
|
//Debug.Print("Could not destroy the OpenGL render context. Error: {0}", Marshal.GetLastWin32Error());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
renderContext = IntPtr.Zero;
|
renderContext = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,8 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
if (!API.ReleaseDC(windowHandle, deviceContext))
|
if (!API.ReleaseDC(windowHandle, deviceContext))
|
||||||
{
|
{
|
||||||
throw new ApplicationException(
|
//throw new ApplicationException("Could not release device context. Error: " + Marshal.GetLastWin32Error());
|
||||||
"Could not release device context. Error: " + Marshal.GetLastWin32Error());
|
//Debug.Print("Could not destroy the device context. Error: {0}", Marshal.GetLastWin32Error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,9 +310,8 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
if (!API.FreeLibrary(opengl32Handle))
|
if (!API.FreeLibrary(opengl32Handle))
|
||||||
{
|
{
|
||||||
throw new ApplicationException(
|
//throw new ApplicationException("FreeLibray call failed ('opengl32.dll'), Error: " + Marshal.GetLastWin32Error());
|
||||||
"FreeLibray call failed ('opengl32.dll'), Error: " + Marshal.GetLastWin32Error()
|
//Debug.Print("Could not release {0}. Error: {1}", opengl32Name, Marshal.GetLastWin32Error());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
opengl32Handle = IntPtr.Zero;
|
opengl32Handle = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
sealed class WinGLControl : OpenTK.Platform.IGLControl
|
sealed class WinGLControl : IGLControl, IDisposable
|
||||||
{
|
{
|
||||||
private WinGLContext glContext;
|
private WinGLContext glContext;
|
||||||
private bool fullscreen;
|
private bool fullscreen;
|
||||||
|
@ -25,7 +25,7 @@ namespace OpenTK.Platform.Windows
|
||||||
private DisplayMode mode;
|
private DisplayMode mode;
|
||||||
|
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
private Message msg; // Used only by the IsIdle event.
|
private MSG msg; // Used only by the IsIdle event.
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ namespace OpenTK.Platform.Windows
|
||||||
glContext = new WinGLContext(mode);
|
glContext = new WinGLContext(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
void c_HandleCreated(object sender, EventArgs e)
|
void c_HandleCreated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Debug.Print("GLControl handle created, creating WinGLContext.");
|
Debug.Print("GLControl handle created, creating WinGLContext.");
|
||||||
|
@ -66,9 +68,7 @@ namespace OpenTK.Platform.Windows
|
||||||
glContext.Dispose();
|
glContext.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#region --- IGLControl members ---
|
||||||
|
|
||||||
#region --- IGLControl membmers ---
|
|
||||||
|
|
||||||
#region public bool IsIdle
|
#region public bool IsIdle
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
return !API.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ namespace OpenTK.Platform.Windows
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.Dispose(true);
|
this.Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
//GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dispose(bool calledManually)
|
private void Dispose(bool calledManually)
|
||||||
|
@ -132,12 +132,12 @@ namespace OpenTK.Platform.Windows
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
~WinGLControl()
|
~WinGLControl()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace OpenTK.Platform.Windows
|
||||||
/// Drives GameWindow on Windows.
|
/// Drives GameWindow on Windows.
|
||||||
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
sealed class WinGLNative : NativeWindow, INativeGLWindow, IDisposable
|
sealed class WinGLNative : NativeWindow, INativeGLWindow
|
||||||
{
|
{
|
||||||
#region --- Fields ---
|
#region --- Fields ---
|
||||||
|
|
||||||
|
@ -35,6 +35,11 @@ namespace OpenTK.Platform.Windows
|
||||||
private WindowInfo window;
|
private WindowInfo window;
|
||||||
private int top, bottom, left, right;
|
private int top, bottom, left, right;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For use in PeekMessage. System.Windows.Forms.Message causes deadlock there.
|
||||||
|
/// </summary>
|
||||||
|
private MSG myGoodMsg = new MSG();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For use in WndProc only.
|
/// For use in WndProc only.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -65,12 +70,12 @@ namespace OpenTK.Platform.Windows
|
||||||
/// <param name="m">Reference to the incoming Windows Message.</param>
|
/// <param name="m">Reference to the incoming Windows Message.</param>
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
{
|
{
|
||||||
switch (m.Msg)
|
switch ((WindowMessage)m.Msg)
|
||||||
{
|
{
|
||||||
case API.Constants.WM_WINDOWPOSCHANGED:
|
case WindowMessage.WINDOWPOSCHANGED:
|
||||||
// Get window size
|
// Get window size
|
||||||
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.WindowPosition), "cx"));
|
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cx"));
|
||||||
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.WindowPosition), "cy"));
|
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cy"));
|
||||||
width -= (left_border + right_border);
|
width -= (left_border + right_border);
|
||||||
height -= (top_border + bottom_border);
|
height -= (top_border + bottom_border);
|
||||||
//if (resizeEventArgs.Width != width || resizeEventArgs.Height != height)
|
//if (resizeEventArgs.Width != width || resizeEventArgs.Height != height)
|
||||||
|
@ -86,10 +91,10 @@ namespace OpenTK.Platform.Windows
|
||||||
// If the message was not a resize notification, send it to the default WndProc.
|
// If the message was not a resize notification, send it to the default WndProc.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case API.Constants.WM_CREATE:
|
case WindowMessage.CREATE:
|
||||||
// Set the window width and height:
|
// Set the window width and height:
|
||||||
this.mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cx"));
|
this.mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cx"));
|
||||||
this.mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cy"));
|
this.mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cy"));
|
||||||
this.mode.Width -= (left_border + right_border);
|
this.mode.Width -= (left_border + right_border);
|
||||||
this.mode.Height -= (top_border + bottom_border);
|
this.mode.Height -= (top_border + bottom_border);
|
||||||
|
|
||||||
|
@ -97,21 +102,23 @@ namespace OpenTK.Platform.Windows
|
||||||
this.OnCreate(EventArgs.Empty);
|
this.OnCreate(EventArgs.Empty);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case API.Constants.WM_CLOSE:
|
case WindowMessage.CLOSE:
|
||||||
this.DestroyWindow();
|
this.DestroyWindow();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case API.Constants.WM_DESTROY:
|
case WindowMessage.DESTROY:
|
||||||
this.OnDestroy(EventArgs.Empty);
|
this.OnDestroy(EventArgs.Empty);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case API.Constants.WM_QUIT:
|
case WindowMessage.QUIT:
|
||||||
isExiting = true;
|
isExiting = true;
|
||||||
|
//this.Dispose();
|
||||||
//Debug.WriteLine("Application quit.");
|
//Debug.WriteLine("Application quit.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefWndProc(ref m);
|
//DefWndProc(ref m);
|
||||||
|
base.WndProc(ref m);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -121,12 +128,12 @@ namespace OpenTK.Platform.Windows
|
||||||
#region public void ProcessEvents()
|
#region public void ProcessEvents()
|
||||||
|
|
||||||
private int ret;
|
private int ret;
|
||||||
System.Windows.Forms.Message msg;
|
MSG msg;
|
||||||
public void ProcessEvents()
|
public void ProcessEvents()
|
||||||
{
|
{
|
||||||
while (!IsIdle)
|
while (!IsIdle)
|
||||||
{
|
{
|
||||||
ret = API.GetMessage(out msg, Handle, 0, 0);
|
ret = API.GetMessage(ref msg, Handle, 0, 0);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
throw new ApplicationException(String.Format(
|
throw new ApplicationException(String.Format(
|
||||||
|
@ -195,7 +202,7 @@ namespace OpenTK.Platform.Windows
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
//return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
||||||
return !API.PeekMessage(out msg, this.Handle, 0, 0, 0);
|
return !API.PeekMessage(ref myGoodMsg, this.Handle, 0, 0, 0);
|
||||||
//return API.GetQueueStatus(API.QueueStatusFlags.ALLEVENTS) == 0;
|
//return API.GetQueueStatus(API.QueueStatusFlags.ALLEVENTS) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,21 +227,21 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
CreateParams cp = new CreateParams();
|
CreateParams cp = new CreateParams();
|
||||||
cp.ClassStyle =
|
cp.ClassStyle =
|
||||||
(int)API.WindowClassStyle.OwnDC |
|
(int)WindowClassStyle.OwnDC |
|
||||||
(int)API.WindowClassStyle.VRedraw |
|
(int)WindowClassStyle.VRedraw |
|
||||||
(int)API.WindowClassStyle.HRedraw |
|
(int)WindowClassStyle.HRedraw |
|
||||||
(int)API.WindowClassStyle.Ime;
|
(int)WindowClassStyle.Ime;
|
||||||
cp.Style =
|
cp.Style =
|
||||||
(int)API.WindowStyle.Visible |
|
(int)WindowStyle.Visible |
|
||||||
(int)API.WindowStyle.ClipChildren |
|
(int)WindowStyle.ClipChildren |
|
||||||
(int)API.WindowStyle.ClipSiblings |
|
(int)WindowStyle.ClipSiblings |
|
||||||
(int)API.WindowStyle.OverlappedWindow;
|
(int)WindowStyle.OverlappedWindow;
|
||||||
|
|
||||||
API.Rectangle rect = new API.Rectangle();
|
Rectangle rect = new Rectangle();
|
||||||
rect.top = rect.left = 0;
|
rect.top = rect.left = 0;
|
||||||
rect.bottom = windowMode.Height;
|
rect.bottom = windowMode.Height;
|
||||||
rect.right = windowMode.Width;
|
rect.right = windowMode.Width;
|
||||||
API.AdjustWindowRect(ref rect, API.WindowStyle.OverlappedWindow, false);
|
API.AdjustWindowRect(ref rect, WindowStyle.OverlappedWindow, false);
|
||||||
|
|
||||||
// Not used
|
// Not used
|
||||||
Top = 0;
|
Top = 0;
|
||||||
|
@ -315,7 +322,7 @@ namespace OpenTK.Platform.Windows
|
||||||
public void DestroyWindow()
|
public void DestroyWindow()
|
||||||
{
|
{
|
||||||
Debug.Print("Destroying window: {0}", window.ToString());
|
Debug.Print("Destroying window: {0}", window.ToString());
|
||||||
API.PostMessage(this.Handle, API.Constants.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
|
API.PostMessage(this.Handle, WindowMessage.DESTROY, IntPtr.Zero, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -428,7 +435,7 @@ namespace OpenTK.Platform.Windows
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.Dispose(true);
|
this.Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
//GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dispose(bool calledManually)
|
private void Dispose(bool calledManually)
|
||||||
|
@ -441,17 +448,17 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
// Safe to clean managed resources
|
// Safe to clean managed resources
|
||||||
glContext.Dispose();
|
glContext.Dispose();
|
||||||
base.DestroyHandle();
|
//base.DestroyHandle();
|
||||||
}
|
}
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
~WinGLNative()
|
~WinGLNative()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace OpenTK.Platform.Windows
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Input event data.
|
/// Input event data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private API.RawInput data = new API.RawInput();
|
private RawInput data = new RawInput();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total number of input devices connected to this system.
|
/// The total number of input devices connected to this system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -70,12 +70,12 @@ namespace OpenTK.Platform.Windows
|
||||||
/// <param name="msg">The WM_INPUT message, containing the data on the input event.</param>
|
/// <param name="msg">The WM_INPUT message, containing the data on the input event.</param>
|
||||||
protected override void WndProc(ref Message msg)
|
protected override void WndProc(ref Message msg)
|
||||||
{
|
{
|
||||||
switch (msg.Msg)
|
switch ((WindowMessage)msg.Msg)
|
||||||
{
|
{
|
||||||
case API.Constants.WM_INPUT:
|
case WindowMessage.INPUT:
|
||||||
size = 0;
|
size = 0;
|
||||||
// Get the size of the input data
|
// Get the size of the input data
|
||||||
API.GetRawInputData(msg.LParam, API.GetRawInputDataEnum.INPUT,
|
API.GetRawInputData(msg.LParam, GetRawInputDataEnum.INPUT,
|
||||||
IntPtr.Zero, ref size, API.RawInputHeaderSize);
|
IntPtr.Zero, ref size, API.RawInputHeaderSize);
|
||||||
|
|
||||||
//if (data == null || API.RawInputSize < size)
|
//if (data == null || API.RawInputSize < size)
|
||||||
|
@ -83,21 +83,21 @@ namespace OpenTK.Platform.Windows
|
||||||
// throw new ApplicationException("Critical error when processing raw windows input.");
|
// throw new ApplicationException("Critical error when processing raw windows input.");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (size == API.GetRawInputData(msg.LParam, API.GetRawInputDataEnum.INPUT,
|
if (size == API.GetRawInputData(msg.LParam, GetRawInputDataEnum.INPUT,
|
||||||
data, ref size, API.RawInputHeaderSize))
|
data, ref size, API.RawInputHeaderSize))
|
||||||
{
|
{
|
||||||
switch (data.Header.Type)
|
switch (data.Header.Type)
|
||||||
{
|
{
|
||||||
case API.RawInputDeviceType.KEYBOARD:
|
case RawInputDeviceType.KEYBOARD:
|
||||||
if (!keyboardDriver.ProcessKeyboardEvent(data))
|
if (!keyboardDriver.ProcessKeyboardEvent(data))
|
||||||
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
|
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case API.RawInputDeviceType.MOUSE:
|
case RawInputDeviceType.MOUSE:
|
||||||
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
|
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case API.RawInputDeviceType.HID:
|
case RawInputDeviceType.HID:
|
||||||
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
|
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,13 @@ namespace OpenTK.Platform.Windows
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case API.Constants.WM_CLOSE:
|
case WindowMessage.CLOSE:
|
||||||
case API.Constants.WM_DESTROY:
|
case WindowMessage.DESTROY:
|
||||||
Debug.Print("Input window detached from parent {0}.", Handle);
|
Debug.Print("Input window detached from parent {0}.", Handle);
|
||||||
ReleaseHandle();
|
ReleaseHandle();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case API.Constants.WM_QUIT:
|
case WindowMessage.QUIT:
|
||||||
Debug.WriteLine("Input window quit.");
|
Debug.WriteLine("Input window quit.");
|
||||||
this.Dispose();
|
this.Dispose();
|
||||||
break;
|
break;
|
||||||
|
@ -168,6 +168,7 @@ namespace OpenTK.Platform.Windows
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
keyboardDriver.Dispose();
|
keyboardDriver.Dispose();
|
||||||
|
this.ReleaseHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
disposed = true;
|
disposed = true;
|
||||||
|
|
|
@ -23,10 +23,10 @@ namespace OpenTK.Platform.Windows
|
||||||
private List<Keyboard> keyboards = new List<Keyboard>();
|
private List<Keyboard> keyboards = new List<Keyboard>();
|
||||||
private IntPtr windowHandle;
|
private IntPtr windowHandle;
|
||||||
|
|
||||||
#region internal static Dictionary<API.VirtualKeys, Input.Key> KeyMap
|
#region internal static Dictionary<VirtualKeys, Input.Key> KeyMap
|
||||||
|
|
||||||
internal static Dictionary<API.VirtualKeys, Input.Key> KeyMap =
|
internal static Dictionary<VirtualKeys, Input.Key> KeyMap =
|
||||||
new Dictionary<API.VirtualKeys, Input.Key>((int)API.VirtualKeys.Last);
|
new Dictionary<VirtualKeys, Input.Key>((int)VirtualKeys.Last);
|
||||||
|
|
||||||
private static bool keyMapExists;
|
private static bool keyMapExists;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -38,81 +38,81 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
KeyMap.Add(API.VirtualKeys.ESCAPE, Input.Key.Escape);
|
KeyMap.Add(VirtualKeys.ESCAPE, Input.Key.Escape);
|
||||||
|
|
||||||
// Function keys
|
// Function keys
|
||||||
for (int i = 0; i < 24; i++)
|
for (int i = 0; i < 24; i++)
|
||||||
{
|
{
|
||||||
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.F1 + i), Input.Key.F1 + i);
|
KeyMap.Add((VirtualKeys)((int)VirtualKeys.F1 + i), Input.Key.F1 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number keys (0-9)
|
// Number keys (0-9)
|
||||||
for (int i = 0; i <= 9; i++)
|
for (int i = 0; i <= 9; i++)
|
||||||
{
|
{
|
||||||
KeyMap.Add((API.VirtualKeys)(0x30 + i), Input.Key.Number0 + i);
|
KeyMap.Add((VirtualKeys)(0x30 + i), Input.Key.Number0 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Letters (A-Z)
|
// Letters (A-Z)
|
||||||
for (int i = 0; i < 26; i++)
|
for (int i = 0; i < 26; i++)
|
||||||
{
|
{
|
||||||
KeyMap.Add((API.VirtualKeys)(0x41 + i), Input.Key.A + i);
|
KeyMap.Add((VirtualKeys)(0x41 + i), Input.Key.A + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyMap.Add(API.VirtualKeys.TAB, Input.Key.Tab);
|
KeyMap.Add(VirtualKeys.TAB, Input.Key.Tab);
|
||||||
KeyMap.Add(API.VirtualKeys.CAPITAL, Input.Key.CapsLock);
|
KeyMap.Add(VirtualKeys.CAPITAL, Input.Key.CapsLock);
|
||||||
KeyMap.Add(API.VirtualKeys.LCONTROL, Input.Key.ControlLeft);
|
KeyMap.Add(VirtualKeys.LCONTROL, Input.Key.ControlLeft);
|
||||||
KeyMap.Add(API.VirtualKeys.LSHIFT, Input.Key.ShiftLeft);
|
KeyMap.Add(VirtualKeys.LSHIFT, Input.Key.ShiftLeft);
|
||||||
KeyMap.Add(API.VirtualKeys.LWIN, Input.Key.WinLeft);
|
KeyMap.Add(VirtualKeys.LWIN, Input.Key.WinLeft);
|
||||||
KeyMap.Add(API.VirtualKeys.LMENU, Input.Key.AltLeft);
|
KeyMap.Add(VirtualKeys.LMENU, Input.Key.AltLeft);
|
||||||
KeyMap.Add(API.VirtualKeys.SPACE, Input.Key.Space);
|
KeyMap.Add(VirtualKeys.SPACE, Input.Key.Space);
|
||||||
KeyMap.Add(API.VirtualKeys.RMENU, Input.Key.AltRight);
|
KeyMap.Add(VirtualKeys.RMENU, Input.Key.AltRight);
|
||||||
KeyMap.Add(API.VirtualKeys.RWIN, Input.Key.WinRight);
|
KeyMap.Add(VirtualKeys.RWIN, Input.Key.WinRight);
|
||||||
KeyMap.Add(API.VirtualKeys.APPS, Input.Key.Menu);
|
KeyMap.Add(VirtualKeys.APPS, Input.Key.Menu);
|
||||||
KeyMap.Add(API.VirtualKeys.RCONTROL, Input.Key.ControlRight);
|
KeyMap.Add(VirtualKeys.RCONTROL, Input.Key.ControlRight);
|
||||||
KeyMap.Add(API.VirtualKeys.RSHIFT, Input.Key.ShiftRight);
|
KeyMap.Add(VirtualKeys.RSHIFT, Input.Key.ShiftRight);
|
||||||
KeyMap.Add(API.VirtualKeys.RETURN, Input.Key.Enter);
|
KeyMap.Add(VirtualKeys.RETURN, Input.Key.Enter);
|
||||||
KeyMap.Add(API.VirtualKeys.BACK, Input.Key.BackSpace);
|
KeyMap.Add(VirtualKeys.BACK, Input.Key.BackSpace);
|
||||||
|
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_1, Input.Key.Semicolon); // Varies by keyboard, ;: on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_1, Input.Key.Semicolon); // Varies by keyboard, ;: on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_2, Input.Key.Slash); // Varies by keyboard, /? on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_2, Input.Key.Slash); // Varies by keyboard, /? on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_3, Input.Key.Tilde); // Varies by keyboard, `~ on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_3, Input.Key.Tilde); // Varies by keyboard, `~ on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_4, Input.Key.BracketLeft); // Varies by keyboard, [{ on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_4, Input.Key.BracketLeft); // Varies by keyboard, [{ on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_5, Input.Key.BackSlash); // Varies by keyboard, \| on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_5, Input.Key.BackSlash); // Varies by keyboard, \| on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_6, Input.Key.BracketRight); // Varies by keyboard, ]} on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_6, Input.Key.BracketRight); // Varies by keyboard, ]} on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_7, Input.Key.Quote); // Varies by keyboard, '" on Win2K/US
|
KeyMap.Add(VirtualKeys.OEM_7, Input.Key.Quote); // Varies by keyboard, '" on Win2K/US
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_PLUS, Input.Key.Plus); // Invariant: +
|
KeyMap.Add(VirtualKeys.OEM_PLUS, Input.Key.Plus); // Invariant: +
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_COMMA, Input.Key.Comma); // Invariant: ,
|
KeyMap.Add(VirtualKeys.OEM_COMMA, Input.Key.Comma); // Invariant: ,
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_MINUS, Input.Key.Minus); // Invariant: -
|
KeyMap.Add(VirtualKeys.OEM_MINUS, Input.Key.Minus); // Invariant: -
|
||||||
KeyMap.Add(API.VirtualKeys.OEM_PERIOD, Input.Key.Period); // Invariant: .
|
KeyMap.Add(VirtualKeys.OEM_PERIOD, Input.Key.Period); // Invariant: .
|
||||||
|
|
||||||
KeyMap.Add(API.VirtualKeys.HOME, Input.Key.Home);
|
KeyMap.Add(VirtualKeys.HOME, Input.Key.Home);
|
||||||
KeyMap.Add(API.VirtualKeys.END, Input.Key.End);
|
KeyMap.Add(VirtualKeys.END, Input.Key.End);
|
||||||
KeyMap.Add(API.VirtualKeys.DELETE, Input.Key.Delete);
|
KeyMap.Add(VirtualKeys.DELETE, Input.Key.Delete);
|
||||||
KeyMap.Add(API.VirtualKeys.PRIOR, Input.Key.PageUp);
|
KeyMap.Add(VirtualKeys.PRIOR, Input.Key.PageUp);
|
||||||
KeyMap.Add(API.VirtualKeys.NEXT, Input.Key.PageDown);
|
KeyMap.Add(VirtualKeys.NEXT, Input.Key.PageDown);
|
||||||
KeyMap.Add(API.VirtualKeys.PRINT, Input.Key.PrintScreen);
|
KeyMap.Add(VirtualKeys.PRINT, Input.Key.PrintScreen);
|
||||||
KeyMap.Add(API.VirtualKeys.PAUSE, Input.Key.Pause);
|
KeyMap.Add(VirtualKeys.PAUSE, Input.Key.Pause);
|
||||||
KeyMap.Add(API.VirtualKeys.NUMLOCK, Input.Key.NumLock);
|
KeyMap.Add(VirtualKeys.NUMLOCK, Input.Key.NumLock);
|
||||||
|
|
||||||
KeyMap.Add(API.VirtualKeys.SLEEP, Input.Key.Sleep);
|
KeyMap.Add(VirtualKeys.SLEEP, Input.Key.Sleep);
|
||||||
|
|
||||||
// Keypad
|
// Keypad
|
||||||
for (int i = 0; i <= 9; i++)
|
for (int i = 0; i <= 9; i++)
|
||||||
{
|
{
|
||||||
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.NUMPAD0 + i), Input.Key.Keypad0 + i);
|
KeyMap.Add((VirtualKeys)((int)VirtualKeys.NUMPAD0 + i), Input.Key.Keypad0 + i);
|
||||||
|
|
||||||
}
|
}
|
||||||
KeyMap.Add(API.VirtualKeys.DECIMAL, Input.Key.KeypadDecimal);
|
KeyMap.Add(VirtualKeys.DECIMAL, Input.Key.KeypadDecimal);
|
||||||
KeyMap.Add(API.VirtualKeys.ADD, Input.Key.KeypadAdd);
|
KeyMap.Add(VirtualKeys.ADD, Input.Key.KeypadAdd);
|
||||||
KeyMap.Add(API.VirtualKeys.SUBTRACT, Input.Key.KeypadSubtract);
|
KeyMap.Add(VirtualKeys.SUBTRACT, Input.Key.KeypadSubtract);
|
||||||
KeyMap.Add(API.VirtualKeys.DIVIDE, Input.Key.KeypadDivide);
|
KeyMap.Add(VirtualKeys.DIVIDE, Input.Key.KeypadDivide);
|
||||||
KeyMap.Add(API.VirtualKeys.MULTIPLY, Input.Key.KeypadMultiply);
|
KeyMap.Add(VirtualKeys.MULTIPLY, Input.Key.KeypadMultiply);
|
||||||
|
|
||||||
// Navigation
|
// Navigation
|
||||||
KeyMap.Add(API.VirtualKeys.UP, Input.Key.Up);
|
KeyMap.Add(VirtualKeys.UP, Input.Key.Up);
|
||||||
KeyMap.Add(API.VirtualKeys.DOWN, Input.Key.Down);
|
KeyMap.Add(VirtualKeys.DOWN, Input.Key.Down);
|
||||||
KeyMap.Add(API.VirtualKeys.LEFT, Input.Key.Left);
|
KeyMap.Add(VirtualKeys.LEFT, Input.Key.Left);
|
||||||
KeyMap.Add(API.VirtualKeys.RIGHT, Input.Key.Right);
|
KeyMap.Add(VirtualKeys.RIGHT, Input.Key.Right);
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (ArgumentException e)
|
||||||
{
|
{
|
||||||
|
@ -156,18 +156,18 @@ namespace OpenTK.Platform.Windows
|
||||||
internal void UpdateKeyboardList()
|
internal void UpdateKeyboardList()
|
||||||
{
|
{
|
||||||
int count = WinRawInput.DeviceCount;
|
int count = WinRawInput.DeviceCount;
|
||||||
API.RawInputDeviceList[] ridl = new API.RawInputDeviceList[count];
|
RawInputDeviceList[] ridl = new RawInputDeviceList[count];
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
ridl[i] = new API.RawInputDeviceList();
|
ridl[i] = new RawInputDeviceList();
|
||||||
API.GetRawInputDeviceList(ridl, ref count, API.RawInputDeviceListSize);
|
API.GetRawInputDeviceList(ridl, ref count, API.RawInputDeviceListSize);
|
||||||
|
|
||||||
// Discover keyboard devices:
|
// Discover keyboard devices:
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
uint size = 0;
|
uint size = 0;
|
||||||
API.GetRawInputDeviceInfo(ridl[i].Device, API.RawInputDeviceInfoEnum.DEVICENAME, IntPtr.Zero, ref size);
|
API.GetRawInputDeviceInfo(ridl[i].Device, RawInputDeviceInfoEnum.DEVICENAME, IntPtr.Zero, ref size);
|
||||||
IntPtr name_ptr = Marshal.AllocHGlobal((IntPtr)size);
|
IntPtr name_ptr = Marshal.AllocHGlobal((IntPtr)size);
|
||||||
API.GetRawInputDeviceInfo(ridl[i].Device, API.RawInputDeviceInfoEnum.DEVICENAME, name_ptr, ref size);
|
API.GetRawInputDeviceInfo(ridl[i].Device, RawInputDeviceInfoEnum.DEVICENAME, name_ptr, ref size);
|
||||||
string name = Marshal.PtrToStringAnsi(name_ptr);
|
string name = Marshal.PtrToStringAnsi(name_ptr);
|
||||||
Marshal.FreeHGlobal(name_ptr);
|
Marshal.FreeHGlobal(name_ptr);
|
||||||
if (name.ToLower().Contains("root"))
|
if (name.ToLower().Contains("root"))
|
||||||
|
@ -175,7 +175,7 @@ namespace OpenTK.Platform.Windows
|
||||||
// This is a terminal services devices, skip it.
|
// This is a terminal services devices, skip it.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (ridl[i].Type == API.RawInputDeviceType.KEYBOARD || ridl[i].Type == API.RawInputDeviceType.HID)
|
else if (ridl[i].Type == RawInputDeviceType.KEYBOARD || ridl[i].Type == RawInputDeviceType.HID)
|
||||||
{
|
{
|
||||||
//It's a keyboard – or a USB device that could be a keyboard
|
//It's a keyboard – or a USB device that could be a keyboard
|
||||||
|
|
||||||
|
@ -206,9 +206,9 @@ namespace OpenTK.Platform.Windows
|
||||||
kb.Description = deviceDesc;
|
kb.Description = deviceDesc;
|
||||||
|
|
||||||
// Register the keyboard:
|
// Register the keyboard:
|
||||||
API.RawInputDeviceInfo info = new API.RawInputDeviceInfo();
|
RawInputDeviceInfo info = new RawInputDeviceInfo();
|
||||||
int devInfoSize = API.RawInputDeviceInfoSize;
|
int devInfoSize = API.RawInputDeviceInfoSize;
|
||||||
API.GetRawInputDeviceInfo(ridl[i].Device, API.RawInputDeviceInfoEnum.DEVICEINFO,
|
API.GetRawInputDeviceInfo(ridl[i].Device, RawInputDeviceInfoEnum.DEVICEINFO,
|
||||||
info, ref devInfoSize);
|
info, ref devInfoSize);
|
||||||
|
|
||||||
kb.NumberOfLeds = info.Device.Keyboard.NumberOfIndicators;
|
kb.NumberOfLeds = info.Device.Keyboard.NumberOfIndicators;
|
||||||
|
@ -232,12 +232,12 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
internal void RegisterKeyboardDevice(Keyboard kb)
|
internal void RegisterKeyboardDevice(Keyboard kb)
|
||||||
{
|
{
|
||||||
API.RawInputDevice[] rid = new API.RawInputDevice[1];
|
RawInputDevice[] rid = new RawInputDevice[1];
|
||||||
// Keyboard is 1/6 (page/id). See http://www.microsoft.com/whdc/device/input/HID_HWID.mspx
|
// Keyboard is 1/6 (page/id). See http://www.microsoft.com/whdc/device/input/HID_HWID.mspx
|
||||||
rid[0] = new API.RawInputDevice();
|
rid[0] = new RawInputDevice();
|
||||||
rid[0].UsagePage = 1;
|
rid[0].UsagePage = 1;
|
||||||
rid[0].Usage = 6;
|
rid[0].Usage = 6;
|
||||||
rid[0].Flags = API.RawInputDeviceFlags.INPUTSINK;
|
rid[0].Flags = RawInputDeviceFlags.INPUTSINK;
|
||||||
rid[0].Target = windowHandle;
|
rid[0].Target = windowHandle;
|
||||||
|
|
||||||
if (!API.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
|
if (!API.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
|
||||||
|
@ -264,30 +264,30 @@ namespace OpenTK.Platform.Windows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rin"></param>
|
/// <param name="rin"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal bool ProcessKeyboardEvent(API.RawInput rin)
|
internal bool ProcessKeyboardEvent(RawInput rin)
|
||||||
{
|
{
|
||||||
//Keyboard key = keyboards[0];
|
//Keyboard key = keyboards[0];
|
||||||
//rin.Header.Device;
|
//rin.Header.Device;
|
||||||
switch (rin.Header.Type)
|
switch (rin.Header.Type)
|
||||||
{
|
{
|
||||||
case API.RawInputDeviceType.KEYBOARD:
|
case RawInputDeviceType.KEYBOARD:
|
||||||
bool pressed =
|
bool pressed =
|
||||||
rin.Data.Keyboard.Message == API.Constants.WM_KEYDOWN ||
|
rin.Data.Keyboard.Message == (int)WindowMessage.KEYDOWN ||
|
||||||
rin.Data.Keyboard.Message == API.Constants.WM_SYSKEYDOWN;
|
rin.Data.Keyboard.Message == (int)WindowMessage.SYSKEYDOWN;
|
||||||
|
|
||||||
// Generic control, shift, alt keys may be sent instead of left/right.
|
// Generic control, shift, alt keys may be sent instead of left/right.
|
||||||
// It seems you have to explicitly register left/right events.
|
// It seems you have to explicitly register left/right events.
|
||||||
switch (rin.Data.Keyboard.VKey)
|
switch (rin.Data.Keyboard.VKey)
|
||||||
{
|
{
|
||||||
case API.VirtualKeys.SHIFT:
|
case VirtualKeys.SHIFT:
|
||||||
keyboards[0][Input.Key.ShiftLeft] = keyboards[0][Input.Key.ShiftRight] = pressed;
|
keyboards[0][Input.Key.ShiftLeft] = keyboards[0][Input.Key.ShiftRight] = pressed;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case API.VirtualKeys.CONTROL:
|
case VirtualKeys.CONTROL:
|
||||||
keyboards[0][Input.Key.ControlLeft] = keyboards[0][Input.Key.ControlRight] = pressed;
|
keyboards[0][Input.Key.ControlLeft] = keyboards[0][Input.Key.ControlRight] = pressed;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case API.VirtualKeys.MENU:
|
case VirtualKeys.MENU:
|
||||||
keyboards[0][Input.Key.AltLeft] = keyboards[0][Input.Key.AltRight] = pressed;
|
keyboards[0][Input.Key.AltLeft] = keyboards[0][Input.Key.AltRight] = pressed;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -349,9 +349,8 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
//keyboards.Clear();
|
keyboards.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue