Esempio n. 1
0
        public NinePatch(NinePatchStyle style)
        {
            this.style = style;

            //mesh = new Mesh.Mesh(BufferUsageHint.DynamicDraw);
            mesh = new RenderStack.Mesh.Mesh();

            VertexFormat vertexFormat = new VertexFormat();

            vertexFormat.Add(new Attribute(VertexUsage.Position, VertexAttribPointerType.Float, 0, 3));
            vertexFormat.Add(new Attribute(VertexUsage.TexCoord, VertexAttribPointerType.Float, 0, 2));

            // \todo Allocate vertex buffers form from UI BufferPool and use double buffered Buffers
            // \todo Share one index buffer among all UI components that have the same index buffer
            //Buffer vertexBuffer = BufferPool.Instance.GetVertexBuffer(vertexFormat, BufferUsageHint.DynamicDraw);
            //Buffer indexBuffer = BufferPool.Instance.GetIndexBuffer(DrawElementsType.UnsignedShort, BufferUsageHint.StaticDraw);
            vertexBuffer = BufferFactory.Create(vertexFormat, BufferUsageHint.DynamicDraw);
            indexBuffer  = BufferFactory.Create(DrawElementsType.UnsignedShort, BufferUsageHint.StaticDraw);

            mesh.VertexBufferRange = vertexBuffer.CreateVertexBufferRange();
            IBufferRange indexBufferRange = mesh.FindOrCreateIndexBufferRange(
                MeshMode.PolygonFill,
                indexBuffer,
                BeginMode.Triangles
                );
            var writer = new IndexBufferWriter(indexBufferRange);

            vertexWriter = new VertexBufferWriter(mesh.VertexBufferRange);

            //  12 13 14 15
            //
            //   8  9 10 11
            //
            //   4  5  6  7
            //
            //   0  1  2  3

            writer.BeginEdit();

            writer.Quad(4, 5, 1, 0); writer.CurrentIndex += 6;
            writer.Quad(5, 6, 2, 1); writer.CurrentIndex += 6;
            writer.Quad(6, 7, 3, 2); writer.CurrentIndex += 6;

            writer.Quad(8, 9, 5, 4); writer.CurrentIndex   += 6;
            writer.Quad(9, 10, 6, 5); writer.CurrentIndex  += 6;
            writer.Quad(10, 11, 7, 6); writer.CurrentIndex += 6;

            writer.Quad(12, 13, 9, 8); writer.CurrentIndex   += 6;
            writer.Quad(13, 14, 10, 9); writer.CurrentIndex  += 6;
            writer.Quad(14, 15, 11, 10); writer.CurrentIndex += 6;

            writer.EndEdit();

            // \bug
            //indexBuffer.UpdateAll();
        }
Esempio n. 2
0
 public Style(
     Vector2 padding,
     Vector2 innerpadding,
     FontStyle fontStyle,
     NinePatchStyle ninePatchStyle,
     IProgram program
     )
 {
     Padding        = padding;
     InnerPadding   = innerpadding;
     Font           = fontStyle;
     NinePatchStyle = ninePatchStyle;
     Program        = program;
 }