public static void Main(string[] args)
{
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
isDebugging = System.Diagnostics.Debugger.IsAttached || args.Contains(DualityApp.CmdArgDebug);
isRunFromEditor = args.Contains(DualityApp.CmdArgEditor);
isProfiling = args.Contains(DualityApp.CmdArgProfiling);
if (isDebugging || isRunFromEditor) ShowConsole();
DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game, args);
using (DualityLauncher launcherWindow = new DualityLauncher(
DualityApp.UserData.GfxWidth,
DualityApp.UserData.GfxHeight,
DualityApp.DefaultMode,
DualityApp.AppData.AppName,
(DualityApp.UserData.GfxMode == ScreenMode.Fullscreen && !isDebugging) ? GameWindowFlags.Fullscreen : GameWindowFlags.Default))
{
DualityApp.UserDataChanged += launcherWindow.OnUserDataChanged;
// Retrieve icon from executable file and set it as window icon
string executablePath = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
launcherWindow.Icon = System.Drawing.Icon.ExtractAssociatedIcon(executablePath);
// Go into native fullscreen mode
if (DualityApp.UserData.GfxMode == ScreenMode.Native && !isDebugging)
launcherWindow.WindowState = WindowState.Fullscreen;
if (DualityApp.UserData.GfxMode == ScreenMode.FixedWindow)
launcherWindow.WindowBorder = WindowBorder.Fixed;
else if (DualityApp.UserData.GfxMode == ScreenMode.Window)
launcherWindow.WindowBorder = WindowBorder.Resizable;
// Initialize default content
launcherWindow.MakeCurrent();
Log.Core.Write("OpenGL initialized");
Log.Core.PushIndent();
Log.Editor.Write("Vendor: {0}", GL.GetString(StringName.Vendor));
Log.Editor.Write("Version: {0}", GL.GetString(StringName.Version));
Log.Editor.Write("Renderer: {0}", GL.GetString(StringName.Renderer));
Log.Editor.Write("Shading language version: {0}", GL.GetString(StringName.ShadingLanguageVersion));
Log.Core.PopIndent();
if (ValidateMinimumGPUSpec() == false)
{
DualityApp.Terminate();
DisplayDevice.Default.RestoreResolution();
return;
}
DualityApp.TargetResolution = new Vector2(launcherWindow.ClientSize.Width, launcherWindow.ClientSize.Height);
DualityApp.TargetMode = launcherWindow.Context.GraphicsMode;
ContentProvider.InitDefaultContent();
// Input setup
DualityApp.Mouse.Source = new GameWindowMouseInputSource(launcherWindow.Mouse, launcherWindow.SetMouseDeviceX, launcherWindow.SetMouseDeviceY);
DualityApp.Keyboard.Source = new GameWindowKeyboardInputSource(launcherWindow.Keyboard);
// Load the starting Scene
Scene.SwitchTo(DualityApp.AppData.StartScene);
// Run the DualityApp
launcherWindow.CursorVisible = isDebugging || DualityApp.UserData.SystemCursorVisible;
SetVSyncMode(launcherWindow);
launcherWindow.Run();
// Shut down the DualityApp
DualityApp.Terminate();
DisplayDevice.Default.RestoreResolution();
}
}