using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace StgSharp { internal enum GraphicAPI : byte { GL, DX, VK } public static class Platform { internal static GraphicAPI API; /// /// 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; /// /// Init an instance of OpenGL program, /// This method should be called before other /// graphic methods, after LoadGL method. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void InitGL(int majorVersion, int minorVersion) { InternalIO.InternalInitGL(majorVersion, minorVersion); } /// /// 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; } } } }