daily update on 20240209 by nitload youmu

This commit is contained in:
Nitload
2024-02-09 23:31:33 +08:00
parent 6fe6b3b3cf
commit 8391569482
159 changed files with 948 additions and 2431 deletions
-23
View File
@@ -1,23 +0,0 @@
using StgSharp.Controlling;
using StgSharp.Graphics;
using StgSharp.Math;
using System;
using System.Security.Cryptography;
namespace StgSharp
{
public static partial class Operation
{
internal static void RegistForm(Form form)
{
}
public static void LoadTimeline()
{
}
}
}
-13
View File
@@ -1,13 +0,0 @@
namespace StgSharp
{
public static partial class Operation
{
//method used for chaging the value of paameters will be listed here
internal static void RenderNextFrame()
{
}
}
}
-21
View File
@@ -1,21 +0,0 @@
using StgSharp.Geometries;
using StgSharp.Math;
namespace StgSharp
{
public static unsafe partial class Geometry
{
public static unsafe Triangle InitTriagnle<T>(
vec3d vertex1,
vec3d vertex2,
vec3d vertex3
) where T : Triangle
{
Triangle t = new Triangle();
return t;
}
}
}
+1 -3
View File
@@ -7,8 +7,6 @@ namespace StgSharp
{
public static unsafe partial class Operation
{
/// <summary>
/// Get the status of a certain key on the keyboard.
/// </summary>
@@ -17,7 +15,7 @@ namespace StgSharp
/// <returns></returns>
public static KeyStatus GetKeyStatus(Form form, Key key)
{
return InternalIO.glfw.GetKey(form.windowID, (int)key);
return InternalIO.glfwGetKey(form.windowID, (int)key);
}
}
+4 -8
View File
@@ -37,8 +37,6 @@ namespace StgSharp
internal static extern unsafe void InternalLoadImage(string fileName, Image.ImageInfo* output, ImageLoader loader);
#endregion
internal static IglFramework glfw = null;
}
}
@@ -48,8 +46,6 @@ namespace StgSharp.Graphics
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public delegate IntPtr ImageLoader(string name, ref int width, ref int height, ref int definedChannel, int desiredChannel);
[StructLayout(LayoutKind.Sequential)]
public struct GLcontext
{
@@ -192,8 +188,8 @@ namespace StgSharp.Graphics
internal unsafe delegate*<uint, uint, int, int, int, int, int, int, int, int, uint, uint, void> glBlitNamedFramebuffer;
internal unsafe delegate*<uint, uint, ulong, UIntPtr, void> glBufferAddressRangeNV;
internal unsafe delegate*<uint, uint, ulong, void> glBufferAttachMemoryNV;
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glBufferData;
internal unsafe delegate*<uint, UIntPtr, void*, uint, void> glBufferDataARB;
internal unsafe delegate*<uint, IntPtr, void*, uint, void> glBufferData;
internal unsafe delegate*<uint, IntPtr, void*, uint, void> glBufferDataARB;
internal unsafe delegate*<uint, IntPtr, UIntPtr, bool, void> glBufferPageCommitmentARB;
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, ulong, bool, void> glBufferPageCommitmentMemNV;
internal unsafe delegate*<uint, uint, int, void> glBufferParameteriAPPLE;
@@ -2459,8 +2455,8 @@ namespace StgSharp.Graphics
internal unsafe delegate*<uint, uint, bool, uint, void> glVertexAttribP4ui;
internal unsafe delegate*<uint, uint, bool, uint*, void> glVertexAttribP4uiv;
internal unsafe delegate*<uint, uint, int, void> glVertexAttribParameteriAMD;
internal unsafe delegate*<uint, int, uint, bool, uint, void*, void> glVertexAttribPointer;
internal unsafe delegate*<uint, int, uint, bool, uint, void*, void> glVertexAttribPointerARB;
internal unsafe delegate*<uint, int, uint, int, uint, void*, void> glVertexAttribPointer;
internal unsafe delegate*<uint, int, uint, int, uint, void*, void> glVertexAttribPointerARB;
internal unsafe delegate*<uint, int, uint, uint, void*, void> glVertexAttribPointerNV;
internal unsafe delegate*<uint, uint, double*, void> glVertexAttribs1dvNV;
internal unsafe delegate*<uint, uint, float*, void> glVertexAttribs1fvNV;
+11 -9
View File
@@ -20,6 +20,9 @@ namespace StgSharp
internal static unsafe partial class InternalIO
{
internal static Dictionary<TypeCode, uint> GLtype =
new Dictionary<TypeCode, uint>();
internal static IntPtr SSClibPtr = IntPtr.Zero;
internal const string SS_errorlog =
@@ -30,14 +33,13 @@ namespace StgSharp
static InternalIO()
{
GLtype.Add(typeof(float), GLconst.FLOAT);
GLtype.Add(typeof(int), GLconst.INT);
GLtype.Add(typeof(uint), GLconst.UNSIGNED_INT);
GLtype.Add(typeof(short), GLconst.SHORT);
GLtype.Add(typeof(ushort), GLconst.UNSIGNED_SHORT);
GLtype.Add(typeof(sbyte), GLconst.BYTE);
GLtype.Add(typeof(byte), GLconst.UNSIGNED_BYTE);
GLtype.Add(TypeCode.Single, GLconst.FLOAT);
GLtype.Add(TypeCode.Int32, GLconst.INT);
GLtype.Add(TypeCode.UInt32, GLconst.UNSIGNED_INT);
GLtype.Add(TypeCode.Int16, GLconst.SHORT);
GLtype.Add(TypeCode.UInt16, GLconst.UNSIGNED_SHORT);
GLtype.Add(TypeCode.SByte, GLconst.BYTE);
GLtype.Add(TypeCode.Byte, GLconst.UNSIGNED_BYTE);
}
internal static T InternalLoadProc<T>(IntPtr libPtr, string name) where T : Delegate
@@ -48,7 +50,7 @@ namespace StgSharp
T ret = Marshal.GetDelegateForFunctionPointer<T>(procPtr);
return ret;
}
catch (Exception ex)
catch (Exception)
{
throw;
}
-15
View File
@@ -1,15 +0,0 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Controlling
{
public static partial class Control
{
public static unsafe void RecycleMappedVec(Vec4d vec)
{
}
}
}
-15
View File
@@ -1,15 +0,0 @@
using StgSharp.Geometries;
namespace StgSharp.Controlling
{
public static class Remove
{
public static void Point(Point p)
{
}
}
}
@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Controlling
{
internal static partial class TimeLine
{
}
}
@@ -0,0 +1,90 @@
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp
{
internal enum GraphicAPI : byte
{
GL,
DX,
VK
}
public static class Platform
{
internal static GraphicAPI API;
/// <summary>
/// Version of current StgSharp platform.
/// Main version represent in hundred's digit,
/// and sub version represent in ten's digit.
/// </summary>
public const long version = 430;
/// <summary>
/// Init an instance of OpenGL program,
/// This method should be called before other
/// graphic methods, after LoadGL method.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InitGL(int majorVersion, int minorVersion)
{
InternalIO.InternalInitGL(majorVersion, minorVersion);
}
/// <summary>
/// Write a log message to log file, and mark the level of this message.
/// </summary>
/// <param name="message">A string contains information of how current evironment runs.</param>
/// <param name="logType">The severity of current message.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteLog(string message, LogType logType)
{
InternalIO.InternalWriteLog(message, logType);
}
internal static TDele ConvertAPI<TDele>(IntPtr funcPtr)
{
if (funcPtr == IntPtr.Zero)
{
throw new Exception("Failed to convert api, the function pointer is zero.");
}
try
{
return Marshal.GetDelegateForFunctionPointer<TDele>(funcPtr);
}
catch (Exception)
{
throw;
}
}
internal static Delegate ConvertAPI(IntPtr funcPtr, Type T)
{
if (funcPtr == IntPtr.Zero)
{
throw new Exception("Failed to convert api, the function pointer is zero.");
}
try
{
return Marshal.GetDelegateForFunctionPointer(funcPtr, T);
}
catch (Exception)
{
throw;
}
}
}
}
+2 -2
View File
@@ -45,7 +45,7 @@
Vertex = 0x8B31,
}
public enum BufferType : int
public enum BufferType : uint
{
ARRAY_BUFFER = 0x8892,
ELEMENT_ARRAY_BUFFER = 0x8893,
@@ -83,7 +83,7 @@
STENCIL = GLconst.STENCIL_BUFFER_BIT,
}
public enum GepmetryType : int
public enum GepmetryType : uint
{
POINTS = 0x0000,
LINES = 0x0001,
@@ -5,15 +5,6 @@ using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
{
internal static unsafe partial class InternalIO
{
internal static Dictionary<Type, uint> GLtype =
new Dictionary<Type, uint>();
}
}
namespace StgSharp.Graphics
{
+175 -136
View File
@@ -1,4 +1,5 @@
using StgSharp.Controlling;
using StgSharp;
using StgSharp.Controlling;
using StgSharp.Logic;
using StgSharp.Math;
using System;
@@ -10,8 +11,10 @@ using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Threading;
@@ -34,8 +37,8 @@ namespace StgSharp.Graphics
internal Form sharedForm;
internal int width;
internal IntPtr windowID;
private IglFunc gl;
private bool closed;
private IglFunc gl;
#endregion
#region form thread setting
@@ -55,12 +58,13 @@ namespace StgSharp.Graphics
{
}
protected FrameBufferSizeHandler FrameBufferSizeCallback
/// <summary>
/// OpenGL package used by current form context.
/// </summary>
public IglFunc GL
{
set
{
gl.SetFrameBufferSizeCallback(this.windowID, value);
}
get => gl;
internal set => gl = value;
}
/// <summary>
@@ -72,20 +76,6 @@ namespace StgSharp.Graphics
set => height = value;
}
/// <summary>
/// OpenGL package used by current form context.
/// </summary>
public IglFunc GL
{
get => gl;
internal set => gl = value;
}
internal Thread RenderThread
{
get { return renderThread; }
}
/// <summary>
/// Representing
/// </summary>
@@ -94,6 +84,14 @@ namespace StgSharp.Graphics
get { return isSingleThread; }
}
public bool ShouldClose
{
set
{
InternalIO.glfwSetWindowShouldClose(windowID, value ? 1 : 0);
}
}
/// <summary>
/// Width of this form, represent in <see cref="int"/>
/// </summary>
@@ -132,11 +130,158 @@ namespace StgSharp.Graphics
get { return _renderStartSignal; }
set { _renderStartSignal = value; }
}
internal Thread RenderThread
{
get { return renderThread; }
}
protected FrameBufferSizeHandler FrameBufferSizeCallback
{
set
{
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
InternalIO.glfwSetFramebufferSizeCallback(windowID, handlerPtr);
}
}
unsafe ~Form()
{
Marshal.FreeHGlobal((IntPtr)contextID);
}
/// <summary>
/// Init an OpenGl context if current form has not been binded to any context.
/// and set the context binded to current form as current OpenGL context.
/// </summary>
/// <exception cref="Exception">Something goes wrong and
/// StgSharp fails in creating a new OpenGL context. </exception>
public unsafe void MakeAsCurrentContext()
{
if (windowID == default)
{
IntPtr windowPtr;
byte[] tittleBytes = Encoding.UTF8.GetBytes(name);
if (sharedForm == null)
{
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, IntPtr.Zero);
}
else
{
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, sharedForm.windowID);
}
if ((long)windowPtr == -1 || (long)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
else
{
windowID = windowPtr;
}
}
InternalIO.InternalSetCurrentGLContext(windowID, contextID);
}
/// <summary>
/// Set all necessary metadata to current form instance
/// </summary>
public void SetMetadata(int width, int height, string name, IntPtr monitor, Form sharedForm)
{
this.width = width;
this.height = height;
this.name = name;
this.sharedForm = sharedForm;
this.monitor = monitor;
}
/// <summary>
/// Resize the current form
/// </summary>
/// <param name="width">New width of the window</param>
/// <param name="height">New height of the window</param>
public void SetSize(int width, int height)
{
this.Width = width;
this.Height = height;
InternalIO.glfwSetWindowSize(this.windowID, width, height);
}
/// <summary>
/// Resize the current form
/// </summary>
/// <param name="size">
/// A <see cref="Vec2d"/> (width,height) representing the new size of current form
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSize(Vec2d size)
{
this.Size = size;
InternalIO.glfwSetWindowSize(this.windowID, (int)size.X, (int)size.Y);
}
/// <summary>
/// Set the size limit of current form
/// </summary>
/// <param name="minWidth">Minimum width of current form </param>
/// <param name="minHeight">Minimum height of current form</param>
/// <param name="maxWidth">Maximum width of curent form</param>
/// <param name="maxHeight">Maximum height of current form</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
{
InternalIO.glfwSetWindowSizeLimits(
this.windowID,
minWidth, minHeight, maxWidth, maxHeight);
}
/// <summary>
/// Set the size limit of current form
/// </summary>
/// <param name="minSize">
/// Minimun size of current form. In form of a <see cref="Vec2d"/> of (width,height)
/// </param>
/// <param name="maxSize">
/// Maximum size of current form. In form of a <see cref="Vec2d"/> of (width,height)
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSizeLimit(Vec2d minSize, Vec2d maxSize)
{
InternalIO.glfwSetWindowSizeLimits(
this.windowID,
(int)minSize.X, (int)minSize.Y, (int)maxSize.X, (int)maxSize.Y);
}
public unsafe void SwapAndPollEvent()
{
if (windowID == IntPtr.Zero)
{
return;
}
if (isSingleThread)
{
InternalIO.glfwSwapBuffers(windowID);
InternalIO.glfwPollEvents();
}
else
{
M128 m = default;
m.IntPtr0 = windowID;
GLonUpdate glu = gl as GLonUpdate;
glu.frameworkHandleEnqueue(
(IntPtr)(delegate*<void>)&InternalSwapBuffer, m);
}
}
internal static void InternalSwapBuffer()
{
IntPtr handle = default;
GLonUpdate.ParamQueue.TryDequeue(out handle);
InternalIO.glfwSwapBuffers(handle);
InternalIO.glfwPollEvents();
}
#region form main
public abstract void Deinit(params object[] args);
@@ -181,21 +326,6 @@ namespace StgSharp.Graphics
}
}
private unsafe void InternalRender()
{
#pragma warning disable CS8602
ConcurrentQueue<IntPtr> glActions = (gl as GLonUpdate).GLactionQueue;
#pragma warning restore CS8602
IntPtr currentOperation;
while (gl.GetWindowShouldClose(this))
{
if (glActions.TryDequeue(out currentOperation))
{
((delegate*<void>)currentOperation)();
}
}
}
internal void InternalDeinit(params object[] args)
{
Deinit(args);
@@ -264,112 +394,21 @@ namespace StgSharp.Graphics
renderThread = new Thread(new ThreadStart(InternalRender));
}
}
#endregion
/// <summary>
/// Set all necessary metadata to current form instance
/// </summary>
public void SetMetadata(int width, int height, string name, IntPtr monitor, Form sharedForm)
private unsafe void InternalRender()
{
this.width = width;
this.height = height;
this.name = name;
this.sharedForm = sharedForm;
this.monitor = monitor;
}
/// <summary>
/// Init an OpenGl context if current form has not been binded to any context.
/// and set the context binded to current form as current OpenGL context.
/// </summary>
/// <exception cref="Exception">Something goes wrong and
/// StgSharp fails in creating a new OpenGL context. </exception>
public unsafe void MakeAsCurrentContext()
{
if (windowID == default)
#pragma warning disable CS8602
ConcurrentQueue<IntPtr> glActions = (gl as GLonUpdate).GLactionQueue;
#pragma warning restore CS8602
IntPtr currentOperation;
while (gl.GetWindowShouldClose(this))
{
IntPtr windowPtr;
byte[] tittleBytes = Encoding.UTF8.GetBytes(name);
if (sharedForm == null)
if (glActions.TryDequeue(out currentOperation))
{
windowPtr = InternalIO.glfw.CreateWindow(
width, height, tittleBytes, monitor, IntPtr.Zero);
}
else
{
windowPtr = InternalIO.glfw.CreateWindow(
width, height, tittleBytes, monitor, sharedForm.windowID);
}
if ((long)windowPtr == -1 || (long)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
else
{
windowID = windowPtr;
((delegate*<void>)currentOperation)();
}
}
InternalIO.InternalSetCurrentGLContext(windowID, contextID);
}
/// <summary>
/// Resize the current form
/// </summary>
/// <param name="width">New width of the window</param>
/// <param name="height">New height of the window</param>
public void SetSize(int width, int height)
{
this.Width = width;
this.Height = height;
InternalIO.glfw.SetWindowSize(this.windowID, width, height);
}
/// <summary>
/// Resize the current form
/// </summary>
/// <param name="size">
/// A <see cref="Vec2d"/> (width,height) representing the new size of current form
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSize(Vec2d size)
{
this.Size = size;
InternalIO.glfw.SetWindowSize(this.windowID, (int)size.X, (int)size.Y);
}
/// <summary>
/// Set the size limit of current form
/// </summary>
/// <param name="minWidth">Minimum width of current form </param>
/// <param name="minHeight">Minimum height of current form</param>
/// <param name="maxWidth">Maximum width of curent form</param>
/// <param name="maxHeight">Maximum height of current form</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
{
InternalIO.glfw.SetWindowSizeLimits(
this.windowID,
minWidth, minHeight, maxWidth, maxHeight);
}
/// <summary>
/// Set the size limit of current form
/// </summary>
/// <param name="minSize">
/// Minimun size of current form. In form of a <see cref="Vec2d"/> of (width,height)
/// </param>
/// <param name="maxSize">
/// Maximum size of current form. In form of a <see cref="Vec2d"/> of (width,height)
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSizeLimit(Vec2d minSize, Vec2d maxSize)
{
InternalIO.glfw.SetWindowSizeLimits(
this.windowID,
(int)minSize.X, (int)minSize.Y, (int)maxSize.X, (int)maxSize.Y);
}
#endregion
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ namespace StgSharp.Graphics
public double timeAfterFrame
{
get { return InternalIO.glfw.GetTime() - frameBegin; }
get { return InternalIO.glfwGetTime() - frameBegin; }
}
public uint totalFrame
+4 -5
View File
@@ -11,19 +11,18 @@ namespace StgSharp.Graphics
/// <summary>
/// A collecion of handle to Element Buffer Object in OpenGL.
/// Each <see cref="uint"/> value indexed from instance of this class this
/// Each <see langword="int"/> value indexed from instance of this class this
/// is the only handle to one Element Buffer Object.
/// </summary>
public unsafe class ElementBuffer : IBufferObject
{
internal ElementBuffer(uint n, IglFunc gl)
internal ElementBuffer(int n, IglFunc gl)
{
_bufferHandle = new glHandle((int)n);
GL = gl;
GL.GenBuffers(n, _bufferHandle);
_bufferHandle = GL.GenBuffers(n);
}
public uint this[int n]
public glHandle this[int n]
{
get { return _bufferHandle[n]; }
}
@@ -11,7 +11,7 @@ namespace StgSharp.Graphics
/// </summary>
public abstract class IBufferObject : IDisposable
{
protected glHandle _bufferHandle;
protected glHandleSet _bufferHandle;
protected IglFunc GL;
/// <summary>
@@ -19,7 +19,7 @@ namespace StgSharp.Graphics
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public uint this[int index]
public glHandle this[int index]
{
get { return _bufferHandle[index]; }
}
+4 -5
View File
@@ -8,11 +8,10 @@ namespace StgSharp.Graphics
public unsafe class VertexArray : IBufferObject
{
internal VertexArray(uint n, IglFunc gl)
internal VertexArray(int n, IglFunc gl)
{
_bufferHandle = new glHandle((int)n);
GL = gl;
GL.GenVertexArrays(n, _bufferHandle);
_bufferHandle = GL.GenVertexArrays(n);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -24,11 +23,11 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void BindNull()
{
GL.BindVertexArray(0);
GL.BindVertexArray(glHandle.Alloc(0));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute(uint index, int vertexLength, Type dataType, bool isNomalized, uint stride, int pointer)
public void SetVertexAttribute(uint index, int vertexLength, TypeCode dataType, bool isNomalized, uint stride, int pointer)
{
GL.SetVertexAttribute(
index, vertexLength, dataType,
+4 -5
View File
@@ -12,16 +12,15 @@ namespace StgSharp.Graphics
public unsafe class VertexBuffer : IBufferObject
{
internal VertexBuffer(uint n, IglFunc glFunc)
internal VertexBuffer(int n, IglFunc glFunc)
{
_bufferHandle = new glHandle((int)n);
GL = glFunc;
GL.GenBuffers(n, _bufferHandle);
_bufferHandle = GL.GenBuffers(n);
}
public sealed override void Bind(int index)
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, (uint)index);
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
}
/// <summary>
@@ -57,7 +56,7 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unbind()
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, 0);
GL.BindBuffer(BufferType.ARRAY_BUFFER, glHandle.Zero);
}
internal void ChangeEnvironment(IglFunc gl)
{
@@ -17,12 +17,11 @@ namespace StgSharp.Graphics
internal Image[] sourceList;
private IglFunc GL;
internal Texture(uint n, IglFunc gl)
internal Texture(int n, IglFunc gl)
{
_textureHandle = new glHandleSet((int)n);
sourceList = new Image[n];
GL = gl;
GL.GenTextures(n, _textureHandle);
_textureHandle = GL.GenTextures(n);
}
public void Activate(TextureUnit unit)
@@ -65,10 +64,10 @@ namespace StgSharp.Graphics
channel = 0;
break;
}
GL.TextureImage2d(
GL.TextureImage2d<byte>(
GLconst.TEXTURE_2D, 0, channel,
(uint)sourceList[index].Width, (uint)sourceList[index].Height,
channel, GLconst.UNSIGNED_BYTE, (byte*)sourceList[index].info.pixelPtr
channel, GLconst.UNSIGNED_BYTE, sourceList[index].pixelArray
);
}
else
+72 -1
View File
@@ -13,6 +13,37 @@ using System.Threading.Tasks;
namespace System
{
public unsafe struct glSHandle
{
internal int* valuePtr;
internal glHandleSet source;
public static glSHandle Zero
{
get { return Alloc(1); }
}
public static glSHandle Alloc(int value)
{
glSHandle ret = default;
ret.source = new glHandleSet(1);
ret.valuePtr = (int*)ret.source.handle;
*ret.valuePtr = (int)value;
return ret;
}
internal int DirectValue
{
get { return *valuePtr; }
}
internal glSHandle(int* val, glHandleSet set)
{
source = set;
valuePtr = val;
}
}
/// <summary>
/// A handle to an OpenGL object,
/// must be indexed from a <see cref="glHandleSet"/>.
@@ -23,6 +54,11 @@ namespace System
internal uint* valuePtr;
internal glHandleSet source;
public static glHandle Zero
{
get { return Alloc(0); }
}
public glHandle()
{
throw new InvalidOperationException();
@@ -32,6 +68,7 @@ namespace System
{
glHandle ret = default;
ret.source = new glHandleSet(1);
ret.valuePtr = ret.source.handle;
*ret.valuePtr = value;
return ret;
}
@@ -54,6 +91,14 @@ namespace System
}
}
internal uint DirectValue
{
get
{
return *valuePtr;
}
}
public uint Value
{
get
@@ -73,7 +118,6 @@ namespace System
*valuePtr = value;
}
}
}
/// <summary>
@@ -85,6 +129,22 @@ namespace System
internal int length;
internal uint* handle;
public static void Copy(in glHandleSet source, glHandleSet target)
{
if (source == null || target == null)
{
throw new NullReferenceException();
}
if (source.length != target.length)
{
throw new Exception($"Lengths of {nameof(source)} and {nameof(target)} are not equal.");
}
for (int i = 0; i < source.length; i++)
{
target._value[i] = source._value[i];
}
}
public glHandle this[int index]
{
get
@@ -97,6 +157,17 @@ namespace System
}
}
public glSHandle this[uint index]
{
get
{
if (index > length)
{
throw new IndexOutOfRangeException();
}
return new glSHandle((int*)handle + index, this);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetValue(int index, uint value)
+40 -78
View File
@@ -3,7 +3,6 @@ using StgSharp.Math;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
@@ -62,9 +61,9 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.BindTexture(uint type, uint texture)
void IglFunc.BindTexture(uint type, glHandle texture)
{
api->glBindTexture(type, texture);
api->glBindTexture(type, texture.DirectValue);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -169,12 +168,12 @@ namespace StgSharp.Graphics
IntPtr windowPtr;
if (share == null)
{
windowPtr = InternalIO.glfw.CreateWindow(
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, IntPtr.Zero);
}
else
{
windowPtr = InternalIO.glfw.CreateWindow(
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, share.windowID);
}
@@ -195,9 +194,9 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.DeleteBuffer(uint handle)
unsafe void IglFunc.DeleteBuffer(glHandle handle)
{
api->glDeleteBuffers(1, &handle);
api->glDeleteBuffers(1, (uint*)handle.Handle);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.DeleteBuffers(glHandleSet handle)
@@ -214,10 +213,10 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.DrawElements(GepmetryType mode, uint count, Type type, IntPtr ptr)
unsafe void IglFunc.DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr)
{
uint a;
switch (Type.GetTypeCode(type))
switch (type)
{
case TypeCode.UInt32:
a = GLconst.UNSIGNED_INT;
@@ -239,68 +238,53 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GenBuffers(uint count, glHandleSet handle)
unsafe glHandleSet IglFunc.GenBuffers(int count)
{
api->glGenBuffers(count, (uint*)handle.handle);
glHandleSet h = new glHandleSet((int)count);
api->glGenBuffers((uint)count, h.handle);
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GenTextures(uint count, glHandleSet handle)
unsafe glHandleSet IglFunc.GenTextures(int count)
{
api->glGenTextures(count, (uint*)handle.handle);
glHandleSet h = new glHandleSet((int)count);
api->glGenTextures((uint)count, h.handle);
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GenVertexArrays(uint count, glHandleSet handle)
unsafe glHandleSet IglFunc.GenVertexArrays(int count)
{
api->glGenVertexArrays(count, (uint*)handle.handle);
glHandleSet h = new glHandleSet(count);
api->glGenVertexArrays((uint)count, h.handle);
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GetGraphicError()
unsafe glSHandle IglFunc.GetUniformLocation(glHandle program, string name)
{
string error = null;
uint code = api->glGetError();
while (code != 0)
byte[] code = Encoding.UTF8.GetBytes(name);
fixed (byte* ptr = code)
{
error += $"OpenGL error {code}\n";
return glSHandle.Alloc(api->glGetUniformLocation(program.DirectValue, ptr));
}
try
{
if (error != null)
{
throw new Exception();
}
}
catch (Exception ex)
{
/**/
InternalIO.InternalWriteLog(
error + ex.StackTrace,
LogType.Error
);
/**/
}
return;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe int IglFunc.GetUniformLocation(uint program, byte* ptr)
{
return api->glGetUniformLocation(program, ptr);
}
unsafe bool IglFunc.GetWindowShouldClose(Form form)
{
return InternalIO.glfw.WindowShouldClose(form.windowID) == 0;
return InternalIO.glfwWindowShouldClose(form.windowID) == 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.MakeContexCurrent(Form form)
{
if (form.windowID == IntPtr.Zero)
{
InternalIO.InternalWriteLog($"From {nameof(form)} is not initted.", LogType.Warning);
return;
}
InternalIO.glfw.MakeContextCurrent(form.windowID);
InternalIO.glfwMakeContextCurrent(form.windowID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -309,7 +293,7 @@ namespace StgSharp.Graphics
int size = sizeof(T);
api->glBufferData(
(uint)bufferType,
(UIntPtr)size,
(IntPtr)size,
&bufferData,
(uint)usage);
}
@@ -325,62 +309,40 @@ namespace StgSharp.Graphics
fixed (void* bufferPtr = bufferArray)
api->glBufferData(
(uint)bufferType,
(UIntPtr)size,
(IntPtr)size,
bufferPtr,
(uint)usage);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
{
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(handler);
InternalIO.glfw.SetFramebufferSizeCallback(id, handlerPtr);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.SetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer)
void IglFunc.SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer)
{
uint type = InternalIO.GLtype[t];
api->glVertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
api->glVertexAttribPointer(index, size, type, normalized ? 1 : 0, stride, (void*)pointer);
api->glEnableVertexAttribArray(index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.SetWindowShouldClose(Form form, bool mark)
{
InternalIO.glfw.SetWindowShouldClose(form.windowID, mark ? 1 : 0);
}
unsafe void IglFunc.SwapBuffers(Form form)
{
if (form.windowID == IntPtr.Zero)
{
return;
}
InternalIO.glfw.SwapBuffers(form.windowID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.TextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels)
void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels)
{
IntPtr source = GCHandle.Alloc(pixels, GCHandleType.Pinned).AddrOfPinnedObject();
api->glTexImage2D(
target, level, internalformat, width, height, 0, format, type, pixels
(uint)target, level, internalformat, width, height, 0, format, type, (void*)source
);
GCHandle.FromIntPtr(source).Free();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.TextureParameter(uint target, uint pname, int param)
void IglFunc.TextureParameter(int target, uint pname, int param)
{
api->glTexParameteri(target, pname, param);
api->glTexParameteri((uint)target, pname, param);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.UseProgram(uint program)
void IglFunc.UseProgram(glHandle program)
{
api->glUseProgram(program);
api->glUseProgram(program.DirectValue);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+10 -19
View File
@@ -29,7 +29,7 @@ namespace StgSharp.Graphics
void IglFunc.BindBuffer(BufferType bufferType, glHandle handle) => throw signal;
void IglFunc.BindTexture(uint type, uint texture) => throw signal;
void IglFunc.BindTexture(uint type, glHandle texture) => throw signal;
void IglFunc.BindVertexArray(glHandle handle) => throw signal;
@@ -59,20 +59,17 @@ namespace StgSharp.Graphics
void IglFunc.DeleteVertexArrays(glHandleSet handle) => throw signal;
void IglFunc.DrawElements(GepmetryType mode, uint count, Type type, IntPtr ptr) => throw signal;
void IglFunc.DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr) => throw signal;
void IglFunc.GenBuffers(uint count, glHandleSet handle) => throw signal;
glHandleSet IglFunc.GenBuffers(int count) => throw signal;
void IglFunc.GenTextures(uint count, glHandleSet handle) => throw signal;
glHandleSet IglFunc.GenTextures(int count) => throw signal;
void IglFunc.GenVertexArrays(uint count, glHandleSet handle) => throw signal;
glHandleSet IglFunc.GenVertexArrays(int count) => throw signal;
void IglFunc.GetGraphicError() => throw signal;
unsafe int IglFunc.GetUniformLocation(uint program, byte* ptr) => throw signal;
unsafe glSHandle IglFunc.GetUniformLocation(glHandle program, string name) => throw signal;
bool IglFunc.GetWindowShouldClose(Form form) => throw signal;
@@ -82,8 +79,6 @@ namespace StgSharp.Graphics
void IglFunc.SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage) => throw signal;
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler) => throw signal;
void IglFunc.SetValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3) => throw signal;
void IglFunc.SetValue(Uniform<float, float, float, float> uniform, Vec4d vec) => throw signal;
@@ -98,17 +93,13 @@ namespace StgSharp.Graphics
void IglFunc.SetValue(Uniform<Vec4d> uniform, Vec4d vec) => throw signal;
void IglFunc.SetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer) => throw signal;
void IglFunc.SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer) => throw signal;
void IglFunc.SetWindowShouldClose(Form form, bool mark) => throw signal;
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels) => throw signal;
void IglFunc.SwapBuffers(Form form) => throw signal;
void IglFunc.TextureParameter(int target, uint pname, int param) => throw signal;
unsafe void IglFunc.TextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels) => throw signal;
void IglFunc.TextureParameter(uint target, uint pname, int param) => throw signal;
void IglFunc.UseProgram(uint program) => throw signal;
void IglFunc.UseProgram(glHandle program) => throw signal;
void IglFunc.Viewport(int x, int y, uint width, uint height) => throw signal;
+100 -162
View File
@@ -16,10 +16,12 @@ namespace StgSharp.Graphics
internal unsafe partial class GLonUpdate : IglFunc
{
private ConcurrentQueue<IntPtr> glActionQueue;
private static ConcurrentQueue<IntPtr> glActionQueue;
private static GLparamQueue paramQueue;
private FrameTimeoutException refreshSignal = new();
private IntPtr SwapBufferPtr = (IntPtr)(delegate*<IntPtr, void>)&InternalIO.glfwSwapBuffers;
internal GLonUpdate(GLcontext* context)
{
if (paramQueue == null)
@@ -29,6 +31,11 @@ namespace StgSharp.Graphics
glActionQueue = new ConcurrentQueue<IntPtr>();
}
internal static GLparamQueue ParamQueue
{
get { return paramQueue; }
}
internal ConcurrentQueue<IntPtr> GLactionQueue
{
get
@@ -36,13 +43,13 @@ namespace StgSharp.Graphics
return glActionQueue;
}
}
void IglFunc.ActiveTexture(uint type)
{
paramQueue.Enqueue(type);
glActionQueue.Enqueue(ActiveTexturePtr);
}
void IglFunc.AfterAlign(Form form, Action action)
{
throw new NotImplementedException();
@@ -77,9 +84,11 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.BindTexture(uint type, uint texture)
void IglFunc.BindTexture(uint type, glHandle texture)
{
paramQueue.Enqueue(type, texture);
M128 m = new M128 { IntPtr1 = (IntPtr)texture.valuePtr };
m.UInt32[0] = (uint)type;
paramQueue.Enqueue(m);
glActionQueue.Enqueue(BindTexturePtr);
}
@@ -109,12 +118,6 @@ namespace StgSharp.Graphics
glActionQueue.Enqueue(ClearGraphicErrorPtr);
}
//TODO:双线程,换运行环境
void IglFunc.SwitchContext()
{
}
glHandleSet IglFunc.CompileShader(ShaderType shaderType, params string[] shaderCode)
{
int l = shaderCode.Length;
@@ -133,7 +136,6 @@ namespace StgSharp.Graphics
return shaderHandle;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
glHandle IglFunc.CreateProgram()
{
@@ -161,12 +163,12 @@ namespace StgSharp.Graphics
IntPtr windowPtr;
if (share == null)
{
windowPtr = InternalIO.glfw.CreateWindow(
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, IntPtr.Zero);
}
else
{
windowPtr = InternalIO.glfw.CreateWindow(
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, share.windowID);
}
@@ -180,7 +182,6 @@ namespace StgSharp.Graphics
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
glHandle IglFunc.CreatGraphicProgram()
{
@@ -208,25 +209,18 @@ namespace StgSharp.Graphics
glActionQueue.Enqueue(DeleBufferPtr);
}
//TODO: 从这里开始
unsafe void IglFunc.DeleteVertexArrays(glHandleSet arrays)
{
glActionQueue.Enqueue(
() =>
{
uint[] target = arrays;
fixed (uint* ptr = target)
{
api->glDeleteVertexArrays(count, ptr);
}
}
);
M128 m = new() { IntPtr1 = (IntPtr)arrays.handle };
m.Int32[0] = arrays.length;
paramQueue.Enqueue(m);
glActionQueue.Enqueue(DeleteVertexArrayPtr);
}
void IglFunc.DrawElements(GepmetryType mode, uint count, Type type, IntPtr ptr)
void IglFunc.DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr)
{
uint a;
switch (Type.GetTypeCode(type))
switch (type)
{
case TypeCode.UInt32:
a = GLconst.UNSIGNED_INT;
@@ -239,73 +233,60 @@ namespace StgSharp.Graphics
break;
default:
InternalIO.InternalWriteLog(
$"Parameter error in parameter {nameof(type)} method DrawElements. " +
$"Only {typeof(uint).Name},{typeof(ushort).Name},{typeof(byte).Name} types are suporrted.",
$"Parameter error in parameter {type} method DrawElements. " +
$"Only {TypeCode.Byte}, {TypeCode.UInt16}, {TypeCode.UInt32} types are suporrted.",
LogType.Error);
return;
}
glActionQueue.Enqueue(
() =>
{ api->glDrawElements((uint)mode, count, a, (void*)ptr); }
);
paramQueue.Enqueue((uint)mode, count, a);
paramQueue.Enqueue(ptr);
glActionQueue.Enqueue(DrawElementsPtr);
}
unsafe void IglFunc.GenBuffers(uint count, glHandleSet handle)
unsafe glHandleSet IglFunc.GenBuffers(int count)
{
glActionQueue.Enqueue(
() =>
{
}
);
glHandleSet h = new glHandleSet(count);
M128 m = default; m.UInt32[2] = (uint)count; m.IntPtr0 = (IntPtr)h.handle;
paramQueue.Enqueue(m);
glActionQueue.Enqueue(GenBufferPtr);
return h;
}
unsafe void IglFunc.GenTextures(uint count, glHandleSet handle)
unsafe glHandleSet IglFunc.GenTextures(int count)
{
glActionQueue.Enqueue(
() =>
{
}
);
glHandleSet h = new glHandleSet(count);
M128 m = default; m.UInt32[2] = (uint)count; m.IntPtr0 = (IntPtr)h.handle;
paramQueue.Enqueue(m);
glActionQueue.Enqueue(GenTexturesPtr);
return h;
}
unsafe void IglFunc.GenVertexArrays(uint count, glHandleSet ptr)
unsafe glHandleSet IglFunc.GenVertexArrays(int count)
{
glActionQueue.Enqueue(
() =>
{
api->glGenVertexArrays(count, ptr);
}
);
glHandleSet h = new glHandleSet(count);
M128 m = default; m.UInt32[2] = (uint)count; m.IntPtr0 = (IntPtr)h.handle;
paramQueue.Enqueue(m);
glActionQueue.Enqueue(GenTexturesPtr);
return h;
}
public void GetGraphicError()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe glSHandle IglFunc.GetUniformLocation(glHandle program, string ptr)
{
throw new NotImplementedException();
}
void IglFunc.GetGraphicError()
{
throw new NotImplementedException();
}
unsafe int IglFunc.GetUniformLocation(uint program, byte* ptr)
{
int ret = -1;
glActionQueue.Enqueue(
() =>
{
int location = api->glGetUniformLocation(program, ptr);
Interlocked.Add(ref ret, location + 1);
}
);
while (ret < 0) { }
return ret;
glSHandle h = glSHandle.Alloc(0);
M128 m;
m.IntPtr0 = program.Handle;
m.IntPtr1 = GCHandle.Alloc(Encoding.UTF8.GetBytes(ptr)).AddrOfPinnedObject();
paramQueue.Enqueue(m);
paramQueue.Enqueue((IntPtr)h.valuePtr);
glActionQueue.Enqueue(GetUniformLocationPtr);
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
bool IglFunc.GetWindowShouldClose(Form form)
{
return InternalIO.glfw.WindowShouldClose(form.windowID) == 0;
return InternalIO.glfwWindowShouldClose(form.windowID) == 0;
}
public void GLswapBuffers(Form form)
@@ -314,7 +295,7 @@ namespace StgSharp.Graphics
{
return;
}
InternalIO.glfw.SwapBuffers(form.windowID);
InternalIO.glfwSwapBuffers(form.windowID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -324,120 +305,77 @@ namespace StgSharp.Graphics
{
return;
}
InternalIO.glfw.MakeContextCurrent(form.windowID);
InternalIO.glfwMakeContextCurrent(form.windowID);
}
void IglFunc.SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
{
glActionQueue.Enqueue(
() =>
{
T data = bufferData;
int size = sizeof(T);
api->glBufferData(
(uint)bufferType,
(UIntPtr)size,
&data,
(uint)usage);
}
);
paramQueue.Enqueue((uint)bufferType, (uint)usage);
paramQueue.Enqueue((IntPtr)sizeof(T), GCHandle.Alloc(bufferData).AddrOfPinnedObject());
glActionQueue.Enqueue(BufferDataPtr);
}
void IglFunc.SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
{
glActionQueue.Enqueue(
() =>
{
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
if (bufferArray == null)
{
return;
}
fixed (void* bufferPtr = bufferArray)
api->glBufferData(
(uint)bufferType,
(UIntPtr)size,
bufferPtr,
(uint)usage);
}
);
paramQueue.Enqueue((uint)bufferType, (uint)usage);
paramQueue.Enqueue((IntPtr)(Marshal.SizeOf<T>() * bufferArray.Length), GCHandle.Alloc(bufferArray).AddrOfPinnedObject());
glActionQueue.Enqueue(BufferDataPtr);
}
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
void IglFunc.SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer)
{
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(handler);
InternalIO.glfw.SetFramebufferSizeCallback(id, handlerPtr);
uint type = InternalIO.GLtype[t];
paramQueue.Enqueue(index, type, stride);
paramQueue.Enqueue(size, normalized ? 1 : 0, pointer);
glActionQueue.Enqueue(SetVertexArrayPtr);
}
void IglFunc.SetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer)
//TODO:双线程,换运行环境
void IglFunc.SwitchContext()
{
glActionQueue.Enqueue(
() =>
{
uint type = InternalIO.GLtype[t];
api->glVertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
api->glEnableVertexAttribArray(index);
}
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetWindowShouldClose(Form form, bool mark)
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels)
{
InternalIO.glfw.SetWindowShouldClose(form.windowID, mark ? 1 : 0);
}
void IglFunc.SwapBuffers(Form form)
{
glActionQueue.Enqueue(
() =>
{
if (form.windowID == IntPtr.Zero)
{
return;
}
InternalIO.glfw.SwapBuffers(form.windowID);
}
);
IntPtr source = GCHandle.Alloc(pixels, GCHandleType.Pinned).AddrOfPinnedObject();
paramQueue.Enqueue(source);
paramQueue.Enqueue((uint)level, internalformat, width, height);
paramQueue.Enqueue((uint)target, format, type);
glActionQueue.Enqueue(textureImage2dPtr);
}
unsafe void IglFunc.TextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels)
void IglFunc.TextureParameter(int target, uint pname, int param)
{
glActionQueue.Enqueue(
() =>
{
api->glTexImage2D(target, level, internalformat, width, height, 0, format, type, pixels);
}
);
M128 m = default;
m.Int32[0] = target;
m.UInt32[2] = pname;
m.Int32[3] = param;
paramQueue.Enqueue(m);
glActionQueue.Enqueue(TextureParameterPtr);
}
void IglFunc.TextureParameter(uint target, uint pname, int param)
void IglFunc.UseProgram(glHandle program)
{
glActionQueue.Enqueue(
() =>
{
api->glTextureParameteri(target, pname, param);
}
);
}
void IglFunc.UseProgram(uint rogram)
{
glActionQueue.Enqueue(
() =>
{
api->glUseProgram(rogram);
}
);
paramQueue.Enqueue((IntPtr)program.valuePtr);
glActionQueue.Enqueue(UseProgramPtr);
}
void IglFunc.Viewport(int x, int y, uint width, uint height)
{
glActionQueue.Enqueue(
() =>
{
api->glViewport(x, y, width, height);
}
);
Vec4d v = new Vec4d(x, y, (int)width, (int)height);
paramQueue.Enqueue(v);
glActionQueue.Enqueue(ViewPortPtr);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void frameworkHandleEnqueue(IntPtr methodHandle, params M128[] param)
{
glActionQueue.Enqueue(methodHandle);
foreach (M128 item in param)
{
paramQueue.Enqueue(item);
}
}
}
}
@@ -4,6 +4,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
@@ -13,15 +14,30 @@ namespace StgSharp.Graphics
{
internal unsafe partial class GLonUpdate : IglFunc
{
internal IntPtr ActiveTexturePtr = (IntPtr)(delegate*<void>)&InternalActiveTexture;
internal IntPtr AttachShaderPtr = (IntPtr)(delegate*<void>)&InternalAttachShader;
internal IntPtr BindBufferPtr = (IntPtr)(delegate*<void>)&InternalBindBuffer;
internal IntPtr ClearColorPtr = (IntPtr)(delegate*<void>)&InternalClearColor;
internal IntPtr ClearGraphicErrorPtr = (IntPtr)(delegate*<void>)&InternalClearGraphicError;
internal IntPtr CompileShaderPtr = (IntPtr)(delegate*<void>)&InternalCompileShader;
IntPtr BindTexturePtr = (IntPtr)(delegate*<void>)&InternalBindTexture;
IntPtr BindVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalBindVertexArray;
private IntPtr ActiveTexturePtr = (IntPtr)(delegate*<void>)&InternalActiveTexture;
private IntPtr AttachShaderPtr = (IntPtr)(delegate*<void>)&InternalAttachShader;
private IntPtr BindBufferPtr = (IntPtr)(delegate*<void>)&InternalBindBuffer;
private IntPtr ClearColorPtr = (IntPtr)(delegate*<void>)&InternalClearColor;
private IntPtr ClearGraphicErrorPtr = (IntPtr)(delegate*<void>)&InternalClearGraphicError;
private IntPtr CompileShaderPtr = (IntPtr)(delegate*<void>)&InternalCompileShader;
private IntPtr DeleBufferPtr = (IntPtr)(delegate*<void>)&InternalDeleteBuffer;
private IntPtr BindTexturePtr = (IntPtr)(delegate*<void>)&InternalBindTexture;
private IntPtr BindVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalBindVertexArray;
private IntPtr BufferDataPtr = (IntPtr)(delegate*<void>)&InternalSetBufferData;
private IntPtr ClearPtr = (IntPtr)(delegate*<void>)&InternalClear;
private IntPtr CreateProgramPtr = (IntPtr)(delegate*<void>)&InternalCreateProgram;
private IntPtr CreateProgramSetPtr = (IntPtr)(delegate*<void>)&InternalCreateProgramSet;
private IntPtr DeleteVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalDeleteVertexArrays;
private IntPtr DrawElementsPtr = (IntPtr)(delegate*<void>)&InternalDrawElements;
private IntPtr GenBufferPtr = (IntPtr)(delegate*<void>)&InternalGenBuffers;
private IntPtr GenTexturesPtr = (IntPtr)(delegate*<void>)&InternalGenTextures;
private IntPtr GenVertexArraysPtr = (IntPtr)(delegate*<void>)&InternalGenVertexArrays;
private IntPtr GetUniformLocationPtr = (IntPtr)(delegate*<void>)&InternalGetUniformLocation;
private IntPtr SetVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalSetVertexAttribute;
private IntPtr textureImage2dPtr = (IntPtr)(delegate*<void>)&InternalTextureImage2d;
private IntPtr TextureParameterPtr = (IntPtr)(delegate*<void>)&InternalTextureParameter;
private IntPtr UseProgramPtr = (IntPtr)(delegate*<void>)&InternalUseProgram;
private IntPtr ViewPortPtr = (IntPtr)(delegate*<void>)&InternalViewport;
private static void InternalActiveTexture()
{
@@ -46,9 +62,9 @@ namespace StgSharp.Graphics
private static void InternalBindTexture()
{
uint t, te;
paramQueue.TryDequeue(out t, out te);
paramQueue.context->glBindTexture(t, te);
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glBindTexture(m.UInt32[0], *(uint*)m.IntPtr1);
}
private static void InternalBindVertexArray()
@@ -121,17 +137,6 @@ namespace StgSharp.Graphics
}
}
private void InternalAfterAlign(Form form, Action action)
{
throw new NotImplementedException();
}
private void InternalAlignFrame(Form form)
{
throw new NotImplementedException();
}
IntPtr CreateProgramPtr = (IntPtr)(delegate*<void>)&InternalCreateProgram;
private static void InternalCreateProgram()
{
IntPtr programHandle = default;
@@ -139,8 +144,6 @@ namespace StgSharp.Graphics
*(uint*)programHandle = paramQueue.context->glCreateProgram();
}
IntPtr CreateProgramSetPtr = (IntPtr)(delegate*<void>)&InternalCreateProgramSet;
private static void InternalCreateProgramSet()
{
IntPtr programHandle;
@@ -153,8 +156,6 @@ namespace StgSharp.Graphics
}
}
internal IntPtr DeleBufferPtr = (IntPtr)(delegate*<void>)&InternalDeleteBuffer;
private static void InternalDeleteBuffer()
{
M128 m = default;
@@ -162,44 +163,101 @@ namespace StgSharp.Graphics
paramQueue.context->glDeleteBuffers(m.UInt32[2], (uint*)m.IntPtr0);
}
private void InternalDeleteVertexArrays(glHandleSet arrays)
private static void InternalDeleteVertexArrays()
{
throw new NotImplementedException();
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glDeleteVertexArrays((uint)m.Int32[0], (uint*)m.IntPtr1);
}
private void InternalDrawElements(GepmetryType mode, uint count, Type type, IntPtr ptr)
private static void InternalDrawElements()
{
throw new NotImplementedException();
uint mode, count, type;
IntPtr ptr;
paramQueue.TryDequeue(out mode, out count, out type);
paramQueue.TryDequeue(out ptr);
paramQueue.context->glDrawElements(mode, count, type, (void*)ptr);
}
private void InternalGenBuffers(uint count, glHandleSet ptr)
private static void InternalGenBuffers()
{
throw new NotImplementedException();
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glGenBuffers(m.UInt32[2], (uint*)m.IntPtr0);
}
private void InternalGenTextures(uint count, glHandleSet ptr)
private static void InternalGenTextures()
{
throw new NotImplementedException();
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glGenTextures(m.UInt32[2], (uint*)m.IntPtr0);
}
private void InternalGenVertexArrays(uint count, glHandleSet ptr)
private static void InternalGenVertexArrays()
{
throw new NotImplementedException();
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glGenVertexArrays(m.UInt32[2], (uint*)m.IntPtr0);
}
private void InternalGetGraphicError()
private static void InternalGetUniformLocation()
{
throw new NotImplementedException();
IntPtr programHandle = default, nameHandle = default, targetHandle = default;
paramQueue.TryDequeue(out programHandle, out nameHandle);
paramQueue.TryDequeue(out targetHandle);
*(int*)targetHandle = paramQueue.context->glGetUniformLocation(*(uint*)programHandle, (byte*)nameHandle);
}
private int InternalGetUniformLocation(uint program, byte* ptr)
private static void InternalSetBufferData()
{
throw new NotImplementedException();
uint type = 0, use = 0;
IntPtr size = default, handle = default;
paramQueue.TryDequeue(out type, out use);
paramQueue.TryDequeue(out size, out handle);
paramQueue.context->glBufferData(type, size, (void*)handle, use);
GCHandle.FromIntPtr(handle).Free();
}
private bool InternalGetWindowShouldClose(Form form)
private static void InternalSetVertexAttribute()
{
throw new NotImplementedException();
uint index, type, stride;
int size, normalized, pointer;
paramQueue.TryDequeue(out index, out type, out stride);
paramQueue.TryDequeue(out size, out normalized, out pointer);
paramQueue.context->glVertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
paramQueue.context->glEnableVertexAttribArray(index);
}
private static void InternalTextureImage2d()
{
IntPtr pix = IntPtr.Zero;
uint target, level, internalFormat, width, height, format, type;
paramQueue.TryDequeue(out pix);
paramQueue.TryDequeue(out level, out internalFormat, out width, out height);
paramQueue.TryDequeue(out target, out format, out type);
paramQueue.context->glTexImage2D(target, (int)level, internalFormat, width, height, 0, format, type, (void*)pix);
GCHandle.FromIntPtr(pix).Free();
}
private static void InternalTextureParameter()
{
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glTextureParameteri(m.UInt32[0], m.UInt32[2], m.Int32[3]);
}
private static void InternalUseProgram()
{
IntPtr handle = IntPtr.Zero;
paramQueue.TryDequeue(out handle);
paramQueue.context->glUseProgram(*(uint*)handle);
}
private static void InternalViewport()
{
M128 m = default;
paramQueue.TryDequeue(out m);
paramQueue.context->glViewport(m.Int32[0], m.Int32[1], m.UInt32[2], m.UInt32[3]);
}
private void InternalMakeContexCurrent(Form form)
@@ -207,94 +265,14 @@ namespace StgSharp.Graphics
throw new NotImplementedException();
}
private void InternalSetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
{
throw new NotImplementedException();
}
private void InternalSetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
{
throw new NotImplementedException();
}
private void InternalSetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<float, float> uniform, float v0, float v1)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<float> uniform, float v0)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<int> uniform, int i0)
{
throw new NotImplementedException();
}
private void InternalSetValue(Uniform<Vec4d> uniform, Vec4d vec)
{
throw new NotImplementedException();
}
private void InternalSetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer)
{
throw new NotImplementedException();
}
private void InternalSetWindowShouldClose(Form form, bool mark)
{
throw new NotImplementedException();
}
private void InternalSwapBuffers(Form form)
{
throw new NotImplementedException();
}
private void InternalSwitchContext()
{
throw new NotImplementedException();
}
private void InternalTextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels)
{
throw new NotImplementedException();
}
private void InternalTextureParameter(uint target, uint pname, int param)
{
throw new NotImplementedException();
}
private void InternalUseProgram(uint program)
{
throw new NotImplementedException();
}
private void InternalViewport(int x, int y, uint width, uint height)
{
throw new NotImplementedException();
}
}
}
@@ -15,7 +15,7 @@ namespace StgSharp.Graphics
/// <param name="count">Amount of EBO to be created.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected ElementBuffer CreateElementBuffer(uint count)
protected ElementBuffer CreateElementBuffer(int count)
{
return new ElementBuffer(count, this.gl);
}
@@ -27,7 +27,7 @@ namespace StgSharp.Graphics
/// <param name="count">Amount of VAO to be crated.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected VertexArray CreateVertexArray(uint count)
protected VertexArray CreateVertexArray(int count)
{
return new VertexArray(count, gl);
}
@@ -35,22 +35,21 @@ namespace StgSharp.Graphics
/// <summary>
/// Create a sets of <see cref="Texture"/>
/// </summary>
/// <param name="n">Amount of textures to be crated.</param>
/// <param name="count">Amount of textures to be crated.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected Texture CreateTexture(uint n)
protected Texture CreateTexture(int count)
{
return new Texture(n, this.GL);
return new Texture(count, this.GL);
}
/// <summary>
/// Create aset of <see cref="VertexBuffer"/>.
/// </summary>
/// <param name="count">Amount of Object to be created.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected VertexBuffer CreateVertexBuffer(uint count)
protected VertexBuffer CreateVertexBuffer(int count)
{
return new VertexBuffer(count, gl);
}
@@ -14,33 +14,37 @@ namespace StgSharp.Graphics
/// </summary>
/// <returns>New instance of <see cref="Shader"/> instance. </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected ShaderProgram CreateShaderProgram(ShaderType shaderType)
protected ShaderProgram CreateShaderProgram()
{
return new ShaderProgram(GL, 1);
return new ShaderProgram(GL);
}
protected Shader CreateShader(ShaderType type, int count)
{
return new Shader(this.gl, new glHandleSet(count), type);
}
}
public class Shader
{
internal readonly glHandle handle;
internal readonly glHandleSet handle;
public readonly ShaderType type;
private readonly IglFunc GL;
internal Shader(IglFunc gl, glHandle handle)
internal Shader(IglFunc gl, glHandleSet handle, ShaderType usage)
{
this.handle = handle;
GL = gl;
type = usage;
}
/// <summary>
/// Compile the vertex shader to be attached to this shader.
/// </summary>
/// <param name="shaderCode">GLSL code of vertex shader.</param>
public unsafe void Compile(string shaderCode, ShaderType usage, int index)
public unsafe void Compile(ShaderType usage, params string[] code)
{
handle.handle[index] = GL.CompileShader(shaderCode, type).handle;
glHandleSet.Copy(GL.CompileShader(usage, code), handle);
}
//TODO:写链接着色器的文档注释
@@ -48,20 +52,11 @@ namespace StgSharp.Graphics
///
/// </summary>
/// <param name="target"></param>
/// <param name="usage"></param>
public void AttachTo(ShaderProgram target, ShaderType usage)
/// <param name="index"></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AttachTo(int index, ShaderProgram target)
{
switch (usage)
{
case ShaderType.Fragment:
break;
case ShaderType.Vertex:
GL.AttachShader(target.handle,)
break;
default:
throw new ArgumentException();
}
GL.AttachShader(target.handle, handle[index]);
}
}
@@ -74,7 +69,7 @@ namespace StgSharp.Graphics
/// <summary>
/// Inti a shader with no program attached.
/// </summary>
internal unsafe ShaderProgram(IglFunc gl, int count)
internal unsafe ShaderProgram(IglFunc gl)
{
GL = gl;
handle = GL.CreateProgram();
@@ -85,7 +80,7 @@ namespace StgSharp.Graphics
/// </summary>
public void Link()
{
if (InternalIO.InternalLinkShaderProgram(handle[0]) == 0)
if (InternalIO.InternalLinkShaderProgram(handle.Value) == 0)
{
IntPtr logPtr = InternalIO.InternalReadLog();
try
@@ -109,22 +104,10 @@ namespace StgSharp.Graphics
/// </summary>
/// <param name="name">Name of the Uniform in shader code</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe Uniform<T> GetUniform<T>(string name) where T : struct
{
byte[] bytes = Encoding.ASCII.GetBytes(name);
int uniform;
fixed (byte* ptr = bytes)
{
uniform = GL.GetUniformLocation(handle[0], ptr);
}
if (uniform != -1)
{
return new Uniform<T>(uniform);
}
else
{
throw new Exception($"Cannot find the uniform {name} in shader {handle[0]}");
}
return new Uniform<T>(this, name, GL);
}
/// <summary>
/// Get a uniform form current shader,
@@ -136,20 +119,7 @@ namespace StgSharp.Graphics
where T : struct
where U : struct
{
byte[] bytes = Encoding.ASCII.GetBytes(name);
int uniform;
fixed (byte* ptr = bytes)
{
uniform = GL.GetUniformLocation(handle[0], ptr);
}
if (uniform != -1)
{
return new Uniform<T, U>(uniform);
}
else
{
throw new Exception($"Cannot find the uniform {name} in shader {handle[0]}");
}
return new Uniform<T, U>(this, name, GL);
}
/// <summary>
/// Get a uniform form current shader,
@@ -157,34 +127,21 @@ namespace StgSharp.Graphics
/// </summary>
/// <param name="name">Name of the Uniform in shader code</param>
/// <returns></returns>
public unsafe Uniform<T, U, V> GetUniform<T, U, V>(int index, string name)
public unsafe Uniform<T, U, V> GetUniform<T, U, V>(string name)
where T : struct
where U : struct
where V : struct
{
byte[] bytes = Encoding.ASCII.GetBytes(name);
int uniform;
fixed (byte* ptr = bytes)
{
uniform = GL.GetUniformLocation(handle[index], ptr);
}
if (uniform != -1)
{
return new Uniform<T, U, V>(uniform);
}
else
{
throw new Exception($"Cannot find the uniform {name} in shader {handle[index]}");
}
return new Uniform<T, U, V>(this, name, GL);
}
/// <summary>
/// Let the current context use this shader.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Use(int index)
public unsafe void Use()
{
GL.UseProgram(handle[index]);
GL.UseProgram(handle);
}
}
@@ -11,21 +11,17 @@ namespace StgSharp.Graphics
public class Uniform<T> where T : struct
{
internal int id;
internal glSHandle id;
private IglFunc GL;
internal unsafe Uniform(
uint shaderID, string name, IglFunc gL)
ShaderProgram program, string name, IglFunc gl)
{
byte[] namearray = Encoding.ASCII.GetBytes(name);
GL = gL;
fixed (byte* ptr = namearray)
{
id = GL.GetUniformLocation(shaderID, ptr);
}
GL = gl;
id = GL.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(int id)
internal unsafe Uniform(glSHandle id)
{
this.id = id;
}
@@ -37,21 +33,17 @@ namespace StgSharp.Graphics
where T : struct
where U : struct
{
internal int id;
internal glSHandle id;
private IglFunc GL;
internal unsafe Uniform(
Shader program, string name, IglFunc glFunc)
ShaderProgram program, string name, IglFunc gl)
{
byte[] namearray = Encoding.ASCII.GetBytes(name);
GL = glFunc;
fixed (byte* ptr = namearray)
{
id = GL.GetUniformLocation(program.programID, ptr);
}
GL = gl;
id = GL.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(int id)
internal unsafe Uniform(glSHandle id)
{
this.id = id;
}
@@ -62,20 +54,16 @@ namespace StgSharp.Graphics
where U : struct
where V : struct
{
internal int id;
internal glSHandle id;
private IglFunc GL;
public unsafe Uniform(Shader program, string name, IglFunc glFunc)
public unsafe Uniform(ShaderProgram program, string name, IglFunc gl)
{
byte[] namearray = Encoding.ASCII.GetBytes(name);
GL = glFunc;
fixed (byte* ptr = namearray)
{
id = GL.GetUniformLocation(program.programID, ptr);
}
GL = gl;
id = GL.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(int id)
internal unsafe Uniform(glSHandle id)
{
this.id = id;
}
@@ -87,20 +75,16 @@ namespace StgSharp.Graphics
where V : struct
where W : struct
{
internal int id;
internal glSHandle id;
private IglFunc GL;
internal unsafe Uniform(Shader program, string name, IglFunc glFunc)
internal unsafe Uniform(ShaderProgram program, string name, IglFunc gl)
{
byte[] namearray = Encoding.ASCII.GetBytes(name);
fixed (byte* ptr = namearray)
{
id = GL.GetUniformLocation(program.programID, ptr);
}
GL = glFunc;
GL = gl;
id = GL.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(int id)
internal unsafe Uniform(glSHandle id)
{
this.id = id;
}
@@ -113,48 +97,56 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetValue(Uniform<float> uniform, float v0)
{
api->glUniform1f(uniform.id, v0);
api->glUniform1f(uniform.id.DirectValue, v0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetValue(Uniform<int> uniform, int i0)
{
api->glUniform1i(uniform.id, i0);
api->glUniform1i(uniform.id.DirectValue, i0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetValue(Uniform<float, float> uniform, float v0, float v1)
{
api->glUniform2f(uniform.id, v0, v1);
api->glUniform2f(uniform.id.DirectValue, v0, v1);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
{
api->glUniform3f(uniform.id, v0, v1, v2);
api->glUniform3f(uniform.id.DirectValue, v0, v1, v2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.SetValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
{
api->glUniform4f(uniform.id, v0, v1, v2, v3);
api->glUniform4f(uniform.id.DirectValue, v0, v1, v2, v3);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
{
api->glUniform1fv(uniform.id, 4, &vec);
api->glUniform1fv(uniform.id.DirectValue, 4, &vec);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetValue(Uniform<Vec4d> uniform, Vec4d vec)
{
api->glUniform1fv(uniform.id, 4, &vec);
api->glUniform1fv(uniform.id.DirectValue, 4, &vec);
}
}
internal partial class GLonUpdate
internal unsafe partial class GLonUpdate
{
private IntPtr UniformVal3fPtr = (IntPtr)(delegate*<void>)&UniformVal3f;
//TODO xontinue here
private static void UniformVal3f()
{
paramQueue.
}
unsafe void IglFunc.SetValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
{
glActionQueue.Enqueue(
+120 -615
View File
@@ -1,631 +1,136 @@
using System;
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace StgSharp.Graphics
namespace StgSharp
{
internal interface IglFramework
{
internal int Init();
internal unsafe void Terminate();
internal unsafe void InitHint(int hint, int value);
internal unsafe void GetVersion(int* major, int* minor, int* rev);
internal unsafe byte* GetVersionString();
internal unsafe int GetError(byte** description);
internal unsafe GLFWerrorfun SetErrorCallback(GLFWerrorfun callback);
internal unsafe IntPtr* GetMonitors(int* count);
internal unsafe IntPtr GetPrimaryMonitor();
internal unsafe void GetMonitorPos(IntPtr monitor, int* xpos, int* ypos);
internal unsafe void GetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height);
internal unsafe void GetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM);
internal unsafe void GetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale);
internal unsafe byte* GetMonitorName(IntPtr monitor);
internal unsafe void SetMonitorUserPointer(IntPtr monitor, void* pointer);
internal unsafe void* GetMonitorUserPointer(IntPtr monitor);
internal unsafe GLFWmonitorfun SetMonitorCallback(GLFWmonitorfun callback);
internal unsafe GLFWvidmode* GetVideoModes(IntPtr monitor, int* count);
internal unsafe GLFWvidmode* GetVideoMode(IntPtr monitor);
internal unsafe void SetGamma(IntPtr monitor, float gamma);
internal unsafe GLFWgammaramp* GetGammaRamp(IntPtr monitor);
internal unsafe void SetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp);
internal unsafe void DefaultWindowHints();
internal unsafe void WindowHint(int hint, int value);
internal unsafe void WindowHintString(int hint, byte* value);
internal unsafe IntPtr CreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share);
internal unsafe void DestroyWindow(IntPtr window);
internal unsafe int WindowShouldClose(IntPtr window);
internal unsafe void SetWindowShouldClose(IntPtr window, int value);
internal unsafe void SetWindowTitle(IntPtr window, byte* title);
internal unsafe void SetWindowIcon(IntPtr window, int count, GLFWimage* images);
internal unsafe void GetWindowPos(IntPtr window, int* xpos, int* ypos);
internal unsafe void SetWindowPos(IntPtr window, int xpos, int ypos);
internal unsafe void GetWindowSize(IntPtr window, int* width, int* height);
internal unsafe void SetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight);
internal unsafe void SetWindowAspectRatio(IntPtr window, int numer, int denom);
internal unsafe void SetWindowSize(IntPtr window, int width, int height);
internal unsafe void GetFramebufferSize(IntPtr window, int* width, int* height);
internal unsafe void GetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom);
internal unsafe void GetWindowContentScale(IntPtr window, float* xscale, float* yscale);
internal unsafe float GetWindowOpacity(IntPtr window);
internal unsafe void SetWindowOpacity(IntPtr window, float opacity);
internal unsafe void IconifyWindow(IntPtr window);
internal unsafe void RestoreWindow(IntPtr window);
internal unsafe void MaximizeWindow(IntPtr window);
internal unsafe void ShowWindow(IntPtr window);
internal unsafe void HideWindow(IntPtr window);
internal unsafe void FocusWindow(IntPtr window);
internal unsafe void RequestWindowAttention(IntPtr window);
internal unsafe IntPtr GetWindowMonitor(IntPtr window);
internal unsafe void SetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate);
internal unsafe int GetWindowAttrib(IntPtr window, int attrib);
internal unsafe void SetWindowAttrib(IntPtr window, int attrib, int value);
internal unsafe void SetWindowUserPointer(IntPtr window, void* pointer);
internal unsafe void* GetWindowUserPointer(IntPtr window);
internal unsafe GLFWwindowposfun SetWindowPosCallback(IntPtr window, GLFWwindowposfun callback);
internal unsafe GLFWwindowsizefun SetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
internal unsafe GLFWwindowclosefun SetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback);
internal unsafe GLFWwindowrefreshfun SetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback);
internal unsafe GLFWwindowfocusfun SetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback);
internal unsafe GLFWwindowiconifyfun SetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback);
internal unsafe GLFWwindowmaximizefun SetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback);
internal unsafe FramebuffersizeHandler SetFramebufferSizeCallback(IntPtr window, IntPtr callback);
internal unsafe GLFWwindowcontentscalefun SetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback);
internal unsafe void PollEvents();
internal unsafe void WaitEvents();
internal unsafe void WaitEventsTimeout(double timeout);
internal unsafe void PostEmptyEvent();
internal unsafe int GetInputMode(IntPtr window, int mode);
internal unsafe void SetInputMode(IntPtr window, int mode, int value);
internal unsafe int RawMouseMotionSupported();
internal unsafe byte* GetKeyName(int key, int scancode);
internal unsafe int GetKeyScancode(int key);
internal unsafe KeyStatus GetKey(IntPtr window, int key);
internal unsafe int GetMouseButton(IntPtr window, int button);
internal unsafe void GetCursorPos(IntPtr window, double* xpos, double* ypos);
internal unsafe void SetCursorPos(IntPtr window, double xpos, double ypos);
internal unsafe GLFWcursor* CreateCursor(GLFWimage* image, int xhot, int yhot);
internal unsafe GLFWcursor* CreateStandardCursor(int shape);
internal unsafe void DestroyCursor(GLFWcursor* cursor);
internal unsafe void SetCursor(IntPtr window, GLFWcursor* cursor);
internal unsafe GLFWkeyfun SetKeyCallback(IntPtr window, GLFWkeyfun callback);
internal unsafe GLFWcharfun SetCharCallback(IntPtr window, GLFWcharfun callback);
internal unsafe GLFWcharmodsfun SetCharModsCallback(IntPtr window, GLFWcharmodsfun callback);
internal unsafe GLFWmousebuttonfun SetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback);
internal unsafe GLFWcursorposfun SetCursorPosCallback(IntPtr window, GLFWcursorposfun callback);
internal unsafe GLFWcursorenterfun SetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback);
internal unsafe GLFWscrollfun SetScrollCallback(IntPtr window, GLFWscrollfun callback);
internal unsafe GLFWdropfun SetDropCallback(IntPtr window, GLFWdropfun callback);
internal unsafe int JoystickPresent(int jid);
internal unsafe float* GetJoystickAxes(int jid, int* count);
internal unsafe byte* GetJoystickButtons(int jid, int* count);
internal unsafe byte* GetJoystickHats(int jid, int* count);
internal unsafe byte* GetJoystickName(int jid);
internal unsafe byte* GetJoystickGUID(int jid);
internal unsafe void SetJoystickUserPointer(int jid, void* pointer);
internal unsafe void* GetJoystickUserPointer(int jid);
internal unsafe int JoystickIsGamepad(int jid);
internal unsafe GLFWjoystickfun SetJoystickCallback(GLFWjoystickfun callback);
internal unsafe int UpdateGamepadMappings(byte* str);
internal unsafe byte* GetGamepadName(int jid);
internal unsafe int GetGamepadState(int jid, GLFWgamepadstate* state);
internal unsafe void SetClipboardString(IntPtr window, byte* str);
internal unsafe byte* GetClipboardString(IntPtr window);
internal unsafe double GetTime();
internal unsafe void SetTime(double time);
internal unsafe ulong* GetTimerValue();
internal unsafe ulong* GetTimerFrequency();
internal unsafe void MakeContextCurrent(IntPtr window);
internal unsafe IntPtr GetCurrentContext();
internal unsafe void SwapBuffers(IntPtr window);
internal unsafe void SwapInterval(int interval);
internal unsafe int ExtensionSupported(byte* extension);
internal unsafe IntPtr GetProcAddress(string procname);
internal unsafe int VulkanSupported();
internal unsafe byte** GetRequiredInstanceExtensions(uint* count);
//internal unsafe GLFWvkproc GetInstanceProcAddress(VkInstance instance, byte* procname);
//internal unsafe int GetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint* queuefamily);
//internal unsafe VkResult CreateWindowSurface(VkInstance instance, IntPtr window, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
}
internal class glFramework_PInvoke : IglFramework
internal partial class InternalIO
{
#region api call
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwInit")] internal extern unsafe static int glfwInit();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwTerminate")] internal extern unsafe static void glfwTerminate();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwInitHint")] internal extern unsafe static void glfwInitHint(int hint, int value);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetVersion")] internal extern unsafe static void glfwGetVersion(int* major, int* minor, int* rev);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetVersionString")] internal extern unsafe static byte* glfwGetVersionString();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetError")] internal extern unsafe static int glfwGetError(byte** description);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetErrorCallback")] internal extern unsafe static GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitors")] internal extern unsafe static IntPtr* glfwGetMonitors(int* count);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetPrimaryMonitor")] internal extern unsafe static IntPtr glfwGetPrimaryMonitor();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitorPos")] internal extern unsafe static void glfwGetMonitorPos(IntPtr monitor, int* xpos, int* ypos);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitorWorkarea")] internal extern unsafe static void glfwGetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitorPhysicalSize")] internal extern unsafe static void glfwGetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitorContentScale")] internal extern unsafe static void glfwGetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitorName")] internal extern unsafe static byte* glfwGetMonitorName(IntPtr monitor);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetMonitorUserPointer")] internal extern unsafe static void glfwSetMonitorUserPointer(IntPtr monitor, void* pointer);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMonitorUserPointer")] internal extern unsafe static void* glfwGetMonitorUserPointer(IntPtr monitor);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetMonitorCallback")] internal extern unsafe static GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetVideoModes")] internal extern unsafe static GLFWvidmode* glfwGetVideoModes(IntPtr monitor, int* count);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetVideoMode")] internal extern unsafe static GLFWvidmode* glfwGetVideoMode(IntPtr monitor);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetGamma")] internal extern unsafe static void glfwSetGamma(IntPtr monitor, float gamma);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetGammaRamp")] internal extern unsafe static GLFWgammaramp* glfwGetGammaRamp(IntPtr monitor);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetGammaRamp")] internal extern unsafe static void glfwSetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwDefaultWindowHints")] internal extern unsafe static void glfwDefaultWindowHints();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwWindowHint")] internal extern unsafe static void glfwWindowHint(int hint, int value);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwWindowHintString")] internal extern unsafe static void glfwWindowHintString(int hint, byte* value);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwCreateWindow")] internal extern unsafe static IntPtr glfwCreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwDestroyWindow")] internal extern unsafe static void glfwDestroyWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwWindowShouldClose")] internal extern unsafe static int glfwWindowShouldClose(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowShouldClose")] internal extern unsafe static void glfwSetWindowShouldClose(IntPtr window, int value);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowTitle")] internal extern unsafe static void glfwSetWindowTitle(IntPtr window, byte* title);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowIcon")] internal extern unsafe static void glfwSetWindowIcon(IntPtr window, int count, GLFWimage* images);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowPos")] internal extern unsafe static void glfwGetWindowPos(IntPtr window, int* xpos, int* ypos);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowPos")] internal extern unsafe static void glfwSetWindowPos(IntPtr window, int xpos, int ypos);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowSize")] internal extern unsafe static void glfwGetWindowSize(IntPtr window, int* width, int* height);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowSizeLimits")] internal extern unsafe static void glfwSetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowAspectRatio")] internal extern unsafe static void glfwSetWindowAspectRatio(IntPtr window, int numer, int denom);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowSize")] internal extern unsafe static void glfwSetWindowSize(IntPtr window, int width, int height);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetFramebufferSize")] internal extern unsafe static void glfwGetFramebufferSize(IntPtr window, int* width, int* height);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowFrameSize")] internal extern unsafe static void glfwGetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowContentScale")] internal extern unsafe static void glfwGetWindowContentScale(IntPtr window, float* xscale, float* yscale);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowOpacity")] internal extern unsafe static float glfwGetWindowOpacity(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowOpacity")] internal extern unsafe static void glfwSetWindowOpacity(IntPtr window, float opacity);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwIconifyWindow")] internal extern unsafe static void glfwIconifyWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwRestoreWindow")] internal extern unsafe static void glfwRestoreWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwMaximizeWindow")] internal extern unsafe static void glfwMaximizeWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwShowWindow")] internal extern unsafe static void glfwShowWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwHideWindow")] internal extern unsafe static void glfwHideWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwFocusWindow")] internal extern unsafe static void glfwFocusWindow(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwRequestWindowAttention")] internal extern unsafe static void glfwRequestWindowAttention(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowMonitor")] internal extern unsafe static IntPtr glfwGetWindowMonitor(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowMonitor")] internal extern unsafe static void glfwSetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowAttrib")] internal extern unsafe static int glfwGetWindowAttrib(IntPtr window, int attrib);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowAttrib")] internal extern unsafe static void glfwSetWindowAttrib(IntPtr window, int attrib, int value);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowUserPointer")] internal extern unsafe static void glfwSetWindowUserPointer(IntPtr window, void* pointer);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetWindowUserPointer")] internal extern unsafe static void* glfwGetWindowUserPointer(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowPosCallback")] internal extern unsafe static GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, GLFWwindowposfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowSizeCallback")] internal extern unsafe static GLFWwindowsizefun glfwSetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowCloseCallback")] internal extern unsafe static GLFWwindowclosefun glfwSetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowRefreshCallback")] internal extern unsafe static GLFWwindowrefreshfun glfwSetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowFocusCallback")] internal extern unsafe static GLFWwindowfocusfun glfwSetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowIconifyCallback")] internal extern unsafe static GLFWwindowiconifyfun glfwSetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowMaximizeCallback")] internal extern unsafe static GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetFramebufferSizeCallback")] internal extern unsafe static FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetWindowContentScaleCallback")] internal extern unsafe static GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwPollEvents")] internal extern unsafe static void glfwPollEvents();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwWaitEvents")] internal extern unsafe static void glfwWaitEvents();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwWaitEventsTimeout")] internal extern unsafe static void glfwWaitEventsTimeout(double timeout);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwPostEmptyEvent")] internal extern unsafe static void glfwPostEmptyEvent();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetInputMode")] internal extern unsafe static int glfwGetInputMode(IntPtr window, int mode);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetInputMode")] internal extern unsafe static void glfwSetInputMode(IntPtr window, int mode, int value);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwRawMouseMotionSupported")] internal extern unsafe static int glfwRawMouseMotionSupported();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetKeyName")] internal extern unsafe static byte* glfwGetKeyName(int key, int scancode);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetKeyScancode")] internal extern unsafe static int glfwGetKeyScancode(int key);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetKey")] internal extern unsafe static KeyStatus glfwGetKey(IntPtr window, int key);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetMouseButton")] internal extern unsafe static int glfwGetMouseButton(IntPtr window, int button);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetCursorPos")] internal extern unsafe static void glfwGetCursorPos(IntPtr window, double* xpos, double* ypos);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetCursorPos")] internal extern unsafe static void glfwSetCursorPos(IntPtr window, double xpos, double ypos);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwCreateCursor")] internal extern unsafe static GLFWcursor* glfwCreateCursor(GLFWimage* image, int xhot, int yhot);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwCreateStandardCursor")] internal extern unsafe static GLFWcursor* glfwCreateStandardCursor(int shape);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwDestroyCursor")] internal extern unsafe static void glfwDestroyCursor(GLFWcursor* cursor);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetCursor")] internal extern unsafe static void glfwSetCursor(IntPtr window, GLFWcursor* cursor);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetKeyCallback")] internal extern unsafe static GLFWkeyfun glfwSetKeyCallback(IntPtr window, GLFWkeyfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetCharCallback")] internal extern unsafe static GLFWcharfun glfwSetCharCallback(IntPtr window, GLFWcharfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetCharModsCallback")] internal extern unsafe static GLFWcharmodsfun glfwSetCharModsCallback(IntPtr window, GLFWcharmodsfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetMouseButtonCallback")] internal extern unsafe static GLFWmousebuttonfun glfwSetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetCursorPosCallback")] internal extern unsafe static GLFWcursorposfun glfwSetCursorPosCallback(IntPtr window, GLFWcursorposfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetCursorEnterCallback")] internal extern unsafe static GLFWcursorenterfun glfwSetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetScrollCallback")] internal extern unsafe static GLFWscrollfun glfwSetScrollCallback(IntPtr window, GLFWscrollfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetDropCallback")] internal extern unsafe static GLFWdropfun glfwSetDropCallback(IntPtr window, GLFWdropfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwJoystickPresent")] internal extern unsafe static int glfwJoystickPresent(int jid);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetJoystickAxes")] internal extern unsafe static float* glfwGetJoystickAxes(int jid, int* count);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetJoystickButtons")] internal extern unsafe static byte* glfwGetJoystickButtons(int jid, int* count);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetJoystickHats")] internal extern unsafe static byte* glfwGetJoystickHats(int jid, int* count);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetJoystickName")] internal extern unsafe static byte* glfwGetJoystickName(int jid);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetJoystickGUID")] internal extern unsafe static byte* glfwGetJoystickGUID(int jid);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetJoystickUserPointer")] internal extern unsafe static void glfwSetJoystickUserPointer(int jid, void* pointer);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetJoystickUserPointer")] internal extern unsafe static void* glfwGetJoystickUserPointer(int jid);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwJoystickIsGamepad")] internal extern unsafe static int glfwJoystickIsGamepad(int jid);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetJoystickCallback")] internal extern unsafe static GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwUpdateGamepadMappings")] internal extern unsafe static int glfwUpdateGamepadMappings(byte* str);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetGamepadName")] internal extern unsafe static byte* glfwGetGamepadName(int jid);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetGamepadState")] internal extern unsafe static int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetClipboardString")] internal extern unsafe static void glfwSetClipboardString(IntPtr window, byte* str);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetClipboardString")] internal extern unsafe static byte* glfwGetClipboardString(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetTime")] internal extern unsafe static double glfwGetTime();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSetTime")] internal extern unsafe static void glfwSetTime(double time);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetTimerValue")] internal extern unsafe static ulong* glfwGetTimerValue();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetTimerFrequency")] internal extern unsafe static ulong* glfwGetTimerFrequency();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwMakeContextCurrent")] internal extern unsafe static void glfwMakeContextCurrent(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetCurrentContext")] internal extern unsafe static IntPtr glfwGetCurrentContext();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSwapBuffers")] internal extern unsafe static void glfwSwapBuffers(IntPtr window);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwSwapInterval")] internal extern unsafe static void glfwSwapInterval(int interval);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwExtensionSupported")] internal extern unsafe static int glfwExtensionSupported(byte* extension);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetProcAddress", CharSet = CharSet.Ansi)] internal extern unsafe static IntPtr glfwGetProcAddress(string procname);
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwVulkanSupported")] internal extern unsafe static int glfwVulkanSupported();
[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetRequiredInstanceExtensions")] internal extern unsafe static byte** glfwGetRequiredInstanceExtensions(uint* count);
[DllImport(SSC_libname, EntryPoint = "glfwInit")] internal extern unsafe static int glfwInit();
[DllImport(SSC_libname, EntryPoint = "glfwTerminate")] internal extern unsafe static void glfwTerminate();
[DllImport(SSC_libname, EntryPoint = "glfwInitHint")] internal extern unsafe static void glfwInitHint(int hint, int value);
[DllImport(SSC_libname, EntryPoint = "glfwGetVersion")] internal extern unsafe static void glfwGetVersion(int* major, int* minor, int* rev);
[DllImport(SSC_libname, EntryPoint = "glfwGetVersionString")] internal extern unsafe static byte* glfwGetVersionString();
[DllImport(SSC_libname, EntryPoint = "glfwGetError")] internal extern unsafe static int glfwGetError(byte** description);
[DllImport(SSC_libname, EntryPoint = "glfwSetErrorCallback")] internal extern unsafe static GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitors")] internal extern unsafe static IntPtr* glfwGetMonitors(int* count);
[DllImport(SSC_libname, EntryPoint = "glfwGetPrimaryMonitor")] internal extern unsafe static IntPtr glfwGetPrimaryMonitor();
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorPos")] internal extern unsafe static void glfwGetMonitorPos(IntPtr monitor, int* xpos, int* ypos);
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorWorkarea")] internal extern unsafe static void glfwGetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height);
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorPhysicalSize")] internal extern unsafe static void glfwGetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM);
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorContentScale")] internal extern unsafe static void glfwGetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale);
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorName")] internal extern unsafe static byte* glfwGetMonitorName(IntPtr monitor);
[DllImport(SSC_libname, EntryPoint = "glfwSetMonitorUserPointer")] internal extern unsafe static void glfwSetMonitorUserPointer(IntPtr monitor, void* pointer);
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorUserPointer")] internal extern unsafe static void* glfwGetMonitorUserPointer(IntPtr monitor);
[DllImport(SSC_libname, EntryPoint = "glfwSetMonitorCallback")] internal extern unsafe static GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwGetVideoModes")] internal extern unsafe static GLFWvidmode* glfwGetVideoModes(IntPtr monitor, int* count);
[DllImport(SSC_libname, EntryPoint = "glfwGetVideoMode")] internal extern unsafe static GLFWvidmode* glfwGetVideoMode(IntPtr monitor);
[DllImport(SSC_libname, EntryPoint = "glfwSetGamma")] internal extern unsafe static void glfwSetGamma(IntPtr monitor, float gamma);
[DllImport(SSC_libname, EntryPoint = "glfwGetGammaRamp")] internal extern unsafe static GLFWgammaramp* glfwGetGammaRamp(IntPtr monitor);
[DllImport(SSC_libname, EntryPoint = "glfwSetGammaRamp")] internal extern unsafe static void glfwSetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp);
[DllImport(SSC_libname, EntryPoint = "glfwDefaultWindowHints")] internal extern unsafe static void glfwDefaultWindowHints();
[DllImport(SSC_libname, EntryPoint = "glfwWindowHint")] internal extern unsafe static void glfwWindowHint(int hint, int value);
[DllImport(SSC_libname, EntryPoint = "glfwWindowHintString")] internal extern unsafe static void glfwWindowHintString(int hint, byte* value);
[DllImport(SSC_libname, EntryPoint = "glfwCreateWindow")] internal extern unsafe static IntPtr glfwCreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share);
[DllImport(SSC_libname, EntryPoint = "glfwDestroyWindow")] internal extern unsafe static void glfwDestroyWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwWindowShouldClose")] internal extern unsafe static int glfwWindowShouldClose(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowShouldClose")] internal extern unsafe static void glfwSetWindowShouldClose(IntPtr window, int value);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowTitle")] internal extern unsafe static void glfwSetWindowTitle(IntPtr window, byte* title);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowIcon")] internal extern unsafe static void glfwSetWindowIcon(IntPtr window, int count, GLFWimage* images);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowPos")] internal extern unsafe static void glfwGetWindowPos(IntPtr window, int* xpos, int* ypos);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowPos")] internal extern unsafe static void glfwSetWindowPos(IntPtr window, int xpos, int ypos);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowSize")] internal extern unsafe static void glfwGetWindowSize(IntPtr window, int* width, int* height);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSizeLimits")] internal extern unsafe static void glfwSetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowAspectRatio")] internal extern unsafe static void glfwSetWindowAspectRatio(IntPtr window, int numer, int denom);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSize")] internal extern unsafe static void glfwSetWindowSize(IntPtr window, int width, int height);
[DllImport(SSC_libname, EntryPoint = "glfwGetFramebufferSize")] internal extern unsafe static void glfwGetFramebufferSize(IntPtr window, int* width, int* height);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowFrameSize")] internal extern unsafe static void glfwGetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowContentScale")] internal extern unsafe static void glfwGetWindowContentScale(IntPtr window, float* xscale, float* yscale);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowOpacity")] internal extern unsafe static float glfwGetWindowOpacity(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowOpacity")] internal extern unsafe static void glfwSetWindowOpacity(IntPtr window, float opacity);
[DllImport(SSC_libname, EntryPoint = "glfwIconifyWindow")] internal extern unsafe static void glfwIconifyWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwRestoreWindow")] internal extern unsafe static void glfwRestoreWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwMaximizeWindow")] internal extern unsafe static void glfwMaximizeWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwShowWindow")] internal extern unsafe static void glfwShowWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwHideWindow")] internal extern unsafe static void glfwHideWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwFocusWindow")] internal extern unsafe static void glfwFocusWindow(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwRequestWindowAttention")] internal extern unsafe static void glfwRequestWindowAttention(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowMonitor")] internal extern unsafe static IntPtr glfwGetWindowMonitor(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowMonitor")] internal extern unsafe static void glfwSetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowAttrib")] internal extern unsafe static int glfwGetWindowAttrib(IntPtr window, int attrib);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowAttrib")] internal extern unsafe static void glfwSetWindowAttrib(IntPtr window, int attrib, int value);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowUserPointer")] internal extern unsafe static void glfwSetWindowUserPointer(IntPtr window, void* pointer);
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowUserPointer")] internal extern unsafe static void* glfwGetWindowUserPointer(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowPosCallback")] internal extern unsafe static GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, GLFWwindowposfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSizeCallback")] internal extern unsafe static GLFWwindowsizefun glfwSetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowCloseCallback")] internal extern unsafe static GLFWwindowclosefun glfwSetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowRefreshCallback")] internal extern unsafe static GLFWwindowrefreshfun glfwSetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowFocusCallback")] internal extern unsafe static GLFWwindowfocusfun glfwSetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowIconifyCallback")] internal extern unsafe static GLFWwindowiconifyfun glfwSetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowMaximizeCallback")] internal extern unsafe static GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetFramebufferSizeCallback")] internal extern unsafe static FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowContentScaleCallback")] internal extern unsafe static GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback);
[DllImport(SSC_libname, EntryPoint = "glfwPollEvents")] internal extern unsafe static void glfwPollEvents();
[DllImport(SSC_libname, EntryPoint = "glfwWaitEvents")] internal extern unsafe static void glfwWaitEvents();
[DllImport(SSC_libname, EntryPoint = "glfwWaitEventsTimeout")] internal extern unsafe static void glfwWaitEventsTimeout(double timeout);
[DllImport(SSC_libname, EntryPoint = "glfwPostEmptyEvent")] internal extern unsafe static void glfwPostEmptyEvent();
[DllImport(SSC_libname, EntryPoint = "glfwGetInputMode")] internal extern unsafe static int glfwGetInputMode(IntPtr window, int mode);
[DllImport(SSC_libname, EntryPoint = "glfwSetInputMode")] internal extern unsafe static void glfwSetInputMode(IntPtr window, int mode, int value);
[DllImport(SSC_libname, EntryPoint = "glfwRawMouseMotionSupported")] internal extern unsafe static int glfwRawMouseMotionSupported();
[DllImport(SSC_libname, EntryPoint = "glfwGetKeyName")] internal extern unsafe static byte* glfwGetKeyName(int key, int scancode);
[DllImport(SSC_libname, EntryPoint = "glfwGetKeyScancode")] internal extern unsafe static int glfwGetKeyScancode(int key);
[DllImport(SSC_libname, EntryPoint = "glfwGetKey")] internal extern unsafe static KeyStatus glfwGetKey(IntPtr window, int key);
[DllImport(SSC_libname, EntryPoint = "glfwGetMouseButton")] internal extern unsafe static int glfwGetMouseButton(IntPtr window, int button);
[DllImport(SSC_libname, EntryPoint = "glfwGetCursorPos")] internal extern unsafe static void glfwGetCursorPos(IntPtr window, double* xpos, double* ypos);
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorPos")] internal extern unsafe static void glfwSetCursorPos(IntPtr window, double xpos, double ypos);
[DllImport(SSC_libname, EntryPoint = "glfwCreateCursor")] internal extern unsafe static GLFWcursor* glfwCreateCursor(GLFWimage* image, int xhot, int yhot);
[DllImport(SSC_libname, EntryPoint = "glfwCreateStandardCursor")] internal extern unsafe static GLFWcursor* glfwCreateStandardCursor(int shape);
[DllImport(SSC_libname, EntryPoint = "glfwDestroyCursor")] internal extern unsafe static void glfwDestroyCursor(GLFWcursor* cursor);
[DllImport(SSC_libname, EntryPoint = "glfwSetCursor")] internal extern unsafe static void glfwSetCursor(IntPtr window, GLFWcursor* cursor);
[DllImport(SSC_libname, EntryPoint = "glfwSetKeyCallback")] internal extern unsafe static GLFWkeyfun glfwSetKeyCallback(IntPtr window, GLFWkeyfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetCharCallback")] internal extern unsafe static GLFWcharfun glfwSetCharCallback(IntPtr window, GLFWcharfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetCharModsCallback")] internal extern unsafe static GLFWcharmodsfun glfwSetCharModsCallback(IntPtr window, GLFWcharmodsfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetMouseButtonCallback")] internal extern unsafe static GLFWmousebuttonfun glfwSetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorPosCallback")] internal extern unsafe static GLFWcursorposfun glfwSetCursorPosCallback(IntPtr window, GLFWcursorposfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorEnterCallback")] internal extern unsafe static GLFWcursorenterfun glfwSetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetScrollCallback")] internal extern unsafe static GLFWscrollfun glfwSetScrollCallback(IntPtr window, GLFWscrollfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwSetDropCallback")] internal extern unsafe static GLFWdropfun glfwSetDropCallback(IntPtr window, GLFWdropfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwJoystickPresent")] internal extern unsafe static int glfwJoystickPresent(int jid);
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickAxes")] internal extern unsafe static float* glfwGetJoystickAxes(int jid, int* count);
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickButtons")] internal extern unsafe static byte* glfwGetJoystickButtons(int jid, int* count);
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickHats")] internal extern unsafe static byte* glfwGetJoystickHats(int jid, int* count);
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickName")] internal extern unsafe static byte* glfwGetJoystickName(int jid);
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickGUID")] internal extern unsafe static byte* glfwGetJoystickGUID(int jid);
[DllImport(SSC_libname, EntryPoint = "glfwSetJoystickUserPointer")] internal extern unsafe static void glfwSetJoystickUserPointer(int jid, void* pointer);
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickUserPointer")] internal extern unsafe static void* glfwGetJoystickUserPointer(int jid);
[DllImport(SSC_libname, EntryPoint = "glfwJoystickIsGamepad")] internal extern unsafe static int glfwJoystickIsGamepad(int jid);
[DllImport(SSC_libname, EntryPoint = "glfwSetJoystickCallback")] internal extern unsafe static GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
[DllImport(SSC_libname, EntryPoint = "glfwUpdateGamepadMappings")] internal extern unsafe static int glfwUpdateGamepadMappings(byte* str);
[DllImport(SSC_libname, EntryPoint = "glfwGetGamepadName")] internal extern unsafe static byte* glfwGetGamepadName(int jid);
[DllImport(SSC_libname, EntryPoint = "glfwGetGamepadState")] internal extern unsafe static int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
[DllImport(SSC_libname, EntryPoint = "glfwSetClipboardString")] internal extern unsafe static void glfwSetClipboardString(IntPtr window, byte* str);
[DllImport(SSC_libname, EntryPoint = "glfwGetClipboardString")] internal extern unsafe static byte* glfwGetClipboardString(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwGetTime")] internal extern unsafe static double glfwGetTime();
[DllImport(SSC_libname, EntryPoint = "glfwSetTime")] internal extern unsafe static void glfwSetTime(double time);
[DllImport(SSC_libname, EntryPoint = "glfwGetTimerValue")] internal extern unsafe static ulong* glfwGetTimerValue();
[DllImport(SSC_libname, EntryPoint = "glfwGetTimerFrequency")] internal extern unsafe static ulong* glfwGetTimerFrequency();
[DllImport(SSC_libname, EntryPoint = "glfwMakeContextCurrent")] internal extern unsafe static void glfwMakeContextCurrent(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwGetCurrentContext")] internal extern unsafe static IntPtr glfwGetCurrentContext();
[DllImport(SSC_libname, EntryPoint = "glfwSwapBuffers")] internal extern unsafe static void glfwSwapBuffers(IntPtr window);
[DllImport(SSC_libname, EntryPoint = "glfwSwapInterval")] internal extern unsafe static void glfwSwapInterval(int interval);
[DllImport(SSC_libname, EntryPoint = "glfwExtensionSupported")] internal extern unsafe static int glfwExtensionSupported(byte* extension);
[DllImport(SSC_libname, EntryPoint = "glfwGetProcAddress", CharSet = CharSet.Ansi)] internal extern unsafe static IntPtr glfwGetProcAddress(string procname);
[DllImport(SSC_libname, EntryPoint = "glfwVulkanSupported")] internal extern unsafe static int glfwVulkanSupported();
[DllImport(SSC_libname, EntryPoint = "glfwGetRequiredInstanceExtensions")] internal extern unsafe static byte** glfwGetRequiredInstanceExtensions(uint* count);
//[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetInstanceProcAddress")] internal extern unsafe static GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, byte* procname);
//[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetPhysicalDevicePresentationSupport")] internal extern unsafe static int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint* queuefamily);
//[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwCreateWindowSurface")] internal extern unsafe static VkResult glfwCreateWindowSurface(VkInstance instance, IntPtr window, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
#endregion
#region api
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int Init() => glfwInit();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Terminate() => glfwTerminate();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void InitHint(int hint, int value) => glfwInitHint(hint, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetVersion(int* major, int* minor, int* rev) => glfwGetVersion(major, minor, rev);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetVersionString() => glfwGetVersionString();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetError(byte** description) => glfwGetError(description);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWerrorfun SetErrorCallback(GLFWerrorfun callback) => glfwSetErrorCallback(callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr* GetMonitors(int* count) => glfwGetMonitors(count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetPrimaryMonitor() => glfwGetPrimaryMonitor();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorPos(IntPtr monitor, int* xpos, int* ypos) => glfwGetMonitorPos(monitor, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height) => glfwGetMonitorWorkarea(monitor, xpos, ypos, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM) => glfwGetMonitorPhysicalSize(monitor, widthMM, heightMM);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale) => glfwGetMonitorContentScale(monitor, xscale, yscale);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetMonitorName(IntPtr monitor) => glfwGetMonitorName(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetMonitorUserPointer(IntPtr monitor, void* pointer) => glfwSetMonitorUserPointer(monitor, pointer);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void* GetMonitorUserPointer(IntPtr monitor) => glfwGetMonitorUserPointer(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWmonitorfun SetMonitorCallback(GLFWmonitorfun callback) => glfwSetMonitorCallback(callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWvidmode* GetVideoModes(IntPtr monitor, int* count) => glfwGetVideoModes(monitor, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWvidmode* GetVideoMode(IntPtr monitor) => glfwGetVideoMode(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetGamma(IntPtr monitor, float gamma) => glfwSetGamma(monitor, gamma);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWgammaramp* GetGammaRamp(IntPtr monitor) => glfwGetGammaRamp(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp) => glfwSetGammaRamp(monitor, ramp);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void DefaultWindowHints() => glfwDefaultWindowHints();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WindowHint(int hint, int value) => glfwWindowHint(hint, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WindowHintString(int hint, byte* value) => glfwWindowHintString(hint, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr CreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share) => glfwCreateWindow(width, height, title, monitor, share);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void DestroyWindow(IntPtr window) => glfwDestroyWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int WindowShouldClose(IntPtr window) => glfwWindowShouldClose(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowShouldClose(IntPtr window, int value) => glfwSetWindowShouldClose(window, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowTitle(IntPtr window, byte* title) => glfwSetWindowTitle(window, title);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowIcon(IntPtr window, int count, GLFWimage* images) => glfwSetWindowIcon(window, count, images);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowPos(IntPtr window, int* xpos, int* ypos) => glfwGetWindowPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowPos(IntPtr window, int xpos, int ypos) => glfwSetWindowPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowSize(IntPtr window, int* width, int* height) => glfwGetWindowSize(window, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight) => glfwSetWindowSizeLimits(window, minwidth, minheight, maxwidth, maxheight);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowAspectRatio(IntPtr window, int numer, int denom) => glfwSetWindowAspectRatio(window, numer, denom);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowSize(IntPtr window, int width, int height) => glfwSetWindowSize(window, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetFramebufferSize(IntPtr window, int* width, int* height) => glfwGetFramebufferSize(window, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom) => glfwGetWindowFrameSize(window, left, top, right, bottom);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowContentScale(IntPtr window, float* xscale, float* yscale) => glfwGetWindowContentScale(window, xscale, yscale);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe float GetWindowOpacity(IntPtr window) => glfwGetWindowOpacity(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowOpacity(IntPtr window, float opacity) => glfwSetWindowOpacity(window, opacity);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void IconifyWindow(IntPtr window) => glfwIconifyWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void RestoreWindow(IntPtr window) => glfwRestoreWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void MaximizeWindow(IntPtr window) => glfwMaximizeWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void ShowWindow(IntPtr window) => glfwShowWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void HideWindow(IntPtr window) => glfwHideWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void FocusWindow(IntPtr window) => glfwFocusWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void RequestWindowAttention(IntPtr window) => glfwRequestWindowAttention(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetWindowMonitor(IntPtr window) => glfwGetWindowMonitor(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate) => glfwSetWindowMonitor(window, monitor, xpos, ypos, width, height, refreshRate);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetWindowAttrib(IntPtr window, int attrib) => glfwGetWindowAttrib(window, attrib);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowAttrib(IntPtr window, int attrib, int value) => glfwSetWindowAttrib(window, attrib, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowUserPointer(IntPtr window, void* pointer) => glfwSetWindowUserPointer(window, pointer);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void* GetWindowUserPointer(IntPtr window) => glfwGetWindowUserPointer(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowposfun SetWindowPosCallback(IntPtr window, GLFWwindowposfun callback) => glfwSetWindowPosCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowsizefun SetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback) => glfwSetWindowSizeCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowclosefun SetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback) => glfwSetWindowCloseCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowrefreshfun SetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback) => glfwSetWindowRefreshCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowfocusfun SetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback) => glfwSetWindowFocusCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowiconifyfun SetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback) => glfwSetWindowIconifyCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowmaximizefun SetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback) => glfwSetWindowMaximizeCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe FramebuffersizeHandler SetFramebufferSizeCallback(IntPtr window, IntPtr callback) => glfwSetFramebufferSizeCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowcontentscalefun SetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback) => glfwSetWindowContentScaleCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void PollEvents() => glfwPollEvents();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WaitEvents() => glfwWaitEvents();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WaitEventsTimeout(double timeout) => glfwWaitEventsTimeout(timeout);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void PostEmptyEvent() => glfwPostEmptyEvent();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetInputMode(IntPtr window, int mode) => glfwGetInputMode(window, mode);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetInputMode(IntPtr window, int mode, int value) => glfwSetInputMode(window, mode, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int RawMouseMotionSupported() => glfwRawMouseMotionSupported();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetKeyName(int key, int scancode) => glfwGetKeyName(key, scancode);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetKeyScancode(int key) => glfwGetKeyScancode(key);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe KeyStatus GetKey(IntPtr window, int key) => glfwGetKey(window, key);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetMouseButton(IntPtr window, int button) => glfwGetMouseButton(window, button);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetCursorPos(IntPtr window, double* xpos, double* ypos) => glfwGetCursorPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetCursorPos(IntPtr window, double xpos, double ypos) => glfwSetCursorPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursor* CreateCursor(GLFWimage* image, int xhot, int yhot) => glfwCreateCursor(image, xhot, yhot);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursor* CreateStandardCursor(int shape) => glfwCreateStandardCursor(shape);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void DestroyCursor(GLFWcursor* cursor) => glfwDestroyCursor(cursor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetCursor(IntPtr window, GLFWcursor* cursor) => glfwSetCursor(window, cursor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWkeyfun SetKeyCallback(IntPtr window, GLFWkeyfun callback) => glfwSetKeyCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcharfun SetCharCallback(IntPtr window, GLFWcharfun callback) => glfwSetCharCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcharmodsfun SetCharModsCallback(IntPtr window, GLFWcharmodsfun callback) => glfwSetCharModsCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWmousebuttonfun SetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback) => glfwSetMouseButtonCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursorposfun SetCursorPosCallback(IntPtr window, GLFWcursorposfun callback) => glfwSetCursorPosCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursorenterfun SetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback) => glfwSetCursorEnterCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWscrollfun SetScrollCallback(IntPtr window, GLFWscrollfun callback) => glfwSetScrollCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWdropfun SetDropCallback(IntPtr window, GLFWdropfun callback) => glfwSetDropCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int JoystickPresent(int jid) => glfwJoystickPresent(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe float* GetJoystickAxes(int jid, int* count) => glfwGetJoystickAxes(jid, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickButtons(int jid, int* count) => glfwGetJoystickButtons(jid, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickHats(int jid, int* count) => glfwGetJoystickHats(jid, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickName(int jid) => glfwGetJoystickName(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickGUID(int jid) => glfwGetJoystickGUID(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetJoystickUserPointer(int jid, void* pointer) => glfwSetJoystickUserPointer(jid, pointer);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void* GetJoystickUserPointer(int jid) => glfwGetJoystickUserPointer(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int JoystickIsGamepad(int jid) => glfwJoystickIsGamepad(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWjoystickfun SetJoystickCallback(GLFWjoystickfun callback) => glfwSetJoystickCallback(callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int UpdateGamepadMappings(byte* str) => glfwUpdateGamepadMappings(str);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetGamepadName(int jid) => glfwGetGamepadName(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetGamepadState(int jid, GLFWgamepadstate* state) => glfwGetGamepadState(jid, state);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetClipboardString(IntPtr window, byte* str) => glfwSetClipboardString(window, str);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetClipboardString(IntPtr window) => glfwGetClipboardString(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe double GetTime() => glfwGetTime();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetTime(double time) => glfwSetTime(time);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe ulong* GetTimerValue() => glfwGetTimerValue();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe ulong* GetTimerFrequency() => glfwGetTimerFrequency();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void MakeContextCurrent(IntPtr window) => glfwMakeContextCurrent(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetCurrentContext() => glfwGetCurrentContext();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SwapBuffers(IntPtr window) => glfwSwapBuffers(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SwapInterval(int interval) => glfwSwapInterval(interval);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int ExtensionSupported(byte* extension) => glfwExtensionSupported(extension);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetProcAddress(string procname) => glfwGetProcAddress(procname);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int VulkanSupported() => glfwVulkanSupported();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte** GetRequiredInstanceExtensions(uint* count) => glfwGetRequiredInstanceExtensions(count);
//[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWvkproc GetInstanceProcAddress(VkInstance instance, byte* procname)=>glfwGetInstanceProcAddress(instance, procname)
//[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint* queuefamily) => glfwGetPhysicalDevicePresentationSupport(instance, device, queuefamily);
//[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe VkResult CreateWindowSurface(VkInstance instance, IntPtr window, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface)=>glfwCreateWindowSurface(instance, window, allocator, surface)
#endregion
}
internal class glFramework_Delegate : IglFramework
{
#region glfw api define
internal static glfwCreateCursor glfw_CreateCursor;
internal static glfwCreateStandardCursor glfw_CreateStandardCursor;
internal static glfwCreateWindow glfw_CreateWindow;
internal static glfwDefaultWindowHints glfw_DefaultWindowHints;
internal static glfwDestroyCursor glfw_DestroyCursor;
internal static glfwDestroyWindow glfw_DestroyWindow;
internal static glfwExtensionSupported glfw_ExtensionSupported;
internal static glfwFocusWindow glfw_FocusWindow;
internal static glfwGetClipboardString glfw_GetClipboardString;
internal static glfwGetCurrentContext glfw_GetCurrentContext;
internal static glfwGetCursorPos glfw_GetCursorPos;
internal static glfwGetError glfw_GetError;
internal static glfwGetFramebufferSize glfw_GetFramebufferSize;
internal static glfwGetGamepadName glfw_GetGamepadName;
internal static glfwGetGamepadState glfw_GetGamepadState;
internal static glfwGetGammaRamp glfw_GetGammaRamp;
internal static glfwGetInputMode glfw_GetInputMode;
internal static glfwGetJoystickAxes glfw_GetJoystickAxes;
internal static glfwGetJoystickButtons glfw_GetJoystickButtons;
internal static glfwGetJoystickGUID glfw_GetJoystickGUID;
internal static glfwGetJoystickHats glfw_GetJoystickHats;
internal static glfwGetJoystickName glfw_GetJoystickName;
internal static glfwGetJoystickUserPointer glfw_GetJoystickUserPointer;
internal static glfwGetKey glfw_GetKey;
internal static glfwGetKeyName glfw_GetKeyName;
internal static glfwGetKeyScancode glfw_GetKeyScancode;
internal static glfwGetMonitorContentScale glfw_GetMonitorContentScale;
internal static glfwGetMonitorName glfw_GetMonitorName;
internal static glfwGetMonitorPhysicalSize glfw_GetMonitorPhysicalSize;
internal static glfwGetMonitorPos glfw_GetMonitorPos;
internal static glfwGetMonitors glfw_GetMonitors;
internal static glfwGetMonitorUserPointer glfw_GetMonitorUserPointer;
internal static glfwGetMonitorWorkarea glfw_GetMonitorWorkarea;
internal static glfwGetMouseButton glfw_GetMouseButton;
internal static glfwGetPrimaryMonitor glfw_GetPrimaryMonitor;
internal static glfwGetProcAddress glfw_GetProcAddress;
internal static glfwGetRequiredInstanceExtensions glfw_GetRequiredInstanceExtensions;
internal static glfwGetTime glfw_GetTime;
internal static glfwGetTimerFrequency glfw_GetTimerFrequency;
internal static glfwGetTimerValue glfw_GetTimerValue;
internal static glfwGetVersion glfw_GetVersion;
internal static glfwGetVersionString glfw_GetVersionString;
internal static glfwGetVideoMode glfw_GetVideoMode;
internal static glfwGetVideoModes glfw_GetVideoModes;
internal static glfwGetWindowAttrib glfw_GetWindowAttrib;
internal static glfwGetWindowContentScale glfw_GetWindowContentScale;
internal static glfwGetWindowFrameSize glfw_GetWindowFrameSize;
internal static glfwGetWindowMonitor glfw_GetWindowMonitor;
internal static glfwGetWindowOpacity glfw_GetWindowOpacity;
internal static glfwGetWindowPos glfw_GetWindowPos;
internal static glfwGetWindowSize glfw_GetWindowSize;
internal static glfwGetWindowUserPointer glfw_GetWindowUserPointer;
internal static glfwHideWindow glfw_HideWindow;
internal static glfwIconifyWindow glfw_IconifyWindow;
internal static glfwInit glfw_Init;
internal static glfwInitHint glfw_InitHint;
internal static glfwJoystickIsGamepad glfw_JoystickIsGamepad;
internal static glfwJoystickPresent glfw_JoystickPresent;
internal static glfwMakeContextCurrent glfw_MakeContextCurrent;
internal static glfwMaximizeWindow glfw_MaximizeWindow;
internal static glfwPollEvents glfw_PollEvents;
internal static glfwPostEmptyEvent glfw_PostEmptyEvent;
internal static glfwRawMouseMotionSupported glfw_RawMouseMotionSupported;
internal static glfwRequestWindowAttention glfw_RequestWindowAttention;
internal static glfwRestoreWindow glfw_RestoreWindow;
internal static glfwSetCharCallback glfw_SetCharCallback;
internal static glfwSetCharModsCallback glfw_SetCharModsCallback;
internal static glfwSetClipboardString glfw_SetClipboardString;
internal static glfwSetCursor glfw_SetCursor;
internal static glfwSetCursorEnterCallback glfw_SetCursorEnterCallback;
internal static glfwSetCursorPos glfw_SetCursorPos;
internal static glfwSetCursorPosCallback glfw_SetCursorPosCallback;
internal static glfwSetDropCallback glfw_SetDropCallback;
internal static glfwSetErrorCallback glfw_SetErrorCallback;
internal static glfwSetFramebufferSizeCallback glfw_SetFramebufferSizeCallback;
internal static glfwSetGamma glfw_SetGamma;
internal static glfwSetGammaRamp glfw_SetGammaRamp;
internal static glfwSetInputMode glfw_SetInputMode;
internal static glfwSetJoystickCallback glfw_SetJoystickCallback;
internal static glfwSetJoystickUserPointer glfw_SetJoystickUserPointer;
internal static glfwSetKeyCallback glfw_SetKeyCallback;
internal static glfwSetMonitorCallback glfw_SetMonitorCallback;
internal static glfwSetMonitorUserPointer glfw_SetMonitorUserPointer;
internal static glfwSetMouseButtonCallback glfw_SetMouseButtonCallback;
internal static glfwSetScrollCallback glfw_SetScrollCallback;
internal static glfwSetTime glfw_SetTime;
internal static glfwSetWindowAspectRatio glfw_SetWindowAspectRatio;
internal static glfwSetWindowAttrib glfw_SetWindowAttrib;
internal static glfwSetWindowCloseCallback glfw_SetWindowCloseCallback;
internal static glfwSetWindowContentScaleCallback glfw_SetWindowContentScaleCallback;
internal static glfwSetWindowFocusCallback glfw_SetWindowFocusCallback;
internal static glfwSetWindowIcon glfw_SetWindowIcon;
internal static glfwSetWindowIconifyCallback glfw_SetWindowIconifyCallback;
internal static glfwSetWindowMaximizeCallback glfw_SetWindowMaximizeCallback;
internal static glfwSetWindowMonitor glfw_SetWindowMonitor;
internal static glfwSetWindowOpacity glfw_SetWindowOpacity;
internal static glfwSetWindowPos glfw_SetWindowPos;
internal static glfwSetWindowPosCallback glfw_SetWindowPosCallback;
internal static glfwSetWindowRefreshCallback glfw_SetWindowRefreshCallback;
internal static glfwSetWindowShouldClose glfw_SetWindowShouldClose;
internal static glfwSetWindowSize glfw_SetWindowSize;
internal static glfwSetWindowSizeCallback glfw_SetWindowSizeCallback;
internal static glfwSetWindowSizeLimits glfw_SetWindowSizeLimits;
internal static glfwSetWindowTitle glfw_SetWindowTitle;
internal static glfwSetWindowUserPointer glfw_SetWindowUserPointer;
internal static glfwShowWindow glfw_ShowWindow;
internal static glfwSwapBuffers glfw_SwapBuffers;
internal static glfwSwapInterval glfw_SwapInterval;
internal static glfwTerminate glfw_Terminate;
internal static glfwUpdateGamepadMappings glfw_UpdateGamepadMappings;
internal static glfwVulkanSupported glfw_VulkanSupported;
internal static glfwWaitEvents glfw_WaitEvents;
internal static glfwWaitEventsTimeout glfw_WaitEventsTimeout;
internal static glfwWindowHint glfw_WindowHint;
internal static glfwWindowHintString glfw_WindowHintString;
internal static glfwWindowShouldClose glfw_WindowShouldClose;
//internal [NotNull] static glfwGetInstanceProcAddress glfw_GetInstanceProcAddress;
//internal [NotNull] static glfwGetPhysicalDevicePresentationSupport glfw_GetPhysicalDevicePresentationSupport;
//internal [NotNull] static glfwCreateWindowSurface glfw_CreateWindowSurface;
#endregion
#region api
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int Init() => glfw_Init();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Terminate() => glfw_Terminate();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void InitHint(int hint, int value) => glfw_InitHint(hint, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetVersion(int* major, int* minor, int* rev) => glfw_GetVersion(major, minor, rev);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetVersionString() => glfw_GetVersionString();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetError(byte** description) => glfw_GetError(description);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWerrorfun SetErrorCallback(GLFWerrorfun callback) => glfw_SetErrorCallback(callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr* GetMonitors(int* count) => glfw_GetMonitors(count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetPrimaryMonitor() => glfw_GetPrimaryMonitor();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorPos(IntPtr monitor, int* xpos, int* ypos) => glfw_GetMonitorPos(monitor, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height) => glfw_GetMonitorWorkarea(monitor, xpos, ypos, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM) => glfw_GetMonitorPhysicalSize(monitor, widthMM, heightMM);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale) => glfw_GetMonitorContentScale(monitor, xscale, yscale);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetMonitorName(IntPtr monitor) => glfw_GetMonitorName(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetMonitorUserPointer(IntPtr monitor, void* pointer) => glfw_SetMonitorUserPointer(monitor, pointer);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void* GetMonitorUserPointer(IntPtr monitor) => glfw_GetMonitorUserPointer(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWmonitorfun SetMonitorCallback(GLFWmonitorfun callback) => glfw_SetMonitorCallback(callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWvidmode* GetVideoModes(IntPtr monitor, int* count) => glfw_GetVideoModes(monitor, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWvidmode* GetVideoMode(IntPtr monitor) => glfw_GetVideoMode(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetGamma(IntPtr monitor, float gamma) => glfw_SetGamma(monitor, gamma);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWgammaramp* GetGammaRamp(IntPtr monitor) => glfw_GetGammaRamp(monitor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp) => glfw_SetGammaRamp(monitor, ramp);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void DefaultWindowHints() => glfw_DefaultWindowHints();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WindowHint(int hint, int value) => glfw_WindowHint(hint, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WindowHintString(int hint, byte* value) => glfw_WindowHintString(hint, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr CreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share) => glfw_CreateWindow(width, height, title, monitor, share);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void DestroyWindow(IntPtr window) => glfw_DestroyWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int WindowShouldClose(IntPtr window) => glfw_WindowShouldClose(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowShouldClose(IntPtr window, int value) => glfw_SetWindowShouldClose(window, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowTitle(IntPtr window, byte* title) => glfw_SetWindowTitle(window, title);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowIcon(IntPtr window, int count, GLFWimage* images) => glfw_SetWindowIcon(window, count, images);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowPos(IntPtr window, int* xpos, int* ypos) => glfw_GetWindowPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowPos(IntPtr window, int xpos, int ypos) => glfw_SetWindowPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowSize(IntPtr window, int* width, int* height) => glfw_GetWindowSize(window, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight) => glfw_SetWindowSizeLimits(window, minwidth, minheight, maxwidth, maxheight);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowAspectRatio(IntPtr window, int numer, int denom) => glfw_SetWindowAspectRatio(window, numer, denom);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowSize(IntPtr window, int width, int height) => glfw_SetWindowSize(window, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetFramebufferSize(IntPtr window, int* width, int* height) => glfw_GetFramebufferSize(window, width, height);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom) => glfw_GetWindowFrameSize(window, left, top, right, bottom);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetWindowContentScale(IntPtr window, float* xscale, float* yscale) => glfw_GetWindowContentScale(window, xscale, yscale);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe float GetWindowOpacity(IntPtr window) => glfw_GetWindowOpacity(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowOpacity(IntPtr window, float opacity) => glfw_SetWindowOpacity(window, opacity);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void IconifyWindow(IntPtr window) => glfw_IconifyWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void RestoreWindow(IntPtr window) => glfw_RestoreWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void MaximizeWindow(IntPtr window) => glfw_MaximizeWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void ShowWindow(IntPtr window) => glfw_ShowWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void HideWindow(IntPtr window) => glfw_HideWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void FocusWindow(IntPtr window) => glfw_FocusWindow(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void RequestWindowAttention(IntPtr window) => glfw_RequestWindowAttention(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetWindowMonitor(IntPtr window) => glfw_GetWindowMonitor(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate) => glfw_SetWindowMonitor(window, monitor, xpos, ypos, width, height, refreshRate);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetWindowAttrib(IntPtr window, int attrib) => glfw_GetWindowAttrib(window, attrib);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowAttrib(IntPtr window, int attrib, int value) => glfw_SetWindowAttrib(window, attrib, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetWindowUserPointer(IntPtr window, void* pointer) => glfw_SetWindowUserPointer(window, pointer);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void* GetWindowUserPointer(IntPtr window) => glfw_GetWindowUserPointer(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowposfun SetWindowPosCallback(IntPtr window, GLFWwindowposfun callback) => glfw_SetWindowPosCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowsizefun SetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback) => glfw_SetWindowSizeCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowclosefun SetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback) => glfw_SetWindowCloseCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowrefreshfun SetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback) => glfw_SetWindowRefreshCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowfocusfun SetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback) => glfw_SetWindowFocusCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowiconifyfun SetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback) => glfw_SetWindowIconifyCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowmaximizefun SetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback) => glfw_SetWindowMaximizeCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe FramebuffersizeHandler SetFramebufferSizeCallback(IntPtr window, IntPtr callback) => glfw_SetFramebufferSizeCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWwindowcontentscalefun SetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback) => glfw_SetWindowContentScaleCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void PollEvents() => glfw_PollEvents();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WaitEvents() => glfw_WaitEvents();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void WaitEventsTimeout(double timeout) => glfw_WaitEventsTimeout(timeout);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void PostEmptyEvent() => glfw_PostEmptyEvent();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetInputMode(IntPtr window, int mode) => glfw_GetInputMode(window, mode);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetInputMode(IntPtr window, int mode, int value) => glfw_SetInputMode(window, mode, value);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int RawMouseMotionSupported() => glfw_RawMouseMotionSupported();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetKeyName(int key, int scancode) => glfw_GetKeyName(key, scancode);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetKeyScancode(int key) => glfw_GetKeyScancode(key);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe KeyStatus GetKey(IntPtr window, int key) => glfw_GetKey(window, key);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetMouseButton(IntPtr window, int button) => glfw_GetMouseButton(window, button);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetCursorPos(IntPtr window, double* xpos, double* ypos) => glfw_GetCursorPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetCursorPos(IntPtr window, double xpos, double ypos) => glfw_SetCursorPos(window, xpos, ypos);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursor* CreateCursor(GLFWimage* image, int xhot, int yhot) => glfw_CreateCursor(image, xhot, yhot);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursor* CreateStandardCursor(int shape) => glfw_CreateStandardCursor(shape);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void DestroyCursor(GLFWcursor* cursor) => glfw_DestroyCursor(cursor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetCursor(IntPtr window, GLFWcursor* cursor) => glfw_SetCursor(window, cursor);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWkeyfun SetKeyCallback(IntPtr window, GLFWkeyfun callback) => glfw_SetKeyCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcharfun SetCharCallback(IntPtr window, GLFWcharfun callback) => glfw_SetCharCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcharmodsfun SetCharModsCallback(IntPtr window, GLFWcharmodsfun callback) => glfw_SetCharModsCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWmousebuttonfun SetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback) => glfw_SetMouseButtonCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursorposfun SetCursorPosCallback(IntPtr window, GLFWcursorposfun callback) => glfw_SetCursorPosCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWcursorenterfun SetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback) => glfw_SetCursorEnterCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWscrollfun SetScrollCallback(IntPtr window, GLFWscrollfun callback) => glfw_SetScrollCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWdropfun SetDropCallback(IntPtr window, GLFWdropfun callback) => glfw_SetDropCallback(window, callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int JoystickPresent(int jid) => glfw_JoystickPresent(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe float* GetJoystickAxes(int jid, int* count) => glfw_GetJoystickAxes(jid, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickButtons(int jid, int* count) => glfw_GetJoystickButtons(jid, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickHats(int jid, int* count) => glfw_GetJoystickHats(jid, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickName(int jid) => glfw_GetJoystickName(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetJoystickGUID(int jid) => glfw_GetJoystickGUID(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetJoystickUserPointer(int jid, void* pointer) => glfw_SetJoystickUserPointer(jid, pointer);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void* GetJoystickUserPointer(int jid) => glfw_GetJoystickUserPointer(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int JoystickIsGamepad(int jid) => glfw_JoystickIsGamepad(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWjoystickfun SetJoystickCallback(GLFWjoystickfun callback) => glfw_SetJoystickCallback(callback);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int UpdateGamepadMappings(byte* str) => glfw_UpdateGamepadMappings(str);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetGamepadName(int jid) => glfw_GetGamepadName(jid);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetGamepadState(int jid, GLFWgamepadstate* state) => glfw_GetGamepadState(jid, state);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetClipboardString(IntPtr window, byte* str) => glfw_SetClipboardString(window, str);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte* GetClipboardString(IntPtr window) => glfw_GetClipboardString(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe double GetTime() => glfw_GetTime();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetTime(double time) => glfw_SetTime(time);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe ulong* GetTimerValue() => glfw_GetTimerValue();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe ulong* GetTimerFrequency() => glfw_GetTimerFrequency();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void MakeContextCurrent(IntPtr window) => glfw_MakeContextCurrent(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetCurrentContext() => glfw_GetCurrentContext();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SwapBuffers(IntPtr window) => glfw_SwapBuffers(window);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SwapInterval(int interval) => glfw_SwapInterval(interval);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int ExtensionSupported(byte* extension) => glfw_ExtensionSupported(extension);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe IntPtr GetProcAddress(string procname) => glfw_GetProcAddress(procname);
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int VulkanSupported() => glfw_VulkanSupported();
[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe byte** GetRequiredInstanceExtensions(uint* count) => glfw_GetRequiredInstanceExtensions(count);
//[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe GLFWvkproc GetInstanceProcAddress(VkInstance instance, byte* procname)=>glfwGetInstanceProcAddress(instance, procname)
//[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int GetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint* queuefamily) => glfw_GetPhysicalDevicePresentationSupport(instance, device, queuefamily);
//[MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe VkResult CreateWindowSurface(VkInstance instance, IntPtr window, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface)=>glfwCreateWindowSurface(instance, window, allocator, surface)
#endregion
}
}
@@ -752,7 +752,7 @@ namespace StgSharp.Graphics
/// <returns>The funtion pointer of the api in form of <see cref="IntPtr"/></returns>
public static IntPtr LoadGLfunc(string name)
{
IntPtr ret = InternalIO.glfw.GetProcAddress(name);
IntPtr ret = InternalIO.glfwGetProcAddress(name);
if (ret == default)
{
InternalIO.InternalAppendLog(
@@ -984,7 +984,7 @@ namespace StgSharp.Graphics
#region load
contextPtr->glBeginQuery = (delegate*<uint, uint, void>)load("glBeginQuery");
contextPtr->glBindBuffer = (delegate*<uint, uint, void>)load("glBindBuffer");
contextPtr->glBufferData = (delegate*<uint, UIntPtr, void*, uint, void>)load("glBufferData");
contextPtr->glBufferData = (delegate*<uint, IntPtr, void*, uint, void>)load("glBufferData");
contextPtr->glBufferSubData = (delegate*<uint, IntPtr, UIntPtr, void*, void>)load("glBufferSubData");
contextPtr->glDeleteBuffers = (delegate*<uint, uint*, void>)load("glDeleteBuffers");
contextPtr->glDeleteQueries = (delegate*<uint, uint*, void>)load("glDeleteQueries");
@@ -1107,7 +1107,7 @@ namespace StgSharp.Graphics
contextPtr->glVertexAttrib4ubv = (delegate*<uint, byte*, void>)load("glVertexAttrib4ubv");
contextPtr->glVertexAttrib4uiv = (delegate*<uint, uint*, void>)load("glVertexAttrib4uiv");
contextPtr->glVertexAttrib4usv = (delegate*<uint, ushort*, void>)load("glVertexAttrib4usv");
contextPtr->glVertexAttribPointer = (delegate*<uint, int, uint, bool, uint, void*, void>)load("glVertexAttribPointer");
contextPtr->glVertexAttribPointer = (delegate*<uint, int, uint, int, uint, void*, void>)load("glVertexAttribPointer");
#endregion
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.0 APIs");
+15 -23
View File
@@ -58,7 +58,7 @@ namespace StgSharp.Graphics
/// </summary>
/// <param name="type">Type of texture to bind</param>
/// <param name="texture">Sign of texture</param>
void BindTexture(uint type, uint texture);
void BindTexture(uint type, glHandle texture);
/// <summary>
/// Same function as OpenGL api, glBindVertexArray
@@ -145,43 +145,41 @@ namespace StgSharp.Graphics
/// <param name="count"></param>
/// <param name="type"></param>
/// <param name="ptr"></param>
void DrawElements(GepmetryType mode, uint count, Type type, IntPtr ptr);
void DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr);
/// <summary>
/// Same fucntion as the OpenGL api glGenBuffers
/// </summary>
/// <param name="count"></param>
/// <param name="handleSet"></param>
unsafe void GenBuffers(uint count, glHandleSet handleSet);
/// <returns></returns>
unsafe glHandleSet GenBuffers(int count);
/// <summary>
/// Same fucnction as OpenGL api glGenTextures.
/// </summary>
/// <param name="count">amount of textures to generate</param>
/// <param name="handleSet">Handle of texture</param>
unsafe void GenTextures(uint count, glHandleSet handleSet);
unsafe glHandleSet GenTextures(int count);
/// <summary>
/// Same fucntion as OpenGL api, glGenVertexArray
/// </summary>
/// <param name="count">Amount of vao to be generated</param>
/// <param name="handleSet">Handle of vao sign array</param>
unsafe void GenVertexArrays(uint count, glHandleSet handleSet);
unsafe glHandleSet GenVertexArrays(int count);
void GetGraphicError();
/// <summary>
/// Same fucntion as OpenGL api, glGetUniformLocation
/// </summary>
/// <param name="program">Shader program to find the uniform</param>
/// <param name="ptr">Pointer to byte array of name <see cref="string"/> of the uniform </param>
/// <param name="name">Name of the uniform </param>
/// <returns></returns>
unsafe int GetUniformLocation(uint program, byte* ptr);
unsafe glSHandle GetUniformLocation(glHandle program, string name);
bool GetWindowShouldClose(Form form);
/// <summary>
/// Make the OpenGL context of a vertain <see cref="Form"/> as the activated OpenGL context.
/// Make the OpenGL context of a certain <see cref="Form"/> as the activated OpenGL context.
/// </summary>
/// <param name="form"></param>
void MakeContexCurrent(Form form);
@@ -190,8 +188,6 @@ namespace StgSharp.Graphics
void SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible;
internal void SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler);
/// <summary>
/// Set data value to a float <see cref="Uniform{T,U,V,W}"/>,
/// all types of parameters are float.
@@ -263,11 +259,7 @@ namespace StgSharp.Graphics
/// <param name="normalized"></param>
/// <param name="stride">Pixels stride of each sets of data</param>
/// <param name="pointer"></param>
void SetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer);
void SetWindowShouldClose(Form form, bool mark);
void SwapBuffers(Form form);
void SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer);
/// <summary>
/// Same function as OpenGL api glTexImage2d
@@ -279,8 +271,8 @@ namespace StgSharp.Graphics
/// <param name="height">height of image</param>
/// <param name="format">color channels of this image</param>
/// <param name="type">how this image express each pixel</param>
/// <param name="pixels">pointer to data array of pixels</param>
unsafe void TextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels);
/// <param name="pixels">data array of pixels</param>
unsafe void TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels) where T : struct;
/// <summary>
/// Same fucntion as OpenGL api glTexParameteri
@@ -288,13 +280,13 @@ namespace StgSharp.Graphics
/// <param name="target">texture target to set parameters</param>
/// <param name="pname">name of parameter</param>
/// <param name="param">value of parameter</param>
void TextureParameter(uint target, uint pname, int param);
void TextureParameter(int target, uint pname, int param);
/// <summary>
/// Same fucntion as OpenGL api glUseShader.
/// </summary>
/// <param name="program">Sign of program to be used</param>
void UseProgram(uint program);
void UseProgram(glHandle program);
/// <summary>
/// Same function as the OpenGL api, glViewPort
+53 -35
View File
@@ -4,7 +4,6 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
@@ -51,6 +50,17 @@ namespace StgSharp.Logic
paramQueue.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(uint u0, uint u1, uint u2)
{
M128 m = default;
m.UInt32[0] = u0;
m.UInt32[1] = u1;
m.UInt32[2] = u2;
paramQueue.Enqueue(m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(float f0, float f1, float f2, float f3)
{
@@ -139,28 +149,14 @@ namespace StgSharp.Logic
{
paramQueue.TryDequeue(out m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out glHandle handle)
public void TryDequeue(out Vec4d v)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
M128 m;
if (paramQueue.TryDequeue(out m))
{
handle.valuePtr = (uint*)ret.IntPtr0;
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out glHandle handle, out glHandle handle1)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
{
handle.valuePtr = (uint*)ret.IntPtr0;
handle1.valuePtr = (uint*)ret.IntPtr1;
v = *(Vec4d*)&m;
}
else
{
@@ -168,6 +164,7 @@ namespace StgSharp.Logic
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out int i0)
{
@@ -182,6 +179,7 @@ namespace StgSharp.Logic
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out int i0, out int i1)
{
@@ -231,21 +229,6 @@ namespace StgSharp.Logic
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out glHandle handle)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
{
handle = ret.UInt32[0];
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out IntPtr p)
{
@@ -327,6 +310,41 @@ namespace StgSharp.Logic
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out uint u0, out uint u1, out uint u2)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
{
u0 = ret.UInt32[0];
u1 = ret.UInt32[1];
u2 = ret.UInt32[2];
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TryDequeue(out uint u0, out uint u1, out uint u2, out uint u3)
{
M128 ret;
if (paramQueue.TryDequeue(out ret))
{
u0 = ret.UInt32[0];
u1 = ret.UInt32[1];
u2 = ret.UInt32[2];
u3 = ret.UInt32[3];
}
else
{
InternalIO.InternalWriteLog("No param in buffer when calling gl function.", LogType.Error);
throw new Exception();
}
}
internal void SetContext(GLcontext* p)
{
context = p;
+21 -23
View File
@@ -4,12 +4,10 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
/// <summary>
/// A two dimension vector defined by two elements.
/// Vec2Ds in StgSharp are defaultly usaed as colum vector.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct Vec2d
{
@@ -21,10 +19,17 @@ namespace StgSharp.Math
[FieldOffset(0)]
internal Vector4 vec;
[FieldOffset(0)]
internal Vector2 v;
public Vec2d(float x, float y)
{
X = x; Y = y;
v = new Vector2(x, y);
}
internal Vec2d(Vector2 vec)
{
v = vec;
}
public static Vec2d Zero
@@ -32,43 +37,36 @@ namespace StgSharp.Math
get { return new Vec2d(0, 0); }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec2d operator +(Vec2d vec1, Vec2d vec2)
public static Vec2d Unit
{
return new Vec2d(
vec1.X + vec2.X,
vec1.Y + vec2.Y
);
get { return new Vec2d(1, 1); }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec2d operator -(Vec2d vec1, Vec2d vec2)
public static Vec2d operator +(Vec2d left, Vec2d right)
{
return new Vec2d(
vec1.X - vec2.X,
vec1.Y - vec2.Y
);
return new Vec2d(left.v + right.v);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec2d operator -(Vec2d left, Vec2d right)
{
return new Vec2d(left.v - right.v);
}
public static Vec2d operator *(Vec2d vec, float value)
{
return new Vec2d(
vec.X * value,
vec.Y * value
);
return new Vec2d(vec.v * value);
}
public static Vec2d operator /(Vec2d vec, float value)
{
return new Vec2d(
vec.X / value,
vec.Y / value
);
return new Vec2d(vec.v / value);
}
public static bool operator ==(Vec2d left, Vec2d right)
{
return left.X == right.X && left.Y == right.Y;
return left.v == right.v;
}
public static bool operator !=(Vec2d left, Vec2d right)
+16 -27
View File
@@ -3,6 +3,7 @@ using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
namespace StgSharp.Math
{
@@ -11,6 +12,8 @@ namespace StgSharp.Math
{
[FieldOffset(0)]
internal Vector4 vec;
[FieldOffset(0)]
internal Vector3 v;
[FieldOffset(0)] public float X;
[FieldOffset(4)] public float Y;
@@ -28,7 +31,7 @@ namespace StgSharp.Math
#if NET5_0_OR_GREATER
Unsafe.SkipInit(out vec);
#endif
X = x; Y = y; Z = z;
v = new Vector3(x, y, z);
}
internal vec3d(Vector4 vector)
@@ -36,6 +39,11 @@ namespace StgSharp.Math
vec = vector;
}
internal vec3d(Vector3 vector)
{
v = vector;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Dot(vec3d right)
{
@@ -76,61 +84,42 @@ namespace StgSharp.Math
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec3d operator -(vec3d left, vec3d right)
{
return new vec3d(
left.X - right.X,
left.Y - right.Y,
left.Z - right.Z
);
return new vec3d(left.v - right.v);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec3d operator *(vec3d vec, float value)
{
return new vec3d(
vec.X * value,
vec.Y * value,
vec.Z * value
);
return new vec3d(vec.v * value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec3d operator /(vec3d vec, float value)
{
return new vec3d(
vec.X / value,
vec.Y / value,
vec.Z / value
);
return new vec3d(vec.v / value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float operator *(vec3d left, vec3d right)
{
return
left.X * right.X +
left.Y * right.Y +
left.Z * right.Z;
return Vector3.Dot(left.v, right.v);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(vec3d left, vec3d right)
{
return left.X == right.X
&& left.Y == right.Y
&& left.Z == right.Z;
return left.v == right.v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(vec3d left, vec3d right)
{
return left.X != right.X
&& left.Y != right.Y
&& left.Z != right.Z;
return left.v != right.v;
}
public string ToString(string sample)
{
return $"{this.X}\t{this.Y}\t{this.Z}\t";
return $"[{X.ToString(sample)},{Y.ToString(sample)},{Z.ToString(sample)}]";
}
public bool Equals(vec3d other)
+4 -3
View File
@@ -1,5 +1,6 @@
using StgSharp.Controlling;
using StgSharp.Math;
using System;
using System.Data.Common;
using System.Numerics;
using System.Runtime.InteropServices;
@@ -39,10 +40,10 @@ namespace StgSharp.Math
[FieldOffset(8)] public float Z;
[FieldOffset(12)] public float W;
public Vec4d(
float x, float y, float z, float w)
public Vec4d(float x, float y, float z, float w)
{
X = x; Y = y; Z = z; W = w;
vec = new Vector4(x, y, z, w);
}
public static implicit operator M128(Vec4d vec)