List of usage examples for java.nio ByteOrder nativeOrder
public static ByteOrder nativeOrder()
From source file:Main.java
/** * Creates a {@link IntBuffer} based on the given data. * * @param data the data for the buffer//from ww w. j av a 2 s . co m * @return the int buffer */ public static IntBuffer createIntBuffer(final float[] data) { final int[] tmpData = new int[data.length]; for (int i = 0; i < tmpData.length; i++) { tmpData[i] = Float.floatToRawIntBits(data[i]); } final ByteBuffer bbVertices = ByteBuffer.allocateDirect(tmpData.length * 4); bbVertices.order(ByteOrder.nativeOrder()); final IntBuffer intBuffer = bbVertices.asIntBuffer(); intBuffer.put(tmpData); intBuffer.flip(); return intBuffer; }
From source file:Main.java
public static IntBuffer transportArrayToNativeBuffer(int[] iArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(iArray.length * 4); byteBuffer.order(ByteOrder.nativeOrder()); return (IntBuffer) byteBuffer.asIntBuffer().put(iArray).position(0); }
From source file:Main.java
public static IntBuffer createIntBuffer(int count) { ByteBuffer data = ByteBuffer.allocateDirect(count * 4); data.order(ByteOrder.nativeOrder()); IntBuffer p1 = data.asIntBuffer(); return p1;/*from www. j av a 2s . co m*/ }
From source file:Main.java
public static FloatBuffer createFloatBuffer(float[] coords) { // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it. ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(coords);//from w w w.j a v a2 s . c o m fb.position(0); return fb; }
From source file:Main.java
/** * Make a FloatBuffer from an array of floats * // w w w.j av a 2 s . c o m * @param f * The array * @return the FloatBuffer */ public static FloatBuffer makeFloatBuffer(float[] f) { ByteBuffer bytBuffer = ByteBuffer.allocateDirect(f.length * 4); bytBuffer.order(ByteOrder.nativeOrder()); FloatBuffer floatBuffer = bytBuffer.asFloatBuffer(); floatBuffer.put(f); floatBuffer.position(0); return floatBuffer; }
From source file:Main.java
public static IntBuffer allocateInttBuffer(int capacity) { final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asIntBuffer(); }
From source file:Main.java
public static FloatBuffer allocateFloatBuffer(int capacity) { final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asFloatBuffer(); }
From source file:Main.java
public static ShortBuffer allocateShortBuffer(int capacity) { final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asShortBuffer(); }
From source file:Main.java
public static IntBuffer allocateInttBuffer(int capacity) { ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asIntBuffer(); }
From source file:Main.java
public static FloatBuffer allocateFloatBuffer(int capacity) { ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asFloatBuffer(); }