Exemplo n.º 1
0
        void IncrementalIndexTest(PrimitiveType pt, bool ver, bool col)
        {
            // test one, just put vertex data in only, same stride, same lenghts.  Check the correct data ends up back in.
            int nd = 5 * buf.primsizes[pt] * (2 + 4); // 5 quads

            for (int i = 0; i < 3; i++)               // 3 times
            {
                int       st = i * nd;
                ArrayData ad = 0 | (ver ? ArrayData.Vertex : 0) | (col ? ArrayData.Color : 0);
                var       r  = new RenderInfo(st, nd, ad, pt);
                for (int j = st; j < st + nd; j++)
                {
                    rd.sofwareBuffer.Add(j);
                }
                rd.bufferInfo.Add(r);
            }
            rp.ProcessRenderBuffer(rd);

            // check we haaave got ...erm...vertexes
            int chk = 0;

            foreach (var p in buf.renderlist)
            {
                Assert.AreEqual(p.pt, pt);
                foreach (var d in p.data)
                {
                    Assert.IsNull(d.t);
                    if (ver)
                    {
                        Assert.AreEqual(d.v.x, chk++);
                        Assert.AreEqual(d.v.y, chk++);
                    }
                    else
                    {
                        Assert.IsNull(d.v);
                    }
                    if (col)
                    {
                        Assert.AreEqual(d.c.a, chk++);
                        Assert.AreEqual(d.c.r, chk++);
                        Assert.AreEqual(d.c.g, chk++);
                        Assert.AreEqual(d.c.b, chk++);
                    }
                    else
                    {
                        Assert.IsNull(d.c);
                    }
                }
            }
            buf.ResetBuffer();
        }
Exemplo n.º 2
0
        public void OneFigureNLines(int n)
        {
            // Draw path
            UPath path = new UPath();

            path.figures.Add(new UFigure(new Point(0, 0), false, true));
            List <float> dpts = new List <float>()
            {
                0, 0, 1, 1, 1, 1
            };

            for (int i = 0; i < n; i++)
            {
                float x = 3 * .2f * i + .5f * i * i;
                float y = 1 * .6f * i + .2f * i * i;
                path.figures[0].geoElements.Add(new ULine(new Point(x, y)));
                dpts.AddRange(new float[] { x, y, 1, 1, 1, 1 });
                if (i != n - 1)
                {
                    dpts.AddRange(new float[] { x, y, 1, 1, 1, 1 });
                }
            }
            mockedDraw.DrawPath(path, new USolidBrush()
            {
                color = new Color(1, 1, 1, 1)
            }, new UStroke());

            // Process data (will need to when otkdraw puts in vbos...and crashfixy interface mocky...)
            proc.ProcessRenderBuffer(rd);

            // Check data
            Assert.AreEqual(1, buf.renderlist.Count); // should just be 1 line rendered in VC with 2 points
            Assert.AreEqual(buf.renderlist[0].pt, PrimitiveType.Lines);
            AssertEqual(
                buf.renderlist[0],
                dpts.ToArray()
                );

            buf.ResetBuffer();
        }