Commits

Amin67v  committed a863890

  • Participants
  • Parent commits 3a6f250

Comments (0)

Files changed (3)

File SharpHammer/Engine/Engine.cs

-using Hmr.Core;
-using System;
-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace Hmr.Engine
-{
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct FrameStats
-	{
-		public UInt64 start_tick;
-		public UInt32 Frame;
-		public float ft;
-		public uint Fps;
-	}
-
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct MemoryStats
-	{
-		public uint DataMax;
-		public uint DataSize;
-		public uint LsrMax;
-		public uint LsrSize;
-		public uint Tmp0Total;
-		public uint Tmp0Max;
-		public uint Tmp0MaxFrameID;
-	}
-
-	internal class engine
-	{
-		public const string NativeDll = "engine.dll";
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(engine.NativeDll, EntryPoint = "eng_init", CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		public static extern bool Init(ref InitParams @params);
-
-		public static InitParams LoadParams(string configFile, IntPtr hwnd)
-		{
-			InitParams param = new InitParams();
-			bool val = LoadParams(ref param, configFile,
-				System.Diagnostics.Process.GetCurrentProcess().MainModule.BaseAddress, hwnd);
-
-			if (!val) {
-				Log.Error("Failed to load param file ...");
-				throw new Exception("Failed to load param file");
-			}
-
-			return param;
-		}
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(engine.NativeDll, EntryPoint = "eng_load_params", CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		public static extern bool LoadParams(ref InitParams @params,
-			[In] [MarshalAs(UnmanagedType.LPStr)] string conf_file,
-			IntPtr hinst, IntPtr hwnd);
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(engine.NativeDll, EntryPoint = "eng_unload_params", CallingConvention = CallingConvention.Cdecl)]
-		public static extern void UnloadParams(ref InitParams @params);
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(engine.NativeDll, EntryPoint = "eng_update", CallingConvention = CallingConvention.Cdecl)]
-		public static extern void Update();
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(engine.NativeDll, EntryPoint = "eng_zero", CallingConvention = CallingConvention.Cdecl)]
-		public static extern int Zero();
-	}
-}

File SharpHammer/Engine/InitParams.cs

-using System;
-using System.Runtime.InteropServices;
-
-namespace Hmr.Engine
-{
-	public enum EngineFlags
-	{
-		Debug = (1 << 0),
-		Dev = (1 << 1),
-		Editor = (1 << 2),
-		Console = (1 << 3)
-	}
-
-	public enum GfxFlags
-	{
-		Fullscreen = (1 << 0),
-		Vsync = (1 << 1),
-		Debug = (1 << 2),
-		Fxaa = (1 << 3),
-		RebuildShaders = (1 << 4)
-	}
-
-	public enum MsaaMode
-	{
-		None = 0,
-		X2 = 2,
-		X4 = 4,
-		X8 = 8,
-	}
-
-	public enum Renderer
-	{
-		Unknown = 0,
-		D3D11_0 = 3,
-		D3D10_1 = 2,
-		D3D10_0 = 1,
-		GL4_2 = 9,
-		GL4_0 = 8,
-		GL3_3 = 7,
-		GL3_2 = 6,
-		GL3_0 = 5
-	}
-
-	public enum ShadingQuality
-	{
-		Low = 2,
-		Normal = 1,
-		High = 0
-	}
-
-	public enum TextureFilter
-	{
-		Trilinear = 0,
-		Bilinear,
-		Aniso2X,
-		Aniso4X,
-		Aniso8X,
-		Aniso16X
-	}
-
-	public enum TextureQuality
-	{
-		High = 1,
-		Normal = 2,
-		Low = 3,
-		Highest = 0
-	}
-
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct DevParams
-	{
-		public int FpsGraphMax;
-		public int FtGraphMax;
-		public int WebServerPort;
-	}
-
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct GfxParams
-	{
-		public uint Flags;
-		public MsaaMode Msaa;
-		public TextureQuality TextureQuality;
-		public TextureFilter TextureFilter;
-		public ShadingQuality ShadingQuality;
-		public Renderer Renderer;
-		public uint AdapterID;
-		public uint Width;
-		public uint Height;
-		public uint RefreshRate;
-		public IntPtr Hwnd;
-	}
-
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct InitParams
-	{
-		public uint Flags;
-		public uint LockFps;
-		public uint ConsoleLineMax;
-		public IntPtr ProgInstance;
-		private GfxParams Gfx;
-		private DevParams Dev;
-		private Hmr.Core.Array ConsoleCMD;
-	}
-}

File SharpHammer/Engine/Lua.cs

-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace Hmr.Engine
-{
-	public class Lua
-	{
-		[SuppressUnmanagedCodeSecurity]
-		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "slua_runfile")]
-		public static extern void RunFile([In] [MarshalAs(UnmanagedType.LPStr)] string luaFile,
-			[MarshalAs(UnmanagedType.Bool)] bool absPath);
-
-		[SuppressUnmanagedCodeSecurity]
-		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "slua_runstring")]
-		public static extern void RunScript([In] [MarshalAs(UnmanagedType.LPStr)] string source);
-	}
-}