Inheritance: OpenTK.GameWindow
示例#1
0
        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))
            {
                // 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();
                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;
                launcherWindow.VSync = (isProfiling || isDebugging) ? VSyncMode.Off : VSyncMode.On; // Don't limit frame rate when debugging.
                launcherWindow.Run();

                // Shut down the DualityApp
                DualityApp.Terminate();
            }
        }
示例#2
0
        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))
            {
                // 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();
                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;
                launcherWindow.VSync         = (isProfiling || isDebugging) ? VSyncMode.Off : VSyncMode.On;         // Don't limit frame rate when debugging.
                launcherWindow.Run();

                // Shut down the DualityApp
                DualityApp.Terminate();
            }
        }
示例#3
0
        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();
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        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);

            int  windowWidth  = DualityApp.UserData.GfxWidth;
            int  windowHeight = DualityApp.UserData.GfxHeight;
            bool isFullscreen = (DualityApp.UserData.GfxMode == ScreenMode.Fullscreen || DualityApp.UserData.GfxMode == ScreenMode.Native) && !isDebugging;

            if (DualityApp.UserData.GfxMode == ScreenMode.Native && !isDebugging)
            {
                windowWidth  = DisplayDevice.Default.Width;
                windowHeight = DisplayDevice.Default.Height;
            }

            using (DualityLauncher launcherWindow = new DualityLauncher(
                       windowWidth,
                       windowHeight,
                       DualityApp.DefaultMode,
                       DualityApp.AppData.AppName,
                       isFullscreen ? GameWindowFlags.Fullscreen : GameWindowFlags.Default))
            {
                // Retrieve icon from executable file and set it as window icon
                string executablePath = System.IO.Path.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
                if (System.IO.File.Exists(executablePath))
                {
                    launcherWindow.Icon = System.Drawing.Icon.ExtractAssociatedIcon(executablePath);
                }

                // Go into native fullscreen mode
                if (DualityApp.UserData.GfxMode == ScreenMode.FullWindow && !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;
                }

                // Specify additional window settings and initialize default content
                launcherWindow.MakeCurrent();
                launcherWindow.CursorVisible = isDebugging || DualityApp.UserData.SystemCursorVisible;
                launcherWindow.VSync         = (isProfiling || isDebugging || DualityApp.UserData.RefreshMode != RefreshMode.VSync) ? VSyncMode.Off : VSyncMode.On;
                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);

                // Debug Logs
                Log.Core.Write("Graphics window initialized: {0}Mode: {1}{0}VSync: {2}{0}SwapInterval: {3}{0}Flags: {4}{0}",
                               Environment.NewLine,
                               launcherWindow.Context.GraphicsMode,
                               launcherWindow.VSync,
                               launcherWindow.Context.SwapInterval,
                               new[] { isDebugging ? "Debugging" : null, isProfiling ? "Profiling" : null, isRunFromEditor ? "RunFromEditor" : null }.NotNull().ToString(", "));

                // Load the starting Scene
                Scene.SwitchTo(DualityApp.AppData.StartScene);

                // Run the DualityApp
                launcherWindow.Run();

                // Shut down the DualityApp
                DualityApp.Terminate();
            }
        }