Пример #1
0
        public override void OnAttach()
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(GetType());
#endif
            _quadData.SquareColor = ColorF.DarkRed;
            _quadData.QuadCount   = 10;
            ActiveScene
            .AddSystem(new VelocitySystem())
            .AddSystem(new QuadUpdateSystem())
            .Inject(_quadData)
            .Init();

            LoadStandardShaders();

            var camera = new Camera(false);
            camera.SetPerspective(MathUtil.Deg2Rad(70), .0001f, 1000f);
            camera.ResizeViewport(Width, Height);

            var editorCam = ActiveScene.CreateEmptyEntity();
            editorCam.AddComponent(new CameraComponent()
            {
                Camera = camera
            });
            editorCam.AddComponent(new TransformComponent()
            {
                Translation = new Vector3(1e-6f, 1e-6f, 1)
            });
            camera.BlendState        = BlendStateDescription.SingleAlphaBlend;
            camera.DepthStencilState = DepthStencilStateDescription.DepthOnlyLessEqual;
            camera.RasterizerState   = RasterizerStateDescription.CullNone;

            camera.RenderTarget = GraphicsDevice.SwapchainFramebuffer;

            var quad = ActiveScene.CreateEntity("Quad");
            quad.AddComponent(new SpriteRendererComponent()
            {
                Color      = _quadData.SquareColor,
                Material   = new Material("Standard2D"),
                SpriteData = RenderData2D.QuadData
            });
            ref var transform = ref quad.GetComponent <TransformComponent>();