示例#1
0
文件: Program.cs 项目: veserine/Neo
        static void Main()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            AppDomain.CurrentDomain.UnhandledException += (args, e) => Log.Debug(e.ExceptionObject.ToString());

            var baseDir     = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? Directory.GetCurrentDirectory();
            var profilesDir = Path.Combine(baseDir, "JitProfiles");

            if (!Directory.Exists(profilesDir))
            {
                Directory.CreateDirectory(profilesDir);
            }

            var dbcdir = Path.Combine(baseDir, "DBC");

            if (!Directory.Exists(dbcdir))
            {
                Directory.CreateDirectory(dbcdir);
            }

            ProfileOptimization.SetProfileRoot(profilesDir);
            ProfileOptimization.StartProfile("JitProfile.jpf");

            FontCollection.Initialize();
            Settings.KeyBindings.Initialize();
            XmlService.Initialize();

            var window  = new EditorWindow();
            var context = new GxContext(window.DrawTarget);

            context.InitContext();

            // TODO: move all shader initializations somehwere?
            context.InitShaders();

            WorldFrame.Instance.Initialize(window.DrawTarget, context);
            WorldFrame.Instance.OnResize((int)window.RenderSize.Width, (int)window.RenderSize.Height);

            var wnd = new MainWindow {
                elementHost1 = { Child = window }
            };

            wnd.Show();
            var isClosed = false;

            wnd.FormClosing += (sender, args) => isClosed = true;

            while (isClosed == false)
            {
                context.BeginFrame();
                WorldFrame.Instance.OnFrame();
                context.EndFrame();
                System.Windows.Forms.Application.DoEvents();
            }

            WorldFrame.Instance.Shutdown();
        }