private static void RenderEntities(GameEngine engine, GraphicsRenderer renderer, GameTime gameTime,
                                    List <CoreAbstractEntity> entities, ClientMapTile onTile, float tileDrawX, float tileDrawY)
 {
     foreach (CoreAbstractEntity entity in entities)
     {
         EntityRenderer entityRenderer = EntityRenderers.Get(entity);
         entityRenderer.Render(engine, renderer, gameTime, entity, onTile, tileDrawX, tileDrawY);
     }
 }
Beispiel #2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            _frameBuffer.Bind();//TODO
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //gt.updateTimer();
            //Console.WriteLine(gt.renderPartialTicks);

            DateTime now = DateTime.Now;

            _partialTicks = (float)MathHelper.Clamp((now - _updateTimer).TotalSeconds / TargetUpdatePeriod, 0, 1);

            if (_ticked)
            {
                _ticked = false;

                //Console.WriteLine(_partialTicks);
                _partialTicks %= 1f;
            }

            if ((now - _lastFpsDate).TotalMilliseconds >= 1000)
            {
                _fpsCounterLast = _fpsCounter;
                _fpsCounter     = 0;
                _lastFpsDate    = now;
            }

            RunGlTasks();

            HandleMouseMovement();
            Camera.UpdateViewMatrix();

            //RENDER SCREEN
            if (World != null)
            {
                SkyboxRenderer?.Render(_partialTicks);
                WorldRenderer?.Render(World, _partialTicks);
                ParticleRenderer?.Render(_partialTicks);
                EntityRenderer?.Render(_partialTicks);
            }

            //render other gui
            if (Player != null)
            {
                GuiRenderer?.RenderCrosshair();
                GuiRenderer?.RenderHUD();
            }

            //render gui screen
            if (GuiScreen != null)
            {
                CursorVisible = true;
                GuiRenderer?.Render(GuiScreen);
            }

            if (_takeScreenshot)
            {
                _takeScreenshot = false;

                CaptureScreen();
            }

            _frameBuffer.BindDefault();
            _frameBuffer.CopyToScreen();//TODO

            SwapBuffers();

            _fpsCounter++;
            //_spinner.SpinOnce();
        }