Package java.nio

Examples of java.nio.Buffer


      }
  }

  private void intialState(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    buf = factory.newInstance();
    checkStatus(h, buf, "intialState", 20, 20, true, 10, 10);
  }
View Full Code Here


    buf = factory.newInstance();
    checkStatus(h, buf, "intialState", 20, 20, true, 10, 10);
  }
  private void position(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    buf = factory.newInstance();
    h.check(buf.position(1), buf,  "position: buf.position(1)");
    checkStatus(h, buf, "position", 20, 20, true, 19, 1);
    buf.position(20);
    checkStatus(h, buf, "position", 20, 20, false, 0, 20);

    // position can't be negative
    buf = factory.newInstance();
    try
      {
        buf.position(-1);
        h.check(false, "position: is negative");
      }
      catch(IllegalArgumentException iae)
      {
        h.check(true, "position: can't be negative");
      }

    // position can't be larger than limit
    buf = factory.newInstance();
    buf.limit(5);
    try
      {
        buf.position(6);
        h.check(false, "position: is larger than capacity");
      }
      catch(IllegalArgumentException iae)
      {
        h.check(true, "position: can't be larger than capacity");
View Full Code Here

        h.check(true, "position: can't be larger than capacity");
      }
  }
  private void mark(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    // mark at default position
    buf = factory.newInstance();
    h.check(buf.mark(), buf, "mark: buf.mark()");
    checkStatus(h, buf, "mark", 20, 20, true, 10, 10);
    buf.position(15);
    checkStatus(h, buf, "mark", 20, 20, true, 5, 15);
    h.check(buf.reset(), buf, "mark: buf.reset()");
    checkStatus(h, buf, "mark", 20, 20, true, 10, 10);
    buf.position(16);
    checkStatus(h, buf, "mark", 20, 20, true, 4, 16);
    buf.reset();
    checkStatus(h, buf, "mark", 20, 20, true, 10, 10);

    // mark at specified position
    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    checkStatus(h, buf, "mark", 20, 20, true, 15, 5);
    buf.position(6);
    checkStatus(h, buf, "mark", 20, 20, true, 14, 6);
    buf.reset();
    checkStatus(h, buf, "mark", 20, 20, true, 15, 5);
    buf.position(7);
    checkStatus(h, buf, "mark", 20, 20, true, 13, 7);
    buf.reset();
    checkStatus(h, buf, "mark", 20, 20, true, 15, 5);

    // mark should be discarded if new position is smaller than mark
    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    buf.position(4);
    try
      {
        buf.reset();
        h.check(false, "mark: mark not invalidated");
      }
      catch(InvalidMarkException ime)
      {
        h.check(true, "mark: invalidated mark");
View Full Code Here

      }
    checkStatus(h, buf, "mark", 20, 20, true, 16, 4);
  }
  private void limit(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    buf = factory.newInstance();
    buf.position(2);
    buf.mark();
    buf.position(3);
    h.check(buf.limit(4), buf, "limit: buf.limit(4)");
    checkStatus(h, buf, "limit", 20, 4, true, 1, 3);
    buf.reset();
    checkStatus(h, buf, "limit", 20, 4, true, 2, 2);

    // mark should be discarded if new limit is smaller than mark
    // and position should be set to new limit
    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    buf.position(6);
    buf.limit(4);
    checkStatus(h, buf, "limit", 20, 4, false, 0, 4);
    try
      {
        buf.reset();
        h.check(false, "limit: mark not invalidated");
      }
      catch(InvalidMarkException ime)
      {
        h.check(true, "limit: invalidated mark");
      }

    // limit can't be negative
    buf = factory.newInstance();
    try
      {
        buf.limit(-1);
        h.check(false, "limit: is negative");
      }
      catch(IllegalArgumentException iae)
      {
        h.check(true, "limit: can't be negative");
      }

    // limit can't be larger than capacity
    buf = factory.newInstance();
    try
      {
        buf.limit(21);
        h.check(false, "limit: is larger than capacity");
      }
      catch(IllegalArgumentException iae)
      {
        h.check(true, "limit: can't be larger than capacity");
View Full Code Here

        h.check(true, "limit: can't be larger than capacity");
      }
  }
  private void rewind(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    buf.position(6);
    buf.limit(9);
    h.check(buf.rewind(), buf, "rewind: buf.rewind()");
    checkStatus(h, buf, "rewind", 20, 9, true, 9, 0);
    try
      {
        buf.reset();
        h.check(false, "rewind: mark not invalidated");
      }
      catch(InvalidMarkException ime)
      {
        h.check(true, "rewind: invalidated mark");
View Full Code Here

        h.check(true, "rewind: invalidated mark");
      }
  }
  private void clear(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    buf.position(6);
    buf.limit(7);
    h.check(buf.clear(), buf, "clear: buf.clear()");
    checkStatus(h, buf, "clear", 20, 20, true, 20, 0);
    try
      {
        buf.reset();
        h.check(false, "clear: mark not invalidated");
      }
      catch(InvalidMarkException ime)
      {
        h.check(true, "clear: invalidated mark");
View Full Code Here

        h.check(true, "clear: invalidated mark");
      }
  }
  private void flip(TestHarness h, BufferFactory factory)
  {
    Buffer buf = null;

    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    buf.position(6);
    h.check(buf.flip(), buf, "flip: buf.flip()");
    checkStatus(h, buf, "flip", 20, 6, true, 6, 0);
    try
      {
        buf.reset();
        h.check(false, "flip: mark not invalidated");
      }
      catch(InvalidMarkException ime)
      {
        h.check(true, "flip: invalidated mark");
View Full Code Here

      }
        } else {
      cdirty = dirtyFlag;
        }

        Buffer vcoord = null;
        Buffer cdataBuffer = null;
        FloatBuffer normal = null;

        int vdefined = 0;
        if((vertexType & PF!= 0) {
      vdefined |= COORD_FLOAT;
View Full Code Here

            updateVBO(data, rendRecord, vboID, 0);

            return vboID;
        }

        final Buffer dataBuffer = data.getBuffer();
        if (dataBuffer != null) {
            // XXX: should we be rewinding? Maybe make that the programmer's responsibility.
            dataBuffer.rewind();
            vboID = makeVBOId();
            data.setVBOID(context.getGlContextRep(), vboID);

            rendRecord.invalidateVBO();
            LwjglRendererUtil.setBoundVBO(rendRecord, vboID);
View Full Code Here

    }

    public static void updateVBO(final AbstractBufferData<? extends Buffer> data, final RendererRecord rendRecord,
            final int vboID, final int offsetBytes) {
        if (data.isNeedsRefresh()) {
            final Buffer dataBuffer = data.getBuffer();
            dataBuffer.rewind();
            LwjglRendererUtil.setBoundVBO(rendRecord, vboID);
            if (dataBuffer instanceof FloatBuffer) {
                ARBBufferObject.glBufferSubDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, offsetBytes,
                        (FloatBuffer) dataBuffer);
            } else if (dataBuffer instanceof ByteBuffer) {
View Full Code Here

TOP

Related Classes of java.nio.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.