Esempio n. 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.Black, 1.0f, 0);

            DeferredRenderer.Render3DStuff(GraphicsDevice);
            Renderer2D.Render(GraphicsDevice);

            base.Draw(gameTime);
        }
Esempio n. 2
0
        public static void Process()
        {
            // limit FPS and handle events
            int  minMsec = (com_maxFPS.GetValue <int>() > 0) ? (1000 / com_maxFPS.GetValue <int>()) : 1;
            uint msec    = 0;

            do
            {
                _frameTime = EventSystem.HandleEvents();

                msec = _frameTime - _lastTime;
            } while (msec < minMsec);

            // handle time scaling
            var scale = timescale.GetValue <float>();

            msec = (uint)(msec * scale);

            if (msec < 1)
            {
                msec = 1;
            }
            else if (msec > 5000)
            {
                msec = 5000;
            }

            if (msec > 500)
            {
                Log.Write(LogLevel.Info, "Hitch warning: {0} msec frame time", msec);
            }

            DeltaTime = msec / 1000f;
            FrameMsec = msec;

            _lastTime = _frameTime;

            // process the command buffer
            Command.ExecuteBuffer();

            // handle network stuff
            NetManager.Process();

            // process game stuff
            Server.Process();

            // process client
            Client.Process();

            // more stuff (needs to be moved)
            Camera.Process();

            if (!sv_running.GetValue <bool>())
            {
                CellManager.Recenter(new[] { Camera.MainCamera.Position });
            }

            Renderer2D.InitPerFrame();
            FontManager.SetColor(Color.White);

            // camera moving
            DebugCamera.Process();

            ConsoleRenderer.Process();

            // render stuff
            if (Renderer.MakeDeviceAvailable())
            {
                Renderer.Clear();

                if (Client.State == Client.ClientState.Ingame)
                {
                    DeferredRenderer.Render3DStuff(Renderer.Device);
                }

                Renderer2D.Render(Renderer.Device);
                Renderer.Device.Present();
            }
        }