List of usage examples for java.nio ByteBuffer allocateDirect
public static ByteBuffer allocateDirect(int capacity)
From source file:Main.java
public static ByteBuffer buildByteBuffer(byte[] array) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length); byteBuffer.put(array);/* www. jav a2s. com*/ byteBuffer.position(0); return byteBuffer; }
From source file:Main.java
public static ByteBuffer createByteBuffer(int count) { ByteBuffer data = ByteBuffer.allocateDirect(count * 4); data.order(ByteOrder.nativeOrder()); return data;/* ww w . j ava 2 s . c o m*/ }
From source file:Main.java
public static IntBuffer getIntBuffer(int[] coords) { ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4); bb.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = bb.asIntBuffer(); intBuffer.put(coords);/*from w w w . ja v a2 s.co m*/ intBuffer.position(0); return intBuffer; }
From source file:Main.java
public static FloatBuffer FloatToBuffer(float[] array) { FloatBuffer fb = ByteBuffer.allocateDirect(array.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer(); fb.put(array).position(0);/*from w w w . j av a2s . c o m*/ return fb; }
From source file:Main.java
public static FloatBuffer arrayToBuffer(float[] arr) { FloatBuffer buffer = ByteBuffer.allocateDirect(arr.length * 4).order(ByteOrder.nativeOrder()) .asFloatBuffer();//w ww . jav a 2 s . co m buffer.put(arr).position(0); return buffer; }
From source file:Main.java
public static IntBuffer getBufferFromIntArray(int[] array) { IntBuffer result = ByteBuffer.allocateDirect(array.length * 4).order(ByteOrder.nativeOrder()).asIntBuffer(); result.put(array).position(0);/*w ww . j a v a 2 s . c o m*/ return result; }
From source file:Main.java
public static ShortBuffer getShortBuffer(short[] coords) { ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 2); bb.order(ByteOrder.nativeOrder()); ShortBuffer shortBuffer = bb.asShortBuffer(); shortBuffer.put(coords);//from w ww. ja va 2s. com shortBuffer.position(0); return shortBuffer; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(int floatCount) { ByteBuffer data = ByteBuffer.allocateDirect(floatCount * 4); data.order(ByteOrder.nativeOrder()); FloatBuffer p1 = data.asFloatBuffer(); return p1;/*from w w w . j av a 2s . com*/ }
From source file:Main.java
public static FloatBuffer makeFloatBuffer(int i_len) { ByteBuffer bb = ByteBuffer.allocateDirect(i_len * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.position(0);//from ww w. j a v a2s . co m return fb; }
From source file:Main.java
public static ShortBuffer createShortBuffer(int shortCount) { ByteBuffer data = ByteBuffer.allocateDirect(shortCount * 4); data.order(ByteOrder.nativeOrder()); ShortBuffer p1 = data.asShortBuffer(); return p1;//from w ww .j a v a2 s . c o m }