daily update on 20240501 by nitload youmu, tracking blueprint coruptr

This commit is contained in:
YoumuLiu
2024-05-02 05:47:27 +08:00
parent 0cd01ed9dd
commit 6324e578ab
60 changed files with 2564 additions and 307 deletions
+61 -20
View File
@@ -32,6 +32,7 @@ using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Reflection;
@@ -59,26 +60,65 @@ namespace StgSharp.Graphics
internal Vector4 backgroundColor;
internal TimeSpanProvider fpsCountProvider;
internal TimeSpanProvider frameTimeProvider;
internal RenderStream mainRenderStream;
internal int height;
internal IntPtr monitor;
internal string name;
internal Form sharedForm;
internal int width;
protected Form()
public Form()
{
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
_frameSpeed = 0;
_frameCount = 0;
fpsCountProvider.SpanRefreshCallback = new TimeSpanRefeshCallback(
fpsCountProvider.SpanRefreshCallback =
() =>
{
Interlocked.Exchange(ref _frameSpeed, _frameCount);
Interlocked.Exchange(ref _frameCount, 0);
//Console.Clear();
//Console.WriteLine(_frameSpeed);
});
};
frameTimeProvider = new TimeSpanProvider(
1000L * 1000L / 60, TimeSpanProvider.DefaultProvider
);
frameTimeProvider.SpanRefreshCallback =
() =>
{
Interlocked.Increment(ref _frameCount);
};
height = 800;
width = 600;
name = new StackFrame(1, false).
GetMethod()!.DeclaringType!.Name;
}
protected Form((int width, int height) size, string name)
{
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
_frameSpeed = 0;
_frameCount = 0;
fpsCountProvider.SpanRefreshCallback =
() =>
{
Interlocked.Exchange(ref _frameSpeed, _frameCount);
Interlocked.Exchange(ref _frameCount, 0);
//Console.Clear();
//Console.WriteLine(_frameSpeed);
};
frameTimeProvider = new TimeSpanProvider(
1000L * 1000L / 60, TimeSpanProvider.DefaultProvider
);
frameTimeProvider.SpanRefreshCallback =
() =>
{
Interlocked.Increment(ref _frameCount);
Console.WriteLine(1);
};
height = size.height;
width = size.width;
this.name = name;
}
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
@@ -93,7 +133,10 @@ namespace StgSharp.Graphics
set
{
height = value;
InternalIO.glfwSetWindowSize(windowID, Width, Height);
if (WindowID != IntPtr.Zero)
{
InternalIO.glfwSetWindowSize(windowID, Width, Height);
}
}
}
@@ -113,7 +156,10 @@ namespace StgSharp.Graphics
{
width = (int)value.X;
height = (int)value.Y;
InternalIO.glfwSetWindowSize(windowID, Width, Height);
if (WindowID != IntPtr.Zero)
{
InternalIO.glfwSetWindowSize(windowID, Width, Height);
}
}
}
@@ -126,12 +172,19 @@ namespace StgSharp.Graphics
set
{
width = value;
InternalIO.glfwSetWindowSize(windowID, Width, Height);
if (WindowID != IntPtr.Zero)
{
InternalIO.glfwSetWindowSize(windowID, Width, Height);
}
}
}
public unsafe IntPtr WindowID => windowID;
public unsafe IntPtr WindowID
{
get => windowID;
internal set => windowID = value;
}
internal unsafe IntPtr id => windowID;
@@ -172,18 +225,6 @@ namespace StgSharp.Graphics
}
/// <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>
/// Set the size limit of current form
/// </summary>
@@ -29,8 +29,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using StgSharpDebug.Logic;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
@@ -46,15 +45,28 @@ namespace StgSharp.Graphics
{
private Blueprint renderLogic;
public Blueprint RenderLogic
{
get => renderLogic;
set => renderLogic = value;
}
/// <summary>
/// Init this form and render it on screen, and respond with operation
/// </summary>
public unsafe void Show()
{
int a = 0;
while (!ShouldClose)
{
a++;
renderLogic.RunRepeatedly(() => ShouldClose);
frameTimeProvider.WaitNextSpan();
}
}
private void GahterSignleFrameAsyncThread(MethodInfo[] methods)
/*
private void GatherSingleFrameAsyncThread(MethodInfo[] methods)
{
if (methods.Length == 0)
{
@@ -76,7 +88,7 @@ namespace StgSharp.Graphics
//singleFrameAsyncThreadList.Add(thread);
}
}
/**/
}
}