daily update on 2024.03.18 by itload youmu
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
using System;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="GlobalSetting.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -9,6 +39,7 @@ namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class StgSharp
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Init an instance of OpenGL program,
|
||||
/// This method should be called before any other StgSharp api.
|
||||
@@ -28,17 +59,20 @@ namespace StgSharp
|
||||
|
||||
public static class GlobalSetting
|
||||
{
|
||||
|
||||
private static bool vSyncActivated;
|
||||
|
||||
public static bool VSyncActivated
|
||||
{
|
||||
get { return vsyncActivated; }
|
||||
get => vsyncActivated;
|
||||
set
|
||||
{
|
||||
InternalIO.glfwSwapInterval(value ? 1 : 0);
|
||||
vsyncActivated = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,34 @@
|
||||
// using StgSharp.Envitronment;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Platform.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// using StgSharp.Envitronment;
|
||||
// using StgSharp.Envitronment.Win32;
|
||||
// using StgSharp.Graphics;
|
||||
// using StgSharp.Math;
|
||||
@@ -36,9 +66,17 @@ namespace StgSharp
|
||||
|
||||
public static partial class StgSharp
|
||||
{
|
||||
internal static GraphicAPI API = default;
|
||||
private static bool vsyncActivated;
|
||||
|
||||
/// <summary>
|
||||
/// Version of current StgSharp platform.
|
||||
/// Main version represent in hundred's digit,
|
||||
/// and sub version represent in ten's digit.
|
||||
/// </summary>
|
||||
public const long version = 430;
|
||||
|
||||
private static uint markCount = 0;
|
||||
private static bool vsyncActivated;
|
||||
internal static GraphicAPI API = default;
|
||||
|
||||
public static void Mark(bool needConsole)
|
||||
{
|
||||
@@ -49,12 +87,34 @@ namespace StgSharp
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Version of current StgSharp platform.
|
||||
/// Main version represent in hundred's digit,
|
||||
/// and sub version represent in ten's digit.
|
||||
/// </summary>
|
||||
public const long version = 430;
|
||||
public static void Track(
|
||||
object target,
|
||||
string message,
|
||||
bool isConsole,
|
||||
[CallerFilePath] string filePath = "",
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerLineNumber] int lineNumber = 0
|
||||
)
|
||||
{
|
||||
Type t = target.GetType();
|
||||
string log = $"Tracked object: {nameof(target)}\t\tType:{t.Name}\n";
|
||||
FieldInfo[] fieldInfo = t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
log += "|\tFieldName\t|\tFieldType\t|\tFieldValue\t|\n";
|
||||
foreach (FieldInfo field in fieldInfo)
|
||||
{
|
||||
log += $"|{field.Name}\t\t|{field.FieldType}\t\t|{field.GetValue(target)}\t\t|\n";
|
||||
}
|
||||
log += $"Tracking at:\n{filePath}\t{callerName}\tline {lineNumber}\n";
|
||||
log += $"Additional information:\n{message}\n";
|
||||
if (isConsole)
|
||||
{
|
||||
Console.WriteLine(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
InternalIO.InternalWriteLog(log, LogType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a log message to log file, and mark the level of this message.
|
||||
@@ -99,33 +159,5 @@ namespace StgSharp
|
||||
}
|
||||
}
|
||||
|
||||
public static void Track(
|
||||
object target,
|
||||
string message,
|
||||
bool isConsole,
|
||||
[CallerFilePath] string filePath = "",
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerLineNumber] int lineNumber = 0
|
||||
)
|
||||
{
|
||||
Type t = target.GetType();
|
||||
string log = $"Tracked object: {nameof(target)}\t\tType:{t.Name}\n";
|
||||
FieldInfo[] fieldInfo = t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
log += "|\tFieldName\t|\tFieldType\t|\tFieldValue\t|\n";
|
||||
foreach (FieldInfo field in fieldInfo)
|
||||
{
|
||||
log += $"|{field.Name}\t\t|{field.FieldType}\t\t|{field.GetValue(target)}\t\t|\n";
|
||||
}
|
||||
log += $"Tracking at:\n{filePath}\t{callerName}\tline {lineNumber}\n";
|
||||
log += $"Additional information:\n{message}\n";
|
||||
if (isConsole)
|
||||
{
|
||||
Console.WriteLine(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
InternalIO.InternalWriteLog(log, LogType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static partial class StgSharp
|
||||
{
|
||||
private static Stopwatch mainProvider = new Stopwatch();
|
||||
private static List<TimeProvider> subscriberList = new List<TimeProvider>();
|
||||
private static Thread timeProvideThread;
|
||||
private static long accuracy;
|
||||
|
||||
private static void ProvideTime()
|
||||
{
|
||||
long totalMS, previousFrameMS = 0,
|
||||
internalFrequncy = Stopwatch.Frequency;
|
||||
lock (mainProvider)
|
||||
{
|
||||
mainProvider.Restart();
|
||||
}
|
||||
while (mainProvider.IsRunning)
|
||||
{
|
||||
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L));
|
||||
foreach (TimeProvider subscriber in subscriberList)
|
||||
{
|
||||
subscriber.CheckTime(totalMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoOptimization)]
|
||||
public static void TimerActivate(int maxFrameUpdateSensitiveTimeProviderCount)
|
||||
{
|
||||
if (!mainProvider.IsRunning)
|
||||
{
|
||||
mainProvider.Start();
|
||||
//speed test
|
||||
long totalMS, previousSecondMS = 0,
|
||||
internalFrequncy = Stopwatch.Frequency;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L));
|
||||
for (int t = 0; t < 10; t++)
|
||||
{
|
||||
if (totalMS < 1000)
|
||||
{
|
||||
subscriberList.Add(new TimeProvider(100L));
|
||||
}
|
||||
}
|
||||
}
|
||||
mainProvider.Stop();
|
||||
subscriberList.Clear();
|
||||
totalMS = (mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L))) / 100L;
|
||||
accuracy = totalMS * 2 / 3;
|
||||
mainProvider.Reset();
|
||||
timeProvideThread = new Thread(new ThreadStart(ProvideTime));
|
||||
timeProvideThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SubscribeTimeProvider(TimeProvider provider)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TimerDeactivate()
|
||||
{
|
||||
lock (mainProvider)
|
||||
{
|
||||
mainProvider.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="TimeProvider.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharpDebug.Logic;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public partial class StgSharp
|
||||
{
|
||||
|
||||
internal static StgSharpTime mainTimeProvider;
|
||||
|
||||
}
|
||||
|
||||
public sealed class StgSharpTime : TimeSourceProviderBase
|
||||
{
|
||||
|
||||
private static long accuracy;
|
||||
private static Stopwatch mainProvider = new Stopwatch();
|
||||
private static List<TimeSpanProvider> subscriberList = new List<TimeSpanProvider>();
|
||||
private static Thread timeProvideThread;
|
||||
|
||||
internal StgSharpTime()
|
||||
{
|
||||
}
|
||||
|
||||
public static StgSharpTime OnlyInstance
|
||||
=> StgSharp.mainTimeProvider;
|
||||
|
||||
public override sealed void StartProvidingTime()
|
||||
{
|
||||
if (mainProvider.IsRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mainProvider.Start();
|
||||
//speed test
|
||||
long totalMS, internalFrequncy = Stopwatch.Frequency;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L));
|
||||
for (int t = 0; t < 10; t++)
|
||||
{
|
||||
if (totalMS < 1000)
|
||||
{
|
||||
subscriberList.Add(new TimeSpanProvider(100L, TimeSpanProvider.DefaultProvider));
|
||||
}
|
||||
}
|
||||
}
|
||||
mainProvider.Stop();
|
||||
subscriberList.Clear();
|
||||
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L)) / 100L;
|
||||
accuracy = (totalMS * 2) / 3;
|
||||
mainProvider.Reset();
|
||||
timeProvideThread = new Thread(new ThreadStart(ProvideTime));
|
||||
timeProvideThread.Start();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoOptimization)]
|
||||
public static void TimerActivate(int maxFrameUpdateSensitiveTimeProviderCount)
|
||||
{
|
||||
}
|
||||
|
||||
protected override sealed void AddSubscriberUnsynced(TimeSpanProvider subscriber)
|
||||
{
|
||||
subscriberList.Add(subscriber);
|
||||
}
|
||||
|
||||
protected override sealed void RemoveSubscriberUnsynced(TimeSpanProvider subscriber)
|
||||
{
|
||||
subscriberList.Remove(subscriber);
|
||||
}
|
||||
|
||||
private void ProvideTime()
|
||||
{
|
||||
long totalMS, internalFrequncy = Stopwatch.Frequency;
|
||||
lock (mainProvider)
|
||||
{
|
||||
mainProvider.Restart();
|
||||
}
|
||||
while (mainProvider.IsRunning)
|
||||
{
|
||||
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L));
|
||||
foreach (TimeSpanProvider subscriber in subscriberList)
|
||||
{
|
||||
if (subscriber.CheckTime(totalMS))
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user