Example #1
0
        /// <summary>
        ///
        /// </summary>
        internal void UpdateInternal()
        {
            /*if (skipFirstFrame) {
             *      skipFirstFrame = false;
             *      Thread.Sleep(1);
             *      return;
             * } */

            if (IsDisposed)
            {
                throw new ObjectDisposedException("Game");
            }

            if (!IsInitialized)
            {
                throw new InvalidOperationException("Game is not initialized");
            }

            bool isActive = IsActive;              // to reduce access to winforms.

            if (isActive != isActiveLastFrame)
            {
                isActiveLastFrame = isActive;
                if (isActive)
                {
                    Activated?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    Deactivated?.Invoke(this, EventArgs.Empty);
                }
            }

            if (Enabled)
            {
                if (requestFullscreenOnStartup)
                {
                    graphicsDevice.FullScreen  = requestFullscreenOnStartup;
                    requestFullscreenOnStartup = false;
                }

                if (requestReload)
                {
                    Reloading?.Invoke(this, EventArgs.Empty);
                    requestReload = false;
                }

                graphicsDevice.Prepare();
                graphicsDevice.Display.Prepare();

                //	pre update :
                gameTimeInternal.Update();

                InputDevice.UpdateInput();

                Frames.Update(gameTimeInternal);
                Console.Update(gameTimeInternal);

                //GIS.Update(gameTimeInternal);

                UpdateClientServerGame(gameTimeInternal);

                //
                //	Sound :
                //
                SoundSystem.Update(gameTimeInternal);

                //
                //	Render :
                //
                var eyeList = graphicsDevice.Display.StereoEyeList;

                foreach (var eye in eyeList)
                {
                    GraphicsDevice.ResetStates();

                    GraphicsDevice.Display.TargetEye = eye;

                    GraphicsDevice.RestoreBackbuffer();

                    GraphicsDevice.ClearBackbuffer(Color.Zero);

                    this.Draw(gameTimeInternal, eye);
                }

                GraphicsDevice.Present(RenderSystem.VSyncInterval);

                InputDevice.EndUpdateInput();
            }

            try {
                invoker.ExecuteQueue(gameTimeInternal, CommandAffinity.Default);
            } catch (Exception e) {
                Log.Error(e.Message);
            }

            CheckExitInternal();
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        internal void UpdateInternal()
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException("Game");
            }

            if (!IsInitialized)
            {
                throw new InvalidOperationException("Game is not initialized");
            }

            bool isActive = IsActive;              // to reduce access to winforms.

            if (isActive != isActiveLastFrame)
            {
                isActiveLastFrame = isActive;
                if (isActive)
                {
                    if (Activated != null)
                    {
                        Activated(this, EventArgs.Empty);
                    }
                }
                else
                {
                    if (Deactivated != null)
                    {
                        Deactivated(this, EventArgs.Empty);
                    }
                }
            }

            if (Enabled)
            {
                if (requestReload)
                {
                    if (Reloading != null)
                    {
                        Reloading(this, EventArgs.Empty);
                    }
                    requestReload = false;
                }

                graphicsDevice.Display.Prepare();

                //	pre update :
                gameTimeInternal.Update();

                InputDevice.UpdateInput();

                //
                //	Update :
                //
                this.Update(gameTimeInternal);

                //
                //	Render :
                //
                var eyeList = graphicsDevice.Display.StereoEyeList;

                foreach (var eye in eyeList)
                {
                    GraphicsDevice.ResetStates();

                    GraphicsDevice.Display.TargetEye = eye;

                    GraphicsDevice.RestoreBackbuffer();

                    GraphicsDevice.ClearBackbuffer(Color.Zero);

                    this.Draw(gameTimeInternal, eye);

                    gameTimeInternal.AddSubframe();
                }

                GraphicsDevice.Present();

                InputDevice.EndUpdateInput();
            }

            try {
                invoker.ExecuteQueue(gameTimeInternal);
            } catch (Exception e) {
                Log.Error(e.Message);
            }

            CheckExitInternal();
        }