Beispiel #1
0
        private void Window_RenderFrame(object sender, TimeEventArgs e)
        {
            serverConnection.ProcessMessages();

            HandleInput(e.Time);

            camera.Position    = world.Player.Position;
            camera.Orientation = world.Player.Orientation;

            world.Update(e.Time);

            while (DeferredTasks.Count > 0)
            {
                if (DeferredTasks.TryDequeue(out var task))
                {
                    task();
                }
            }

            GL.ClearColor(0.6f, 0.7f, 0.8f, 1);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);

            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);

            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.ScissorTest);
            GL.Disable(EnableCap.StencilTest);

            GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
            GL.PolygonMode(MaterialFace.Back, PolygonMode.Line);

            blockTextureAtlas.Texture.Bind();

            var aspect = window.Width / (float)window.Height;

            worldRenderer.Draw(worldProgram, aspect, e.Time);

            userInterface.Draw(e.Time);

            GL.Disable(EnableCap.ScissorTest);
        }