Exemplo n.º 1
0
            private IVertexBuffer BindVertexBuffer(DrawList drawList)
            {
                Watertight.Math.Vertex[] Verts = new Math.Vertex[drawList.VertexBuffer.Count];
                ushort[] Indicies = new ushort[drawList.IndexBuffer.Count];

                for (int x = 0; x < drawList.VertexBuffer.Count; x++)
                {
                    FlowUI.Draw.Vertex FlowVtx = drawList.VertexBuffer.ElementAt(x);
                    Verts[x] = new Math.Vertex
                    {
                        Location = new Vector3(FlowVtx.Pos, 0),
                        Color    = FlowVtx.Color,
                        UV       = FlowVtx.UV
                    };
                }

                for (int i = 0; i < drawList.IndexBuffer.Count; i++)
                {
                    Indicies[i] = drawList.IndexBuffer.ElementAt(i);
                }

                if (InternalVertexBuffer == null)
                {
                    InternalVertexBuffer = IEngine.Instance.Renderer.RendererResourceFactory.CreateVertexBuffer();
                }

                InternalVertexBuffer.SetVertexData(Verts, Indicies);

                return(InternalVertexBuffer);
            }
Exemplo n.º 2
0
            private IVertexBuffer CreateVertexBuffer(ImDrawListPtr DrawList)
            {
                Vertex[] Verts = new Vertex[DrawList.VtxBuffer.Size];

                for (int x = 0; x < DrawList.VtxBuffer.Size; x++)
                {
                    Verts[x] = new Vertex
                    {
                        Location = new System.Numerics.Vector3(DrawList.VtxBuffer[x].pos, 0),
                        UV       = DrawList.VtxBuffer[x].uv,
                        Color    = Color.FromArgb((int)DrawList.VtxBuffer[x].col)
                    };
                }

                ushort[] Ind = new ushort[DrawList.IdxBuffer.Size];
                for (int x = 0; x < DrawList.IdxBuffer.Size; x++)
                {
                    Ind[x] = DrawList.IdxBuffer[x];
                }

                if (VertexBuffer == null)
                {
                    VertexBuffer = IEngine.Instance.Renderer.RendererResourceFactory.CreateVertexBuffer();
                }
                VertexBuffer.SetVertexData(Verts, Ind);

                return(VertexBuffer);
            }
Exemplo n.º 3
0
        public override void OnStart()
        {
            base.OnStart();

            Vertex[] vertices = new Vertex[]
            {
                new Vertex
                {
                    Location = new System.Numerics.Vector3(-0.5f, -0.5f, 0),
                    Color    = Color.Gold,
                    UV       = Vector2.Zero,
                },
                new Vertex
                {
                    Location = new System.Numerics.Vector3(0.5f, -0.5f, 0),
                    Color    = Color.Red,
                    UV       = Vector2.Zero,
                },
                new Vertex
                {
                    Location = new System.Numerics.Vector3(0.5f, 0.5f, 0),
                    Color    = Color.Blue,
                    UV       = Vector2.Zero,
                },
                new Vertex
                {
                    Location = new System.Numerics.Vector3(-0.5f, 0.5f, 0),
                    Color    = Color.Green,
                    UV       = Vector2.Zero,
                },
            };

            ushort[] ind = new ushort[]
            {
                0, 1, 2,
                2, 3, 0,
            };

            CameraComp = new CameraComponent(null);
            CameraComp.Register();
            CameraComp.MakeActive();

            const bool TestPerspective = false;

            if (TestPerspective)
            {
                CameraComp.Mode     = CameraComponent.ProjectionMode.Perspective;
                CameraComp.Location = new Vector3(200, 100, 500);
                CameraComp.LookAt(Vector3.Zero);
            }
            else
            {
                CameraComp.Mode = CameraComponent.ProjectionMode.Orthographic;
            }


            IVertexBuffer VertexBuffer = Renderer.RendererResourceFactory.CreateVertexBuffer();

            VertexBuffer.SetVertexData(vertices, ind);

            Command = Renderer.RendererResourceFactory.CreateRenderCommand()
                      .WithDebugName("Sample Game Render")
                      .WithMaterial(Renderer.DefaultMaterialPtr.Get <Material>())
                      .WithVertexBuffer(VertexBuffer);


            SampleRenderable renderable = new SampleRenderable(Command);

            Renderer.AddRenderable(renderable);
        }