public void BeforeTest(TestDetails details)
		{
			Console.WriteLine("----- Beginning Duality environment setup -----");

			// Set environment directory to Duality binary directory
			this.oldEnvDir = Environment.CurrentDirectory;
			string codeBaseURI = typeof(DualityApp).Assembly.CodeBase;
			string codeBasePath = codeBaseURI.StartsWith("file:") ? codeBaseURI.Remove(0, "file:".Length) : codeBaseURI;
			codeBasePath = codeBasePath.TrimStart('/');
			Environment.CurrentDirectory = Path.GetDirectoryName(codeBasePath);

			// Add some Console logs manually for NUnit
			if (!Log.Core.Outputs.OfType<TextWriterLogOutput>().Any(o => o.Target == Console.Out))
			{
				if (this.consoleLogOutput == null) this.consoleLogOutput = new TextWriterLogOutput(Console.Out);
				Log.AddGlobalOutput(this.consoleLogOutput);
			}

			// Initialize Duality
			DualityApp.Init(
				DualityApp.ExecutionEnvironment.Launcher, 
				DualityApp.ExecutionContext.Game, 
				new DefaultPluginLoader(),
				null);

			// Manually register pseudo-plugin for the Unit Testing Assembly
			this.unitTestPlugin = DualityApp.LoadPlugin(typeof(DualityTestsPlugin).Assembly, codeBasePath);

			// Create a dummy window, to get access to all the device contexts
			if (this.dummyWindow == null)
			{
				WindowOptions options = new WindowOptions
				{
					Width = 800,
					Height = 600
				};
				this.dummyWindow = DualityApp.OpenWindow(options);
			}

			// Load local testing memory
			TestHelper.LocalTestMemory = Serializer.TryReadObject<TestMemory>(TestHelper.LocalTestMemoryFilePath, typeof(XmlSerializer));

			Console.WriteLine("----- Duality environment setup complete -----");
		}
Beispiel #2
0
        public static void Main()
        {
            DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game);

            WindowOptions options = new WindowOptions
            {
                Width = 800,
                Height = 600
            };
            using (INativeWindow launcherWindow = DualityApp.OpenWindow(options))
            {
                // Run tests
                BitmapDebuggerVisualizer.TestShow(Pixmap.DualityIcon.Res);
                BitmapDebuggerVisualizer.TestShow(Pixmap.DualityIcon.Res.MainLayer);
                BitmapDebuggerVisualizer.TestShow(Texture.DualityIcon.Res);
                BitmapDebuggerVisualizer.TestShow(Font.GenericMonospace10.Res.Material.MainTexture.Res);
            }
            DualityApp.Terminate();
        }
Beispiel #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;

            bool isDebugging = System.Diagnostics.Debugger.IsAttached || args.Contains(DualityApp.CmdArgDebug);
            bool isRunFromEditor = args.Contains(DualityApp.CmdArgEditor);
            bool isProfiling = args.Contains(DualityApp.CmdArgProfiling);
            if (isDebugging || isRunFromEditor) ShowConsole();

            Log.Core.Write("Running DualityLauncher with flags: {1}{0}",
                Environment.NewLine,
                new[] { isDebugging ? "Debugging" : null, isProfiling ? "Profiling" : null, isRunFromEditor ? "RunFromEditor" : null }.NotNull().ToString(", "));

            // Initialize the Duality core
            DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game, args);

            // Open up a new window
            WindowOptions options = new WindowOptions
            {
                Width = DualityApp.UserData.GfxWidth,
                Height = DualityApp.UserData.GfxHeight,
                ScreenMode = isDebugging ? ScreenMode.Window : DualityApp.UserData.GfxMode,
                RefreshMode = (isDebugging || isProfiling) ? RefreshMode.NoSync : DualityApp.UserData.RefreshMode,
                Title = DualityApp.AppData.AppName,
                SystemCursorVisible = isDebugging || DualityApp.UserData.SystemCursorVisible
            };
            using (INativeWindow window = DualityApp.OpenWindow(options))
            {
                // Load the starting Scene
                Scene.SwitchTo(DualityApp.AppData.StartScene);

                // Enter the applications update / render loop
                window.Run();
            }

            // Shut down the Duality core
            DualityApp.Terminate();
        }
Beispiel #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;

            bool isDebugging = System.Diagnostics.Debugger.IsAttached || args.Contains(DualityApp.CmdArgDebug);
            bool isRunFromEditor = args.Contains(DualityApp.CmdArgEditor);
            bool isProfiling = args.Contains(DualityApp.CmdArgProfiling);
            if (isDebugging || isRunFromEditor) ShowConsole();

            // Set up console logging
            Log.AddGlobalOutput(new ConsoleLogOutput());

            // Set up file logging
            StreamWriter logfileWriter = null;
            TextWriterLogOutput logfileOutput = null;
            try
            {
                logfileWriter = new StreamWriter("logfile.txt");
                logfileWriter.AutoFlush = true;
                logfileOutput = new TextWriterLogOutput(logfileWriter);
                Log.AddGlobalOutput(logfileOutput);
            }
            catch (Exception e)
            {
                Log.Core.WriteWarning("Text Logfile unavailable: {0}", Log.Exception(e));
            }

            // Write initial log message before actually booting Duality
            Log.Core.Write("Running DualityLauncher with flags: {1}{0}",
                Environment.NewLine,
                new[] { isDebugging ? "Debugging" : null, isProfiling ? "Profiling" : null, isRunFromEditor ? "RunFromEditor" : null }.NotNull().ToString(", "));

            // Initialize the Duality core
            DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game, args);

            // Open up a new window
            WindowOptions options = new WindowOptions
            {
                Width = DualityApp.UserData.GfxWidth,
                Height = DualityApp.UserData.GfxHeight,
                ScreenMode = isDebugging ? ScreenMode.Window : DualityApp.UserData.GfxMode,
                RefreshMode = (isDebugging || isProfiling) ? RefreshMode.NoSync : DualityApp.UserData.RefreshMode,
                Title = DualityApp.AppData.AppName,
                SystemCursorVisible = isDebugging || DualityApp.UserData.SystemCursorVisible
            };
            using (INativeWindow window = DualityApp.OpenWindow(options))
            {
                // Load the starting Scene
                Scene.SwitchTo(DualityApp.AppData.StartScene);

                // Enter the applications update / render loop
                window.Run();
            }

            // Shut down the Duality core
            DualityApp.Terminate();

            // Clean up the log file
            if (logfileWriter != null)
            {
                Log.RemoveGlobalOutput(logfileOutput);
                logfileWriter.Flush();
                logfileWriter.Close();
                logfileWriter = null;
                logfileOutput = null;
            }
        }