VirtualIndexBuffer extends IndexBuffer { @Override public int get() { int i = get(position); position++; return i; } VirtualIndexBuffer(int numVerts, Mode meshMode); @Override int get(); @Override void rewind(); @Override int remaining(); @Override int get(int i); @Override IndexBuffer put(int i, int value); @Override int size(); @Override Buffer getBuffer(); @Override IndexBuffer put(int value); @Override Format getFormat();  }
@Test public void testGet() { IntBuffer ib = IntBuffer.allocate(27); final VirtualIndexBuffer bufferPoints = new VirtualIndexBuffer(27, Mode.Points); for (int i=0; i<27; i++) {ib.put(bufferPoints.get());} assertArrayEquals(new int[]{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}, ib.array()); ib.clear(); assertEquals(0, bufferPoints.remaining()); final VirtualIndexBuffer bufferLines = new VirtualIndexBuffer(27, Mode.Lines); for (int i=0; i<27; i++) {ib.put(bufferLines.get());} assertArrayEquals(new int[]{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}, ib.array()); assertEquals(0, bufferLines.remaining()); ib.clear(); final VirtualIndexBuffer bufferTriangles = new VirtualIndexBuffer(27, Mode.Triangles); for (int i=0; i<27; i++) {ib.put(bufferTriangles.get());} assertArrayEquals(new int[]{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}, ib.array()); assertEquals(0, bufferTriangles.remaining()); ib.clear(); final VirtualIndexBuffer bufferLineStrip = new VirtualIndexBuffer(27, Mode.LineStrip); for (int i=0; i<27; i++) {ib.put(bufferLineStrip.get());} assertArrayEquals(new int[]{ 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}, ib.array()); assertEquals(25, bufferLineStrip.remaining()); ib.clear(); final VirtualIndexBuffer bufferLineLoop = new VirtualIndexBuffer(27, Mode.LineLoop); for (int i=0; i<27; i++) {ib.put(bufferLineLoop.get());} assertArrayEquals(new int[]{ 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 0}, ib.array()); assertEquals(26, bufferLineLoop.remaining()); ib.clear(); final VirtualIndexBuffer bufferTriangleStrip = new VirtualIndexBuffer(27, Mode.TriangleStrip); for (int i=0; i<27; i++) {ib.put(bufferTriangleStrip.get());} assertArrayEquals(new int[]{ 0, 1, 2, 2, 1, 3, 2, 3, 4, 4, 3, 5, 4, 5, 6, 6, 5, 7, 6, 7, 8, 8, 7, 9, 8, 9, 10}, ib.array()); assertEquals(48, bufferTriangleStrip.remaining()); ib.clear(); final VirtualIndexBuffer bufferTriangleFan = new VirtualIndexBuffer(27, Mode.TriangleFan); for (int i=0; i<27; i++) {ib.put(bufferTriangleFan.get());} assertArrayEquals(new int[]{ 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 7, 0, 7, 8, 0, 8, 9, 0, 9, 10}, ib.array()); assertEquals(48, bufferTriangleFan.remaining()); ib.clear(); }
@Test public void testGet_Patch() { final VirtualIndexBuffer bufferPatch = new VirtualIndexBuffer(27, Mode.Patch); thrown.expect(UnsupportedOperationException.class); bufferPatch.get(); }