Daily update on 20231211 by nitload youmu

This commit is contained in:
Nitload
2023-12-12 03:17:16 +08:00
parent ab85c1a9fe
commit f97fb137ba
100 changed files with 2699 additions and 3191 deletions
@@ -2640,7 +2640,7 @@ namespace StgSharp.Graphics
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate GLFWcursorposfun glfwSetCursorPosCallback(IntPtr window, GLFWcursorposfun callback);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate GLFWdropfun glfwSetDropCallback(IntPtr window, GLFWdropfun callback);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, FrameBufferSizeHandler callback);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate void glfwSetGamma(IntPtr monitor, float gamma);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate void glfwSetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp);
[UnmanagedFunctionPointer(callingConvention: CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal unsafe delegate void glfwSetInputMode(IntPtr window, int mode, int value);
+116 -41
View File
@@ -6,6 +6,9 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
@@ -24,7 +27,7 @@ namespace StgSharp.Graphics
/// <summary>
///
/// </summary>
public unsafe abstract partial class Form
public abstract partial class Form
{
internal LinkedList<Control> allControl;
internal Vector4 color;
@@ -35,23 +38,32 @@ namespace StgSharp.Graphics
internal Form sharedForm;
internal int width;
internal IntPtr windowID;
protected IglFunc GL;
private GLonRender glRender;
private GLonUpdate glUpdate;
~Form()
{
Marshal.FreeHGlobal((IntPtr)contextID);
glRender.api = default;
}
internal FrameUpdateTimer timer = new FrameUpdateTimer();
private SemaphoreSlim ping = new SemaphoreSlim(1, 1);
private SemaphoreSlim pong = new SemaphoreSlim(0, 1);
private UpdateWhenRender updateWhenRender;
private DynamicMethod updateWhenRenderDM;
private ILGenerator updateWhenRenderIL;
private delegate void UpdateWhenRender();
/// <summary>
/// Height of this form, represent in <see cref="int"/>
/// </summary>
public int Height
{
get => height;
set => height = value;
}
/// <summary>
/// Width of this form, represent in <see cref="int"/>
/// </summary>
public Vec2d Size
{
get { return new Vec2d(width, height); }
@@ -68,30 +80,107 @@ namespace StgSharp.Graphics
set => width = value;
}
#region form main
public abstract void Deinit(object[] args);
public abstract void Init(object[] args);
public abstract void OnRenderFrame(object[] args);
public abstract void OnUpdateFrame(object[] args);
internal void internalShowForm(object arg)
unsafe ~Form()
{
object[] args = (object[])arg;
Init((object[])args[0]);
while (InternalIO.glfw.WindowShouldClose(windowID) == 0)
{
OnUpdateFrame((object[])args[1]);
}
Deinit((object[])args[2]);
Marshal.FreeHGlobal((IntPtr)contextID);
glRender.api = default;
}
#region form main
public abstract void Deinit(object[] args, IglFunc GL);
public abstract void Init(object[] args, IglFunc GL);
public abstract void OnRenderFrame(object[] args, IglFunc GL);
public abstract void OnUpdateFrame(object[] args, IglFunc GL);
/// <summary>
/// Init this form and render it on screen, and respond with operation
/// </summary>
public void Show(object[] args)
{
if (args == null)
{
args = new object[3] { null, null, null };
}
Operation.RegistForm(this);
try
{
Thread updateThread = new Thread(InternalUpdateFrame);
Thread renderThread = new Thread(InternalRenderFrame);
updateThread.Start();
renderThread.Start();
updateThread.Join();
renderThread.Join();
ping.Dispose();
pong.Dispose();
}
catch (Exception)
{
throw;
}
}
internal void InternalInit(object[] args)
{
updateWhenRenderDM = new DynamicMethod(
name: "updateWhenRender",
returnType: typeof(void),
parameterTypes: new Type[] { typeof(void) },
restrictedSkipVisibility: true
);
updateWhenRenderIL = updateWhenRenderDM.GetILGenerator();
Init((object[])args, this.glRender);
}
internal void InternalRenderFrame(object args)
{
while (InternalIO.glfw.WindowShouldClose(windowID) != 0)
{
ping.Wait();
try
{
OnRenderFrame((object[])args, glRender);
timer.GoNextFrame();
throw new Exception("Forget to reload GL apis");
pong.Release();
}
catch (NullReferenceException)
{
throw new Exception("Forget to reload GL apis");
pong.Release();
}
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void InternalUpdateFrame(object args)
{
OnUpdateFrame((object[])args);
while (InternalIO.glfw.WindowShouldClose(windowID) != 0)
{
pong.Wait();
try
{
OnUpdateFrame((object[])args, glUpdate);
timer.GoNextFrame();
throw new Exception("Forget to reload GL apis");
ping.Release();
}
catch (NullReferenceException)
{
throw new Exception("Forget to reload GL apis");
ping.Release();
}
}
}
#endregion
@@ -115,7 +204,7 @@ namespace StgSharp.Graphics
/// </summary>
/// <exception cref="Exception">Something goes wrong and
/// StgSharp fails in creating a new OpenGL context. </exception>
public void MakeAsCurrentContext()
public unsafe void MakeAsCurrentContext()
{
if (windowID == default)
{
@@ -207,20 +296,6 @@ namespace StgSharp.Graphics
(int)minSize.X, (int)minSize.Y, (int)maxSize.X, (int)maxSize.Y);
}
public void ShowForm(
object[] initArgs,
object[] updateArgs,
object[] deinitArgs)
{
Thread t = new Thread(new ParameterizedThreadStart(internalShowForm));
t.Start(new object[] { initArgs, updateArgs, deinitArgs });
}
public void ShowForm()
{
Thread t = new Thread(new ParameterizedThreadStart(internalShowForm));
t.Start(new object[3] { null, null, null });
}
/// <summary>
/// Bind this form to StgSharp platform.
+132
View File
@@ -0,0 +1,132 @@
using StgSharp;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
/// <summary>
/// A timer counting frames after its construction.
/// </summary>
public class FrameTimer
{
private Form timeProvider;
internal readonly uint bornTick;
/// <summary>
/// Frames after this timer created.
/// </summary>
public uint Time
{
get { return timeProvider.timer.totalFrame - bornTick; }
}
public FrameTimer(Form provaider)
{
timeProvider = provaider;
bornTick = timeProvider.timer.totalFrame;
}
/// <summary>
/// Convert a <see cref="FrameTimer"/> into uint value.
/// this will get total frames since the timer was created.
/// </summary>
/// <param name="timer"><see cref="FrameTimer"/> to be converted</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator uint(FrameTimer timer)
{
return timer.Time;
}
}
public partial class Form
{
internal class FrameUpdateTimer
{
private Counter<uint> tickCounter;
private float frameLength;
private double frameTime;
private bool refreshed;
private SemaphoreSlim pong;
private bool isOnceFulFrame = false;
public uint totalFrame
{
get { return tickCounter; }
}
public double timeAfterFrame
{
get { return InternalIO.glfw.GetTime() - frameTime; }
}
internal bool IsOnceFullFrame
{
get { return isOnceFulFrame; }
set
{
if (!isOnceFulFrame)
{
isOnceFulFrame = value;
}
}
}
internal void Init(SemaphoreSlim semaphore)
{
pong = semaphore;
}
internal void Refresh()
{
refreshed = false;
}
internal bool GoNextFrame()
{
try
{
while (refreshed) { }
refreshed = true;
return refreshed;
}
catch (Exception ex)
{
InternalIO.InternalWriteLog(ex.Message, LogType.Error);
return false;
}
}
}
private bool isFullyRendered = false;
/// <summary>
/// Wait until the next frame of a certain <see cref="Form"/> started,
/// all GL function after this method will be blocked until the next frame started.
/// When a frame refreshed before
/// It should be noticed that do not use this method too often to avoid unexpected performance problem
/// </summary>
/// <param name="form">The <see cref="Form"/> that can provide a frame refresh benchmark</param>
/// <param name="action"><see cref="Action"/> to be done and aligned.</param>
/// <returns>
/// A bool value indicating if the <see cref="Form"/> successfully refresh the frame.
/// If the retur value is false, please set a new <see cref="Form"/> as benchmark.
/// </returns>
protected bool AlignFrame(Form form, Action action)
{
try
{
bool isAligned = form.timer.GoNextFrame();
action();
return isAligned;
}
catch (Exception)
{
return false;
}
}
}
}
+35 -43
View File
@@ -6,54 +6,46 @@ using System.Text;
namespace StgSharp.Graphics
{
public partial class Form
public unsafe class ElementBuffer : IDisposable, IBufferObject
{
protected ElementBuffer CreateElementBuffer(int n)
uint[] _bufferID;
private IglFunc GL;
internal ElementBuffer(int n, IglFunc glFunc)
{
return new ElementBuffer(n, GL);
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* id = _bufferID)
{
GL.GenBuffers(n, id);
}
}
protected unsafe class ElementBuffer : IDisposable
public uint this[int n]
{
uint[] _bufferID;
private IglFunc GL;
internal ElementBuffer(int n, IglFunc glFunc)
{
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* id = _bufferID)
{
GL.GenBuffers(n, id);
}
}
public uint this[int n]
{
get { return _bufferID[n]; }
}
public void Bind(int index)
{
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
}
public void SetValue<T>(int index, T[] bufferArray, BufferUsage usage)
where T : struct, IConvertible
{
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.DeleteBuffers(_bufferID.Length, id);
}
}
get { return _bufferID[n]; }
}
public void Bind(int index)
{
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
}
public void SetValue<T>(int index, T[] bufferArray, BufferUsage usage)
where T : struct, IConvertible
{
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.DeleteBuffers(_bufferID.Length, id);
}
}
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
internal class FrameBuffer
{
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
/// <summary>
/// Interface of all kinds OpenGL buffer onjects
/// </summary>
public interface IBufferObject
{
uint this[int index] { get; }
void Bind(int index);
}
}
+36 -43
View File
@@ -5,62 +5,55 @@ using System.Text;
namespace StgSharp.Graphics
{
public partial class Form
public unsafe struct VertexArray : IDisposable, IBufferObject
{
protected VertexArray CreateVertexArray(int n)
internal uint[] _bufferID;
private IglFunc GL;
internal VertexArray(int n, IglFunc glFunc)
{
return new VertexArray(n, GL);
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* id = _bufferID)
{
GL.GenVertexArrays(n, id);
}
}
protected unsafe struct VertexArray : IDisposable
public uint this[int n]
{
internal uint[] _bufferID;
private IglFunc GL;
internal VertexArray(int n, IglFunc glFunc)
get
{
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* id = _bufferID)
{
GL.GenVertexArrays(n, id);
}
return _bufferID[n];
}
}
public uint this[int n]
{
get
{
return _bufferID[n];
}
}
public void Bind(int index)
{
GL.BindVertexArray(_bufferID[index]);
}
public void Bind(int index)
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.BindVertexArray(_bufferID[index]);
GL.DeleteVertexArrays(_bufferID.Length, id);
}
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.DeleteVertexArrays(_bufferID.Length, id);
}
}
public void BindNull()
{
GL.BindVertexArray(0);
}
public void BindNull()
{
GL.BindVertexArray(0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute(uint index, int vertexLength, Type dataType, bool isNomalized, int stride, int pointer)
{
GL.SetVertexAttribute(
index, vertexLength, dataType,
isNomalized,
stride, pointer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute(uint index, int vertexLength, Type dataType, bool isNomalized, int stride, int pointer)
{
GL.SetVertexAttribute(
index, vertexLength, dataType,
isNomalized,
stride, pointer);
}
}
}
+55 -55
View File
@@ -8,72 +8,72 @@ using System.Text;
namespace StgSharp.Graphics
{
public partial class Form
public unsafe struct VertexBuffer : IDisposable, IBufferObject
{
protected VertexBuffer CreateVertexBuffer(int n)
internal uint[] _bufferID;
private IglFunc GL;
internal VertexBuffer(int n, IglFunc glFunc)
{
return new VertexBuffer(n, GL);
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* ptr = _bufferID)
{
GL.GenBuffers(n, ptr);
}
}
protected unsafe struct VertexBuffer : IDisposable
public uint this[int n]
{
internal uint[] _bufferID;
private IglFunc GL;
get { return _bufferID[n]; }
}
internal VertexBuffer(int n, IglFunc glFunc)
/// <summary>
///
/// </summary>
public void Unbind()
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, 0);
}
public void Bind(int index)
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferID[index]);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* ptr = _bufferID)
{
GL.GenBuffers(n, ptr);
}
GL.DeleteBuffers(_bufferID.Length, id);
}
}
public uint this[int n]
{
get { return _bufferID[n]; }
}
/// <summary>
/// Set data to current vertex buffer object
/// </summary>
/// <typeparam name="T">Type of bufferData</typeparam>
/// <param name="index">Index to find certain VBO in this instance</param>
/// <param name="bufferData">Data to write in</param>
/// <param name="usage">How OpenGL use these data, defined by <see cref="BufferUsage"/></param>
public void SetValue<T>(int index, T bufferData, BufferUsage usage) where T : IMat
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferData, usage);
/// <summary>
///
/// </summary>
public void Unbind()
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, 0);
}
}
public void Bind(int index)
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferID[index]);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.DeleteBuffers(_bufferID.Length, id);
}
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="bufferData"></param>
/// <param name="readType"></param>
public void SetValue<T>(int index, T bufferData, BufferUsage usage) where T : IMat
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferData, usage);
}
public void SetValueArray<T>(int index, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferArray, usage);
}
/// <summary>
/// Set data to current vertex buffer object
/// </summary>
/// <typeparam name="T">Type of bufferData</typeparam>
/// <param name="index">Index to find certain VBO in this instance</param>
/// <param name="bufferArray">A array of data to write in</param>
/// <param name="usage">How OpenGL use these data, defined by <see cref="BufferUsage"/></param>
public void SetValueArray<T>(int index, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferArray, usage);
}
}
}
+5 -1
View File
@@ -17,7 +17,11 @@ namespace StgSharp.Graphics
internal GLcontext glContext
{
get { return glRender.api; }
set { glRender.api = value; }
set
{
glUpdate.api = value;
glRender.api = value;
}
}
}
+3 -2
View File
@@ -18,6 +18,7 @@ namespace StgSharp.Graphics
api.ActiveTexture(type);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.AttachShader(uint program, uint shader)
{
@@ -56,7 +57,6 @@ namespace StgSharp.Graphics
{
while (api.GetError() != 0) { }
}
uint IglFunc.CompileShader(string shaderCode, ShaderType shaderType)
{
uint shaderID;
@@ -262,7 +262,8 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
{
InternalIO.glfw.SetFramebufferSizeCallback(id, handler);
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(handler);
InternalIO.glfw.SetFramebufferSizeCallback(id, handlerPtr);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+4 -4
View File
@@ -70,7 +70,7 @@ namespace StgSharp.Graphics
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, FrameBufferSizeHandler 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();
@@ -195,7 +195,7 @@ namespace StgSharp.Graphics
[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, FrameBufferSizeHandler 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();
@@ -317,7 +317,7 @@ namespace StgSharp.Graphics
[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, FrameBufferSizeHandler callback) => glfwSetFramebufferSizeCallback(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();
@@ -568,7 +568,7 @@ namespace StgSharp.Graphics
[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, FrameBufferSizeHandler callback) => glfw_SetFramebufferSizeCallback(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();
+7 -6
View File
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -10,11 +11,15 @@ namespace StgSharp.Graphics
{
internal partial class GLonUpdate : IglFunc
{
internal GLcontext api;
void IglFunc.ActiveTexture(uint type)
{
throw new NotImplementedException();
}
void IglFunc.AttachShader(uint program, uint shader)
{
throw new NotImplementedException();
@@ -25,7 +30,6 @@ namespace StgSharp.Graphics
throw new NotImplementedException();
}
void IglFunc.BindTexture(uint type, uint texture)
{
throw new NotImplementedException();
@@ -206,14 +210,11 @@ namespace StgSharp.Graphics
throw new NotImplementedException();
}
public void SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
{
InternalIO.glfw.SetFramebufferSizeCallback(id, handler);
}
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
{
throw new NotImplementedException();
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(handler);
InternalIO.glfw.SetFramebufferSizeCallback(id, handlerPtr);
}
+24 -21
View File
@@ -5,6 +5,12 @@ namespace StgSharp.Graphics
{
public interface IglFunc
{
/// <summary>
/// Same function as OpenGL api glActiveTexture
/// </summary>
/// <param name="type">type of texture to activate</param>
void ActiveTexture(uint type);
/// <summary>
/// Same fucntion as OpenGL api glAttachShader
/// </summary>
@@ -19,6 +25,13 @@ namespace StgSharp.Graphics
/// <param name="index"></param>
void BindBuffer(BufferType bufferType, uint index);
/// <summary>
/// Same function as OpenGL api, glBindTexture.
/// </summary>
/// <param name="type">Type of texture to bind</param>
/// <param name="texture">Sign of texture</param>
void BindTexture(uint type, uint texture);
/// <summary>
/// Same function as OpenGL api, glBindVertexArray
/// </summary>
@@ -95,6 +108,13 @@ namespace StgSharp.Graphics
/// <param name="ptr"></param>
unsafe void GenBuffers(int count, uint* ptr);
/// <summary>
/// Same fucnction as OpenGL api glGenTextures.
/// </summary>
/// <param name="count">amount of textures to generate</param>
/// <param name="ptr">pointer to texture signs' array</param>
unsafe void GenTextures(int count, uint* ptr);
/// <summary>
/// Same fucntion as OpenGL api, glGenVertexArray
/// </summary>
@@ -114,6 +134,10 @@ namespace StgSharp.Graphics
bool GetWindowShouldClose(Form form);
/// <summary>
/// Make the OpenGL context of a vertain <see cref="Form"/> as the activated OpenGL context.
/// </summary>
/// <param name="form"></param>
void MakeContexCurrent(Form form);
void SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage) where T : IMat;
@@ -181,27 +205,6 @@ namespace StgSharp.Graphics
/// </summary>
/// <param name="program">Sign of program to be used</param>
void UseProgram(uint program);
/// <summary>
/// Same fucnction as OpenGL api glGenTextures.
/// </summary>
/// <param name="count">amount of textures to generate</param>
/// <param name="ptr">pointer to texture signs' array</param>
unsafe void GenTextures(int count, uint* ptr);
/// <summary>
/// Same function as OpenGL api, glBindTexture.
/// </summary>
/// <param name="type">Type of texture to bind</param>
/// <param name="texture">Sign of texture</param>
void BindTexture(uint type, uint texture);
/// <summary>
/// Same function as OpenGL api glActiveTexture
/// </summary>
/// <param name="type">type of texture to activate</param>
void ActiveTexture(uint type);
/// <summary>
/// Same function as the OpenGL api, glViewPort
/// </summary>