Example #1
0
        /// <summary>
        /// Upload the data to a display list.
        /// </summary>
        /// <param name="displayList">The display list that should receive the data</param>
        public void Render(IChangeableDisplayList <VertexPositionColor> displayList)
        {
            if (displayList == null)
            {
                throw new ArgumentNullException(nameof(displayList));
            }

            var(verts, inds) = Render();
            displayList.SetIndices(inds);
            displayList.SetVertices(verts);
        }
        private void Setup()
        {
            random = new Random();
            font   = Font.GenerateFromFont("OpenSans-Regular.ttf", 50);
            var textSprites = font.DrawString("HelloWorld", 0, 0);

            renderer = new SpriteRenderer();
            renderer.SetRenderItems(textSprites);
            resourceSet = new TextureResourceSet(window);
            displayList = DynamicDisplayList <VertexPositionColorTexture> .Create(renderer);

            renderer.RenderToData((vertices, count, tex) =>
            {
                displayList.SetIndices(SpriteRenderer.GetIndices(count));
                displayList.SetVertices(vertices);
                resourceSet.Texture = tex;
            });
        }