daily update on 20240513 by nitload youmu, instancing render added

This commit is contained in:
YoumuLiu
2024-05-13 03:39:54 +08:00
parent 56459deec5
commit a3506c96a3
78 changed files with 2562 additions and 1098 deletions
+57 -38
View File
@@ -52,46 +52,20 @@ namespace StgSharp.Graphics
private int _frameCount;
private int _frameSpeed;
private short fpsCount;
private IntPtr windowID;
internal LinkedList<Control> allControl;
internal Vector4 backgroundColor;
internal TimeSpanProvider fpsCountProvider;
internal TimeSpanProvider frameTimeProvider;
private short fpsCount;
internal Form sharedForm;
internal int height;
internal IntPtr monitor;
internal string name;
internal Form sharedForm;
internal int width;
internal IntPtr monitor;
public Form()
{
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 =
() =>
{
};
height = 800;
width = 600;
name = new StackFrame(1, false).
GetMethod()!.DeclaringType!.Name;
}
internal LinkedList<Control> allControl;
internal string name;
internal TimeSpanProvider fpsCountProvider;
internal TimeSpanProvider frameTimeProvider;
internal Vector4 backgroundColor;
protected Form((int width, int height) size, string name)
{
@@ -107,7 +81,7 @@ namespace StgSharp.Graphics
Console.WriteLine(_frameSpeed);
};
frameTimeProvider = new TimeSpanProvider(
1000L * 1000L / 60, TimeSpanProvider.DefaultProvider
(1000L * 1000L) / 60, TimeSpanProvider.DefaultProvider
);
frameTimeProvider.SpanRefreshCallback =
() =>
@@ -118,6 +92,32 @@ namespace StgSharp.Graphics
this.name = name;
}
public Form()
{
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 =
() =>
{
};
height = 800;
width = 600;
name = new StackFrame(1, false).
GetMethod()!.DeclaringType!.Name;
}
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
public int FrameSpeed => _frameSpeed;
@@ -178,13 +178,14 @@ namespace StgSharp.Graphics
public unsafe IntPtr WindowID
{
{
get => windowID;
internal set => windowID = value;
}
internal unsafe IntPtr id => windowID;
#pragma warning disable CA1044
protected FrameBufferSizeHandler FrameSizeCallback
{
set
@@ -193,8 +194,26 @@ namespace StgSharp.Graphics
InternalIO.glfwSetFramebufferSizeCallback(windowID, handlerPtr);
}
}
#pragma warning restore CA1044
#region Key Control
protected KeyStatus CheckKey(KeyboardKey key)
{
return InternalIO.glfwGetKey(this.WindowID,(int)key);
}
protected KeyStatus CheckKey(Mouse key)
{
return InternalIO.glfwGetKey(this.WindowID, (int)key);
}
protected KeyStatus CheckKey(Joystick key)
{
return InternalIO.glfwGetKey(this.WindowID, (int)key);
}
#endregion
/// <summary>
/// Set all necessary metadata to current form instance
@@ -251,9 +270,9 @@ namespace StgSharp.Graphics
/// <param name="maxHeight">Maximum height of current form</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
{
{
//TODO 重做form的尺寸极限控制
InternalIO.glfwSetWindowSizeLimits(this.windowID, minWidth, minHeight, maxWidth, maxHeight);
InternalIO.glfwSetWindowSizeLimits(this.windowID, minWidth, minHeight, maxWidth, maxHeight);
}
}