daily update on 20240213 by nitload youmu. 逐步弃用GLFW,正在使用wgl重写glfw底层,相关实现转移到C#实现,SSC彻底变成线性代数计算器。

This commit is contained in:
Nitload
2024-02-13 23:42:22 +08:00
parent 8391569482
commit a2241a5a58
307 changed files with 16701 additions and 10296 deletions
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
#if Windows
using Microsoft.Win32.SafeHandles;
using Windows.Win32;
using Windows.Win32.Graphics.OpenGL;
using Windows.Win32.Graphics.Gdi;
namespace StgSharp.Envitronment.Win32
{
public readonly partial struct DeviceContextHandle
: IEquatable<DeviceContextHandle>
{
internal readonly IntPtr Value;
internal DeviceContextHandle(nint value) => this.Value = value;
public static explicit operator DeviceContextHandle(IntPtr value) => new DeviceContextHandle(value);
public static implicit operator IntPtr(DeviceContextHandle value) => value.Value;
public static bool operator !=(DeviceContextHandle left, DeviceContextHandle right) => !(left == right);
public static bool operator ==(DeviceContextHandle left, DeviceContextHandle right) => left.Value == right.Value;
public bool Equals(DeviceContextHandle other) => this.Value == other.Value;
public override bool Equals(object obj) => obj is DeviceContextHandle other && this.Equals(other);
public override int GetHashCode() => this.Value.GetHashCode();
public override string ToString() => $"0x{this.Value:x}";
}
public readonly partial struct GlRenderContextHandle
: IEquatable<GlRenderContextHandle>
{
internal readonly IntPtr Value;
internal GlRenderContextHandle(IntPtr value) => this.Value = value;
internal static GlRenderContextHandle Null => default;
internal bool IsNull => Value == default;
public static explicit operator GlRenderContextHandle(IntPtr value) => new GlRenderContextHandle(value);
public static implicit operator IntPtr(GlRenderContextHandle value) => value.Value;
public static bool operator !=(GlRenderContextHandle left, GlRenderContextHandle right) => !(left == right);
public static bool operator ==(GlRenderContextHandle left, GlRenderContextHandle right) => left.Value == right.Value;
public bool Equals(GlRenderContextHandle other) => this.Value == other.Value;
public override bool Equals(object obj) => obj is GlRenderContextHandle other && this.Equals(other);
public override int GetHashCode() => this.Value.GetHashCode();
public override string ToString() => $"0x{this.Value:x}";
}
public struct WGLconst
{
#region Attribute
public const int ACCELERATION_ARB = 0x2003;
public const int ACCUM_ALPHA_BITS_ARB = 0x2021;
public const int ACCUM_BITS_ARB = 0x201D;
public const int ACCUM_BLUE_BITS_ARB = 0x2020;
public const int ACCUM_GREEN_BITS_ARB = 0x201F;
public const int ACCUM_RED_BITS_ARB = 0x201E;
public const int ALPHA_BITS_ARB = 0x201B;
public const int ALPHA_SHIFT_ARB = 0x201C;
public const int AUX_BUFFERS_ARB = 0x2024;
public const int BLUE_BITS_ARB = 0x2019;
public const int BLUE_SHIFT_ARB = 0x201A;
public const int COLOR_BITS_ARB = 0x2014;
public const int DEPTH_BITS_ARB = 0x2022;
public const int DOUBLE_BUFFER_ARB = 0x2011;
public const int DRAW_TO_BITMAP_ARB = 0x2002;
public const int DRAW_TO_WINDOW_ARB = 0x2001;
public const int FULL_ACCELERATION_ARB = 0x2027;
public const int GENERIC_ACCELERATION_ARB = 0x2026;
public const int GREEN_BITS_ARB = 0x2017;
public const int GREEN_SHIFT_ARB = 0x2018;
public const int NEED_PALETTE_ARB = 0x2004;
public const int NEED_SYSTEM_PALETTE_ARB = 0x2005;
public const int NO_ACCELERATION_ARB = 0x2025;
public const int NUMBER_OVERLAYS_ARB = 0x2008;
public const int NUMBER_PIXEL_FORMATS_ARB = 0x2000;
public const int NUMBER_UNDERLAYS_ARB = 0x2009;
public const int PIXEL_TYPE_ARB = 0x2013;
public const int RED_BITS_ARB = 0x2015;
public const int RED_SHIFT_ARB = 0x2016;
public const int SHARE_ACCUM_ARB = 0x200E;
public const int SHARE_DEPTH_ARB = 0x200C;
public const int SHARE_STENCIL_ARB = 0x200D;
public const int STENCIL_BITS_ARB = 0x2023;
public const int STEREO_ARB = 0x2012;
public const int SUPPORT_GDI_ARB = 0x200F;
public const int SUPPORT_OPENGL_ARB = 0x2010;
public const int SWAP_COPY_ARB = 0x2029;
public const int SWAP_EXCHANGE_ARB = 0x2028;
public const int SWAP_LAYER_BUFFERS_ARB = 0x2006;
public const int SWAP_METHOD_ARB = 0x2007;
public const int SWAP_UNDEFINED_ARB = 0x202A;
public const int TRANSPARENT_ALPHA_VALUE_ARB = 0x203A;
public const int TRANSPARENT_ARB = 0x200A;
public const int TRANSPARENT_BLUE_VALUE_ARB = 0x2039;
public const int TRANSPARENT_GREEN_VALUE_ARB = 0x2038;
public const int TRANSPARENT_INDEX_VALUE_ARB = 0x203B;
public const int TRANSPARENT_RED_VALUE_ARB = 0x2037;
public const int TYPE_COLORINDEX_ARB = 0x202C;
public const int TYPE_RGBA_ARB = 0x202B;
#endregion
#region context
public const int CONTEXT_MAJOR_VERSION_ARB = 0x2091;
public const int CONTEXT_MINOR_VERSION_ARB = 0x2092;
public const int CONTEXT_LAYER_PLANE_ARB = 0x2093;
public const int CONTEXT_FLAGS_ARB = 0x2094;
public const int CONTEXT_PROFILE_MASK_ARB = 0x9126;
public const int CONTEXT_DEBUG_BIT_ARB = 0x0001;
public const int CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002;
public const int CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001;
public const int CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002;
public const int ERROR_INVALID_VERSION_ARB = 0x2095;
public const int ERROR_INVALID_PROFILE_ARB = 0x2096;
#endregion
#region
public const uint WS_OVERLAPPED = 0x00000000;
public const uint WS_POPUP = 0x80000000;
public const uint WS_CHILD = 0x40000000;
public const uint WS_MINIMIZE = 0x20000000;
public const uint WS_VISIBLE = 0x10000000;
public const uint WS_DISABLED = 0x08000000;
public const uint WS_CLIPSIBLINGS = 0x04000000;
public const uint WS_CLIPCHILDREN = 0x02000000;
public const uint WS_MAXIMIZE = 0x01000000;
public const uint WS_CAPTION = 0x00C00000; /* WS_BORDER | WS_DLGFRAME */
public const uint WS_BORDER = 0x00800000;
public const uint WS_DLGFRAME = 0x00400000;
public const uint WS_VSCROLL = 0x00200000;
public const uint WS_HSCROLL = 0x00100000;
public const uint WS_SYSMENU = 0x00080000;
public const uint WS_THICKFRAME = 0x00040000;
public const uint WS_GROUP = 0x00020000;
public const uint WS_TABSTOP = 0x00010000;
public const uint WS_MINIMIZEBOX = 0x00020000;
public const uint WS_MAXIMIZEBOX = 0x00010000;
public const uint WS_OVERLAPPEDWINDOW = WS_OVERLAPPED |
WS_CAPTION |
WS_SYSMENU |
WS_THICKFRAME |
WS_MINIMIZEBOX |
WS_MAXIMIZEBOX;
#endregion
}
public readonly partial struct WindowHandle
: IEquatable<WindowHandle>
{
internal readonly IntPtr Value;
internal WindowHandle(IntPtr value) => this.Value = value;
internal static WindowHandle Null => default;
internal bool IsNull => Value == default;
public static explicit operator WindowHandle(IntPtr value) => new WindowHandle(value);
public static implicit operator IntPtr(WindowHandle value) => value.Value;
public static bool operator !=(WindowHandle left, WindowHandle right) => !(left == right);
public static bool operator ==(WindowHandle left, WindowHandle right) => left.Value == right.Value;
public bool Equals(WindowHandle other) => this.Value == other.Value;
public override bool Equals(object obj) => obj is WindowHandle other && this.Equals(other);
public override int GetHashCode() => this.Value.GetHashCode();
public override string ToString() => $"0x{this.Value:x}";
//public static implicit operator HANDLE(WindowHandle value) => new HANDLE(value.Value);
}
[StructLayout(LayoutKind.Sequential)]
public class PixelFormatDescriptor
{
// 定义类的成员变量,使用与 C/C++ 中相同的数据类型
public ushort nSize;
public ushort nVersion;
public uint dwFlags;
[MarshalAs(UnmanagedType.U1)]
public byte iPixelType;
[MarshalAs(UnmanagedType.U1)]
public byte cColorBits;
[MarshalAs(UnmanagedType.U1)]
public byte cRedBits;
[MarshalAs(UnmanagedType.U1)]
public byte cRedShift;
[MarshalAs(UnmanagedType.U1)]
public byte cGreenBits;
[MarshalAs(UnmanagedType.U1)]
public byte cGreenShift;
[MarshalAs(UnmanagedType.U1)]
public byte cBlueBits;
[MarshalAs(UnmanagedType.U1)]
public byte cBlueShift;
[MarshalAs(UnmanagedType.U1)]
public byte cAlphaBits;
[MarshalAs(UnmanagedType.U1)]
public byte cAlphaShift;
[MarshalAs(UnmanagedType.U1)]
public byte cAccumBits;
[MarshalAs(UnmanagedType.U1)]
public byte cAccumRedBits;
[MarshalAs(UnmanagedType.U1)]
public byte cAccumGreenBits;
[MarshalAs(UnmanagedType.U1)]
public byte cAccumBlueBits;
[MarshalAs(UnmanagedType.U1)]
public byte cAccumAlphaBits;
[MarshalAs(UnmanagedType.U1)]
public byte cDepthBits;
[MarshalAs(UnmanagedType.U1)]
public byte cStencilBits;
[MarshalAs(UnmanagedType.U1)]
public byte cAuxBuffers;
[MarshalAs(UnmanagedType.U1)]
public byte iLayerType;
[MarshalAs(UnmanagedType.U1)]
public byte bReserved;
public uint dwLayerMask;
public uint dwVisibleMask;
public uint dwDamageMask;
// 定义一个构造函数,用于设置类的成员变量的默认值
public PixelFormatDescriptor()
{
nSize = (ushort)Marshal.SizeOf(this); // 设置 nSize 为类的大小
nVersion = 1; // 设置 nVersion 为 1
dwFlags = 0; // 设置 dwFlags 为 0
iPixelType = 0; // 设置 iPixelType 为 0
cColorBits = 0; // 设置 cColorBits 为 0
cRedBits = 0; // 设置 cRedBits 为 0
cRedShift = 0; // 设置 cRedShift 为 0
cGreenBits = 0; // 设置 cGreenBits 为 0
cGreenShift = 0; // 设置 cGreenShift 为 0
cBlueBits = 0; // 设置 cBlueBits 为 0
cBlueShift = 0; // 设置 cBlueShift 为 0
cAlphaBits = 0; // 设置 cAlphaBits 为 0
cAlphaShift = 0; // 设置 cAlphaShift 为 0
cAccumBits = 0; // 设置 cAccumBits 为 0
cAccumRedBits = 0; // 设置 cAccumRedBits 为 0
cAccumGreenBits = 0; // 设置 cAccumGreenBits 为 0
cAccumBlueBits = 0; // 设置 cAccumBlueBits 为 0
cAccumAlphaBits = 0; // 设置 cAccumAlphaBits 为 0
cDepthBits = 0; // 设置 cDepthBits 为 0
cStencilBits = 0; // 设置 cStencilBits 为 0
cAuxBuffers = 0; // 设置 cAuxBuffers 为 0
iLayerType = 0; // 设置 iLayerType 为 0
bReserved = 0; // 设置 bReserved 为 0
dwLayerMask = 0; // 设置 dwLayerMask 为 0
dwVisibleMask = 0; // 设置 dwVisibleMask 为 0
dwDamageMask = 0; // 设置 dwDamageMask 为 0
}
}
}
#endif