daily update on 20240315 by nitload youmu
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
public static void InitGL(int majorVersion, int minorVersion)
|
||||
{
|
||||
if (API == default)
|
||||
{
|
||||
API = GraphicAPI.GL;
|
||||
}
|
||||
if (API != GraphicAPI.GL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
InternalIO.InternalInitGL(majorVersion, minorVersion);
|
||||
}
|
||||
|
||||
public static class GlobalSetting
|
||||
{
|
||||
private static bool vSyncActivated;
|
||||
|
||||
public static bool VSyncActivated
|
||||
{
|
||||
get { return vsyncActivated; }
|
||||
set
|
||||
{
|
||||
InternalIO.glfwSwapInterval(value ? 1 : 0);
|
||||
vsyncActivated = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -33,10 +34,10 @@ namespace StgSharp
|
||||
VK
|
||||
}
|
||||
|
||||
public static partial class Platform
|
||||
public static partial class StgSharp
|
||||
{
|
||||
internal static GraphicAPI API = default;
|
||||
|
||||
private static bool vsyncActivated;
|
||||
private static uint markCount = 0;
|
||||
|
||||
public static void Mark(bool needConsole)
|
||||
@@ -55,22 +56,6 @@ namespace StgSharp
|
||||
/// </summary>
|
||||
public const long version = 430;
|
||||
|
||||
/// <summary>
|
||||
/// Init an instance of OpenGL program,
|
||||
/// This method should be called before other
|
||||
/// graphic methods, after LoadGL method.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InitGL(int majorVersion, int minorVersion)
|
||||
{
|
||||
if (API != default)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InternalIO.InternalInitGL(majorVersion, minorVersion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a log message to log file, and mark the level of this message.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user