daily update on 20240403 by nitload youmu

This commit is contained in:
YoumuLiu
2024-04-03 08:56:33 +08:00
parent b207f16616
commit 127fcdbfd3
631 changed files with 23499 additions and 2664 deletions
+12 -50
View File
@@ -59,7 +59,6 @@ namespace StgSharp.Graphics
internal Vector4 backgroundColor;
internal TimeSpanProvider fpsCountProvider;
internal TimeSpanProvider frameTimeProvider;
internal IglFunc gl;
internal IntPtr graphicContextID;
internal int height;
internal IntPtr monitor;
@@ -78,19 +77,11 @@ namespace StgSharp.Graphics
Interlocked.Exchange(ref _frameSpeed, _frameCount);
Interlocked.Exchange(ref _frameCount, 0);
});
frameAsyncThreadList = new List<FrameAsyncThread>();
}
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
public int FrameSpeed => _frameSpeed;
/// <summary>
/// OpenGL package binded to current form context.
/// A OpenGL context is only binded to current form.
/// </summary>
public IglFunc GL => gl;
/// <summary>
/// Height of this form, represent in <see cref="int"/>
/// </summary>
@@ -102,10 +93,7 @@ namespace StgSharp.Graphics
public bool ShouldClose
{
get
{
return InternalIO.glfwWindowShouldClose(windowID) != 0;
}
get => InternalIO.glfwWindowShouldClose(windowID) != 0;
set => InternalIO.glfwSetWindowShouldClose(windowID, value ? 1 : 0);
}
@@ -145,17 +133,18 @@ namespace StgSharp.Graphics
}
}
public abstract void Deinit();
protected abstract void DeInit();
/// <summary>
/// Necessary operation to init this form.
/// Necessary operation to init graphic elements this form.
/// </summary>
public abstract void Init();
/// <param name="gl">OpenGL library binded to current form.</param>
protected abstract void Init();
/// <summary>
/// Behaviour of current form when in a frame cycle.
/// </summary>
public abstract void Main();
protected abstract void Main();
/// <summary>
/// Init an OpenGl context if current form has not been binded to any context. and set the context binded to
@@ -191,16 +180,11 @@ namespace StgSharp.Graphics
GLcontext* contextID = (GLcontext*)graphicContextID;
*contextID = new GLcontext();
contextID->glGetString = (delegate*<uint, IntPtr>)IntPtr.Zero;
gl = new GLpack(contextID);
}
GL.api = (GLcontext*)graphicContextID;
InternalIO.glfwMakeContextCurrent(windowID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void PollEvents()
{
InternalIO.glfwPollEvents();
}
/// <summary>
/// Set all necessary metadata to current form instance
@@ -227,6 +211,8 @@ namespace StgSharp.Graphics
InternalIO.glfwSetWindowSize(this.windowID, (int)size.X, (int)size.Y);
}
protected abstract void ProcessInput();
/// <summary>
/// Resize the current form
/// </summary>
@@ -264,7 +250,7 @@ namespace StgSharp.Graphics
/// </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="maxWidth">Maximum width of current 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)
@@ -274,38 +260,14 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void InternalDeinit() { Deinit(); }
internal void InternalDeInit() { DeInit(); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void SwapBuffers()
{
InternalIO.glfwSwapBuffers(windowID);
}
/// <summary>
/// Get OpenGL library of this form's context.
/// </summary>
/// <returns>A <see cref="IglFunc"/> package contains all opengl APIs</returns>
protected IglFunc GetGL()
{
if (StgSharp.API == GraphicAPI.GL)
{
return this.GL;
}
else
{
InternalIO.InternalWriteLog(
"Attempt to get OpenGL API package in other graphic envitronment.",
LogType.Error);
throw new InvalidOperationException("Attempt to get OpenGL API package in other graphic envitronment.");
}
}
unsafe ~Form() { Marshal.FreeHGlobal(graphicContextID); }
#endregion form main
}