Move Windows-specific projects into separate solution.

This commit is contained in:
wo80
2022-03-05 01:01:39 +01:00
parent 11e42c98f4
commit 23c2682c6e
23 changed files with 161 additions and 158 deletions
@@ -0,0 +1,35 @@
namespace TriangleNet.Rendering.GDI.Native
{
using System;
/// <summary>
/// Specifies gradient fill mode
/// </summary>
[Flags]
internal enum GradientFillMode : uint
{
/// <summary>
/// In this mode, two endpoints describe a rectangle. The rectangle is defined
/// to have a constant color (specified by the TRIVERTEX structure) for the
/// left and right edges. GDI interpolates the color from the left to right
/// edge and fills the interior
/// </summary>
GRADIENT_FILL_RECT_H = 0,
/// <summary>
/// In this mode, two endpoints describe a rectangle. The rectangle is
/// defined to have a constant color (specified by the TRIVERTEX structure)
/// for the top and bottom edges. GDI interpolates the color from the top
/// to bottom edge and fills the interior
/// </summary>
GRADIENT_FILL_RECT_V = 1,
/// <summary>
/// In this mode, an array of TRIVERTEX structures is passed to GDI
/// along with a list of array indexes that describe separate triangles.
/// GDI performs linear interpolation between triangle vertices and fills
/// the interior. Drawing is done directly in 24- and 32-bpp modes.
/// Dithering is performed in 16-, 8-, 4-, and 1-bpp mode
/// </summary>
GRADIENT_FILL_TRIANGLE = 2
}
}
@@ -0,0 +1,28 @@
namespace TriangleNet.Rendering.GDI.Native
{
using System.Runtime.InteropServices;
/// <summary>
/// The GRADIENT_RECT structure specifies the index of two vertices in the
/// pVertex array in the GradientFill function. These two vertices form the
/// upper-left and lower-right boundaries of a rectangle.
/// </summary>
/// <remarks>
/// http://msdn.microsoft.com/en-us/library/windows/desktop/dd144958.aspx
/// </remarks>
[StructLayout(LayoutKind.Sequential)]
internal struct GradientRect
{
/// <summary>
/// The upper-left corner of a rectangle.
/// </summary>
public uint UpperLeft;
/// <summary>
/// The lower-right corner of a rectangle.
/// </summary>
public uint LowerRight;
}
}
@@ -0,0 +1,32 @@
namespace TriangleNet.Rendering.GDI.Native
{
using System.Runtime.InteropServices;
/// <summary>
/// The GRADIENT_TRIANGLE structure specifies the index of three
/// vertices in the pVertex array in the GradientFill function.
/// These three vertices form one triangle
/// </summary>
/// <remarks>
/// http://msdn.microsoft.com/en-us/library/windows/desktop/dd144959.aspx
/// </remarks>
[StructLayout(LayoutKind.Sequential)]
internal struct GradientTriangle
{
/// <summary>
/// The first point of the triangle where sides intersect.
/// </summary>
public uint Vertex1;
/// <summary>
/// The second point of the triangle where sides intersect.
/// </summary>
public uint Vertex2;
/// <summary>
/// The third point of the triangle where sides intersect.
/// </summary>
public uint Vertex3;
}
}
@@ -0,0 +1,90 @@
namespace TriangleNet.Rendering.GDI.Native
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// PInvoke signatures for GradientFill methods.
/// </summary>
/// <remarks>
/// Minimum requirements: Windows 2000 Professional
///
/// http://msdn.microsoft.com/en-us/library/windows/desktop/dd144957.aspx
/// </remarks>
internal static class NativeMethods
{
/// <summary>
/// The GradientFill function fills rectangle and triangle structures
/// </summary>
/// <param name="hdc">Handle to the destination device context</param>
/// <param name="pVertex">Array of TRIVERTEX structures that each define a triangle vertex</param>
/// <param name="nVertex">The number of vertices in pVertex</param>
/// <param name="pMesh">Array of elements</param>
/// <param name="nMesh">The number of elements in pMesh</param>
/// <param name="ulMode">Specifies gradient fill mode</param>
/// <returns>If the function succeeds, the return value is true, false</returns>
public static bool GradientFill([In] IntPtr hdc, TriVertex[] pVertex, uint nVertex, uint[] pMesh, uint nMesh,
GradientFillMode ulMode)
{
return Native.GradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode);
}
/// <summary>
/// The GradientFill function fills rectangle and triangle structures
/// </summary>
/// <param name="hdc">Handle to the destination device context</param>
/// <param name="pVertex">Array of TRIVERTEX structures that each define a triangle vertex</param>
/// <param name="nVertex">The number of vertices in pVertex</param>
/// <param name="pMesh">Array of GRADIENT_TRIANGLE structures in triangle mode</param>
/// <param name="nMesh">The number of elements in pMesh</param>
/// <param name="ulMode">Specifies gradient fill mode</param>
/// <returns>If the function succeeds, the return value is true, false</returns>
public static bool GradientFill([In] IntPtr hdc, TriVertex[] pVertex, uint nVertex, GradientTriangle[] pMesh,
uint nMesh, GradientFillMode ulMode)
{
return Native.GradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode);
}
/// <summary>
/// The GradientFill function fills rectangle and triangle structures
/// </summary>
/// <param name="hdc">Handle to the destination device context</param>
/// <param name="pVertex">Array of TRIVERTEX structures that each define a triangle vertex</param>
/// <param name="nVertex">The number of vertices in pVertex</param>
/// <param name="pMesh">an array of GRADIENT_RECT structures in rectangle mode</param>
/// <param name="nMesh">The number of elements in pMesh</param>
/// <param name="ulMode">Specifies gradient fill mode</param>
/// <returns>If the function succeeds, the return value is true, false</returns>
public static bool GradientFill([In] IntPtr hdc, TriVertex[] pVertex, uint nVertex, GradientRect[] pMesh,
uint nMesh, GradientFillMode ulMode)
{
return Native.GradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode);
}
#region Nested type: Native
internal class Native
{
[DllImport("msimg32.dll", EntryPoint = "GradientFill", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GradientFill([In] IntPtr hdc,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] TriVertex[] pVertex,
uint nVertex, uint[] pMesh, uint nMesh, GradientFillMode ulMode);
[DllImport("msimg32.dll", EntryPoint = "GradientFill", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GradientFill([In] IntPtr hdc,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] TriVertex[] pVertex,
uint nVertex, GradientRect[] pMesh, uint nMesh, GradientFillMode ulMode);
[DllImport("msimg32.dll", EntryPoint = "GradientFill", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GradientFill([In] IntPtr hdc,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] TriVertex[] pVertex,
uint nVertex, GradientTriangle[] pMesh, uint nMesh, GradientFillMode ulMode);
}
#endregion
}
}
@@ -0,0 +1,45 @@
namespace TriangleNet.Rendering.GDI.Native
{
using System.Runtime.InteropServices;
/// <summary>
/// The TRIVERTEX structure contains color information and position information.
/// </summary>
/// <remarks>
/// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145142.aspx
/// </remarks>
[StructLayout(LayoutKind.Sequential)]
internal struct TriVertex
{
/// <summary>
/// The x-coordinate, in logical units, of the upper-left corner of the rectangle
/// </summary>
public int x;
/// <summary>
/// The y-coordinate, in logical units, of the upper-left corner of the rectangle
/// </summary>
public int y;
/// <summary>
/// The color information at the point of x, y
/// </summary>
public ushort Red;
/// <summary>
/// The color information at the point of x, y
/// </summary>
public ushort Green;
/// <summary>
/// The color information at the point of x, y
/// </summary>
public ushort Blue;
/// <summary>
/// The color information at the point of x, y
/// </summary>
public ushort Alpha;
}
}