daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange

This commit is contained in:
Nitload
2024-10-03 04:03:06 +08:00
parent 0979123ac0
commit 6e2f93b053
265 changed files with 26732 additions and 19058 deletions
@@ -39,11 +39,9 @@ namespace StgSharp
public class UniformEmptyReferenceException : Exception
{
public UniformEmptyReferenceException(string program, string name) :
base($"Location -1 returned when trying to find uniform {name} in shader program {program}")
{
}
public UniformEmptyReferenceException( string program, string name )
: base(
$"Location -1 returned when trying to find uniform {name} in shader program {program}" ) { }
}
}
+15 -19
View File
@@ -44,7 +44,7 @@ namespace StgSharp
internal const int ssdSegmentLength = 16;
static byte[] _currentHash;
private static byte[] _currentHash;
private static bool _inited;
private static int _mainThreadID = -1;
@@ -53,14 +53,12 @@ namespace StgSharp
{
get
{
if (_currentHash == null)
{
if( _currentHash == null ) {
string route = Assembly.GetExecutingAssembly().Location;
string time = DateTime.UtcNow.ToString();
using (SHA256 sh = SHA256.Create())
{
byte[] bytes = Encoding.UTF8.GetBytes(route);
_currentHash = sh.ComputeHash(bytes);
using( SHA256 sh = SHA256.Create() ) {
byte[] bytes = Encoding.UTF8.GetBytes( route );
_currentHash = sh.ComputeHash( bytes );
}
}
return _currentHash;
@@ -69,26 +67,24 @@ namespace StgSharp
public static int MainThreadID
{
get => (_mainThreadID == -1) ?
throw new InvalidOperationException("StgSharp environment is not inited. " +
"Main thread id is not available") : _mainThreadID;
get => ( _mainThreadID == -1 ) ?
throw new InvalidOperationException(
"StgSharp environment is not inited. " + "Main thread id is not available" ) : _mainThreadID;
}
/// <summary>
/// CustomizeInit an instance of OpenGL program,
/// This method should be called before any other StgSharp api.
/// CustomizeInit an instance of OpenGL program, This method should be called before any
/// other StgSharp api.
/// </summary>
public static void InitGL(int majorVersion, int minorVersion)
public static void InitGL( int majorVersion, int minorVersion )
{
if (API == default)
{
if( API == default ) {
API = GraphicAPI.GL;
}
if (API != GraphicAPI.GL)
{
if( API != GraphicAPI.GL ) {
return;
}
InternalIO.InternalInitGL(majorVersion, minorVersion);
InternalIO.InternalInitGL( majorVersion, minorVersion );
}
public static class GlobalSetting
@@ -101,7 +97,7 @@ namespace StgSharp
get => vsyncActivated;
set
{
InternalIO.glfwSwapInterval(value ? 1 : 0);
InternalIO.glfwSwapInterval( value ? 1 : 0 );
vsyncActivated = value;
}
}
+6 -8
View File
@@ -48,13 +48,13 @@ namespace StgSharp
{
get
{
if (monitorsArray == null)
{
if( monitorsArray == null ) {
int count = 0;
IntPtr* arrayhandle = InternalIO.glfwGetMonitors(&count);
IntPtr* arrayhandle = InternalIO.glfwGetMonitors( &count );
monitorsArray = new IntPtr[count];
Marshal.Copy((IntPtr)arrayhandle, monitorsArray, 0, count);
Marshal.FreeHGlobal((IntPtr)arrayhandle);
Marshal.Copy(
( IntPtr )arrayhandle, monitorsArray, 0, count );
Marshal.FreeHGlobal( ( IntPtr )arrayhandle );
}
return monitorsArray;
}
@@ -62,10 +62,8 @@ namespace StgSharp
public static IntPtr DefaultMonitor
{
get { return MonitorsHandleArray[0]; }
get { return MonitorsHandleArray[ 0 ]; }
}
}
}
+48 -54
View File
@@ -60,18 +60,19 @@ namespace StgSharp
{
internal enum GraphicAPI : byte
{
GL,
DX,
VK
}
public static partial class StgSharp
{
/// <summary>
/// Version of current StgSharp platform.
/// Main version represent in hundred's digit,
/// and sub version represent in ten's digit.
/// 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;
@@ -85,38 +86,39 @@ namespace StgSharp
mainTimeProvider = new StgSharpTime();
MainTimeProvider.StartProvidingTime();
InternalIO.glfwInit();
InternalIO.InternalAppendLog("\n\n\n");
InternalIO.InternalAppendLog( "\n\n\n" );
InternalIO.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} Started.",
LogType.Info);
LogType.Info );
_mainThreadID = Environment.CurrentManagedThreadId;
}
public static void LogError(Exception ex)
public static void LogError( Exception ex )
{
InternalIO.InternalWriteLog(ex.Message, LogType.Error);
InternalIO.InternalWriteLog( ex.Message, LogType.Error );
}
public static void LogInfo(string log)
public static void LogInfo( string log )
{
InternalIO.InternalWriteLog(log, LogType.Info);
InternalIO.InternalWriteLog( log, LogType.Info );
}
public static void LogWarning(string log)
public static void LogWarning( string log )
{
InternalIO.InternalWriteLog(log, LogType.Warning);
}
public static void LogWarning(Exception notVerySeriesException)
{
InternalIO.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
InternalIO.InternalWriteLog( log, LogType.Warning );
}
public static void Mark(bool needConsole)
public static void LogWarning( Exception notVerySeriesException )
{
InternalIO.InternalWriteLog(
notVerySeriesException.Message, LogType.Warning );
}
public static void Mark( bool needConsole )
{
markCount++;
if (needConsole)
{
Console.WriteLine(markCount);
if( needConsole ) {
Console.WriteLine( markCount );
}
}
@@ -132,68 +134,60 @@ namespace StgSharp
bool isConsole,
[CallerFilePath] string filePath = "",
[CallerMemberName] string callerName = "",
[CallerLineNumber] int lineNumber = 0
)
[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);
FieldInfo[] fieldInfo = t.GetFields(
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
log += "|\tFieldName\t|\tFieldType\t|\tFieldValue\t|\n";
foreach (FieldInfo field in fieldInfo)
{
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);
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.
/// </summary>
/// <param name="message">A string contains information of how current evironment runs.</param>
/// <param name="logType">The severity of current message.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteLog(string message, LogType logType)
/// <param name="message"> A string contains information of how current evironment runs. </param>
/// <param name="logType"> The severity of current message. </param>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static void WriteLog( string message, LogType logType )
{
InternalIO.InternalWriteLog(message, logType);
InternalIO.InternalWriteLog( message, logType );
}
internal static TDele ConvertAPI<TDele>(IntPtr funcPtr)
internal static TDele ConvertAPI<TDele>( IntPtr funcPtr )
{
if (funcPtr == IntPtr.Zero)
{
throw new Exception("Failed to convert api, the function pointer is zero.");
if( funcPtr == IntPtr.Zero ) {
throw new Exception(
"Failed to convert api, the function pointer is zero." );
}
try
{
return Marshal.GetDelegateForFunctionPointer<TDele>(funcPtr);
try {
return Marshal.GetDelegateForFunctionPointer<TDele>( funcPtr );
}
catch (Exception)
{
catch( Exception ) {
throw;
}
}
internal static Delegate ConvertAPI(IntPtr funcPtr, Type T)
internal static Delegate ConvertAPI( IntPtr funcPtr, Type T )
{
if (funcPtr == IntPtr.Zero)
{
throw new Exception("Failed to convert api, the function pointer is zero.");
if( funcPtr == IntPtr.Zero ) {
throw new Exception(
"Failed to convert api, the function pointer is zero." );
}
try
{
return Marshal.GetDelegateForFunctionPointer(funcPtr, T);
try {
return Marshal.GetDelegateForFunctionPointer( funcPtr, T );
}
catch (Exception)
{
catch( Exception ) {
throw;
}
}
@@ -37,18 +37,16 @@ using System.Threading.Tasks;
namespace StgSharp
{
public static partial class StgSharp
{
private static ConcurrentDictionary<int, KeyStatus> keyListener
= new ConcurrentDictionary<int, KeyStatus>();
public static KeyStatus CheckKey(KeyboardKey key)
public static KeyStatus CheckKey( KeyboardKey key )
{
return keyListener.GetOrAdd((int)key, KeyStatus.RELEASE);
return keyListener.GetOrAdd( ( int )key, KeyStatus.RELEASE );
}
}
}