daly update on 20230502 by nitload youmu

This commit is contained in:
YoumuLiu
2024-05-03 00:49:56 +08:00
parent 8149dfacb0
commit 66efce19fc
28 changed files with 236 additions and 222 deletions
+2 -5
View File
@@ -86,7 +86,6 @@ namespace StgSharp.Graphics
frameTimeProvider.SpanRefreshCallback =
() =>
{
Interlocked.Increment(ref _frameCount);
};
height = 800;
width = 600;
@@ -104,8 +103,8 @@ namespace StgSharp.Graphics
{
Interlocked.Exchange(ref _frameSpeed, _frameCount);
Interlocked.Exchange(ref _frameCount, 0);
//Console.Clear();
//Console.WriteLine(_frameSpeed);
Console.Clear();
Console.WriteLine(_frameSpeed);
};
frameTimeProvider = new TimeSpanProvider(
1000L * 1000L / 60, TimeSpanProvider.DefaultProvider
@@ -113,8 +112,6 @@ namespace StgSharp.Graphics
frameTimeProvider.SpanRefreshCallback =
() =>
{
Interlocked.Increment(ref _frameCount);
Console.WriteLine(1);
};
height = size.height;
width = size.width;
@@ -56,12 +56,11 @@ namespace StgSharp.Graphics
/// </summary>
public unsafe void Show()
{
int a = 0;
while (!ShouldClose)
{
a++;
renderLogic.RunRepeatedly(() => ShouldClose);
frameTimeProvider.WaitNextSpan();
Interlocked.Add(ref _frameCount, 1);
}
}
+20 -7
View File
@@ -42,17 +42,30 @@ namespace StgSharp.Graphics
{
internal static unsafe partial class GL
{
private static IntPtr api;
private static ref GLcontext Context
{
get { return ref *(GLcontext*)api; }
}
private static GLcontext* context;
public static IntPtr CurrentContextHandle
{
get { return (IntPtr)api; }
set { api = value; }
get { return (IntPtr)context; }
set
{
context = (GLcontext*)value;
}
}
private static ref GLcontext Context
{
get
{
#if DEBUG
if ((IntPtr)context==IntPtr.Zero)
{
throw new NullReferenceException();
}
#endif
return ref *context;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -56,10 +56,9 @@ namespace StgSharp.Graphics
private static string glExtensionList;
/// <summary>
/// Load all supportted OpenGL APIs and bind them to given <see cref="Form"/> context.
/// Load all supported OpenGL APIs and bind them to given <see cref="Form"/> context.
/// </summary>
/// <param name="stream">The <see cref="Form"/> used as current OpenGL context</param>
/// <param name="loader">A delegate to get address of OpenGL api</param>
public static unsafe void LoadGLapi(this glRenderStream stream)
{
GLcontext* context = (GLcontext*)stream.ContextHandle;
@@ -94,7 +93,7 @@ namespace StgSharp.Graphics
coreVersion.Replace(branch, string.Empty);
}
}
string[] versionSep = coreVersion.Split('.');
string[] versionSep = coreVersion!.Split('.');
int majorVersion = int.Parse(versionSep[0]);
int minorVersion = int.Parse(versionSep[1]);
CheckCoreVersion(majorVersion, minorVersion);
@@ -100,10 +100,12 @@ namespace StgSharp.Graphics
in Dictionary<string, BlueprintPipeline> output)
{
MakeAsCurrentContext();
ProcessInput();
Main(in input, in output);
InternalIO.glfwSwapBuffers(CanvasHandle);
InternalIO.glfwPollEvents();
}
internal sealed override void InternalTerminate()
{
Deinit();