Esempio n. 1
0
        public override void Render(double timestep)
        {
            var renderList = world.GetGlobalResource <RenderListStore>();

            RenderingPipeline.SetModels(renderList.Models);

            foreach (var light in renderList.Lights)
            {
                RenderingPipeline.AddPointLight(light);
            }

            var cameras = world.Components <CameraComponent>();
            var cam     = cameras.First();

            var pos = cam.PositionOffset;

            if (cam.TryGetSibling <TransformComponent>(out var xform))
            {
                pos += xform.Position;
            }

            var matrices = new GlobalUniform
            {
                ViewMatrix       = cam.ViewMatrix,
                ProjectionMatrix = cam.ProjectionMatrix,
                ViewPosition     = pos
            };

            RenderingPipeline.SetGlobals(matrices);

            graphics.BeginFrame(matrices);

            RenderingPipeline.DrawAndFlush();

            graphics.EndFrame();

            renderList.Clear();
        }