// using StgSharp.Envitronment; // using StgSharp.Envitronment.Win32; // using StgSharp.Graphics; // using StgSharp.Math; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; #if Windows // using Windows.Win32.UI.WindowsAndMessaging; // using Windows.Win32; // using Windows.Win32.Foundation; // using Windows.Win32.Graphics.OpenGL; // using Windows.Win32.Graphics.Gdi; // using Windows.Win32.UI; #endif namespace StgSharp { internal enum GraphicAPI : byte { GL, DX, VK } 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) { markCount++; if (needConsole) { Console.WriteLine(markCount); } } /// /// Version of current StgSharp platform. /// Main version represent in hundred's digit, /// and sub version represent in ten's digit. /// public const long version = 430; /// /// Write a log message to log file, and mark the level of this message. /// /// A string contains information of how current evironment runs. /// The severity of current message. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteLog(string message, LogType logType) { InternalIO.InternalWriteLog(message, logType); } internal static TDele ConvertAPI(IntPtr funcPtr) { if (funcPtr == IntPtr.Zero) { throw new Exception("Failed to convert api, the function pointer is zero."); } try { return Marshal.GetDelegateForFunctionPointer(funcPtr); } catch (Exception) { throw; } } internal static Delegate ConvertAPI(IntPtr funcPtr, Type T) { if (funcPtr == IntPtr.Zero) { throw new Exception("Failed to convert api, the function pointer is zero."); } try { return Marshal.GetDelegateForFunctionPointer(funcPtr, T); } catch (Exception) { throw; } } 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); } } } }