Example usage for java.nio IntBuffer clear

List of usage examples for java.nio IntBuffer clear

Introduction

In this page you can find the example usage for java.nio IntBuffer clear.

Prototype

public final Buffer clear() 

Source Link

Document

Clears this buffer.

Usage

From source file:Main.java

/**
 * Create a new int[] array and populate it with the given IntBuffer's
 * contents.//from   www  .j  a va 2s  . c o  m
 * 
 * @param buff
 *            the IntBuffer to read from
 * @return a new int array populated from the IntBuffer
 */
public static int[] getIntArray(IntBuffer buff) {
    if (buff == null) {
        return null;
    }
    buff.clear();
    int[] inds = new int[buff.limit()];
    for (int x = 0; x < inds.length; x++) {
        inds[x] = buff.get();
    }
    return inds;
}

From source file:Main.java

public static IntBuffer createIntBuffer(final int... data) {
    if (data == null) {
        return null;
    }// w  w  w .  j  av a 2 s.  c  o m
    final IntBuffer buff = createIntBuffer(data.length);
    buff.clear();
    buff.put(data);
    buff.flip();
    return buff;
}

From source file:Main.java

public static IntBuffer createIntBufferOnHeap(final int size) {
    final IntBuffer buf = ByteBuffer.allocate(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer();
    buf.clear();
    return buf;//from   w ww .j  a  v  a 2s .c  o m
}

From source file:Main.java

public static IntBuffer createIntBufferOnHeap(final int size) {
    final IntBuffer buf = ByteBuffer.allocate(SIZEOF_FLOAT * size).order(ByteOrder.nativeOrder()).asIntBuffer();
    buf.clear();
    return buf;// w ww  . jav  a  2 s  . co m
}

From source file:Main.java

public static IntBuffer createIntBuffer(final int size) {
    final IntBuffer buf = ByteBuffer.allocateDirect(SIZEOF_FLOAT * size).order(ByteOrder.nativeOrder())
            .asIntBuffer();//from  ww w. j  av a2 s  .c  o m
    buf.clear();
    return buf;
}

From source file:Main.java

public static Buffer setupIntBuffer(IntBuffer preBuffer, int[] array) {

    if (preBuffer == null || preBuffer.capacity() < array.length) {
        preBuffer = createIntBuffer(array.length * 2);
    } else {/*from   w ww .j  a  v a  2s . c  o  m*/
        preBuffer.clear();
    }

    preBuffer.clear();
    preBuffer.put(array);
    preBuffer.position(0);

    return preBuffer;
}

From source file:Main.java

public static IntBuffer createIntBuffer(final int size) {
    final IntBuffer buf = ByteBuffer.allocateDirect(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer();
    buf.clear();
    return buf;//from w w w .  ja  v  a2 s.  c o  m
}

From source file:com.asakusafw.runtime.io.csv.CsvParser.java

private void addSeparator() {
    IntBuffer buf = cellBeginPositions;
    if (buf.remaining() == 0) {
        IntBuffer newBuf = IntBuffer.allocate(buf.capacity() * 2);
        newBuf.clear();
        buf.flip();//  w w w .  j  a v  a2  s  .  co  m
        newBuf.put(buf);
        buf = newBuf;
        cellBeginPositions = newBuf;
    }
    buf.put(lineBuffer.position());
}

From source file:org.jtrfp.trcl.core.Texture.java

public static final int createTextureID(GL3 gl) {
    IntBuffer ib = IntBuffer.allocate(1);
    gl.glGenTextures(1, ib);/* ww w. j a  v  a 2s  . co  m*/
    ib.clear();
    return ib.get();
}

From source file:org.jtrfp.trcl.gpu.GLShader.java

private void printStatusInfo(GL3 gl, int shaderID) {
    IntBuffer statBuf = IntBuffer.allocate(1);
    gl.glGetShaderiv(shaderID, GL4.GL_COMPILE_STATUS, statBuf);
    if (statBuf.get(0) == GL4.GL_FALSE) {
        statBuf.clear();
        gl.glGetShaderiv(shaderID, GL4.GL_INFO_LOG_LENGTH, statBuf);
        ByteBuffer log = ByteBuffer.allocate(statBuf.get(0));
        gl.glGetShaderInfoLog(shaderID, statBuf.get(0), null, log);
        System.out.println(Charset.forName("US-ASCII").decode(log).toString());
        System.exit(1);/*from  ww  w .ja v  a 2 s .c  om*/
    }
}