Пример #1
0
        public static void Main(string canvasId)
        {
            // Create app
            _application = new MyApplication();

            // Create Services
            var windowsSystem = new WebWindowsSystem();

            _application.Container.RegisterInstance(windowsSystem);

            var document = (JSObject)Runtime.GetGlobalObject("document");
            var canvas   = (JSObject)document.Invoke("getElementById", canvasId);
            var surface  = (WebSurface)windowsSystem.CreateSurface(canvas);

            AppCanvas[canvasId] = surface;
            ConfigureGraphicsContext(_application, surface);

            // Audio is currently unsupported
            //var xaudio = new WaveEngine.XAudio2.XAudioDevice();
            //application.Container.RegisterInstance(xaudio);

            var notifier = new JavaScriptHotspotNotifier();

            _application.Container.RegisterInstance <IHotspotNotifier>(notifier);

            var clockTimer = Stopwatch.StartNew();

            windowsSystem.Run(
                () =>
            {
                Runtime.InvokeJS($"App.saveToLocalStorage('BetiJaiDemoStarting', '{DateTime.Now}');");
                _application.Initialize();
                Runtime.InvokeJS("WaveEngine.init();");
            },
                () =>
            {
                var gameTime = clockTimer.Elapsed;
                clockTimer.Restart();

                _application.UpdateFrame(gameTime);
                _application.DrawFrame(gameTime);
            });
        }
Пример #2
0
        public static void Main(string canvasId)
        {
            // Hack for AOT dll dependencies
            var cp = new WaveEngine.Components.Graphics3D.Spinner();

            // Create app
            var application = new MyApplication();

            // Create Services
            var windowsSystem = new WebWindowsSystem();

            application.Container.RegisterInstance(windowsSystem);

            var document = (JSObject)Runtime.GetGlobalObject("document");
            var canvas   = (JSObject)document.Invoke("getElementById", canvasId);
            var surface  = (WebSurface)windowsSystem.CreateSurface(canvas);

            appCanvas[canvasId] = surface;
            ConfigureGraphicsContext(application, surface);

            // Audio is currently unsupported
            //var xaudio = new WaveEngine.XAudio2.XAudioDevice();
            //application.Container.RegisterInstance(xaudio);

            Stopwatch clockTimer = Stopwatch.StartNew();

            windowsSystem.Run(
                () =>
            {
                application.Initialize();
                Runtime.InvokeJS("WaveEngine.init();");
            },
                () =>
            {
                var gameTime = clockTimer.Elapsed;
                clockTimer.Restart();

                application.UpdateFrame(gameTime);
                application.DrawFrame(gameTime);
            });
        }