List of usage examples for java.nio FloatBuffer put
public FloatBuffer put(FloatBuffer src)
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); fb.position(0);//from w w w. j a v a 2s .c o m return fb; }
From source file:Main.java
public static FloatBuffer makeFloatBuffer4(float $a, float $b, float $c, float $d) { ByteBuffer b = ByteBuffer.allocateDirect(4 * BYTES_PER_FLOAT); b.order(ByteOrder.nativeOrder()); FloatBuffer buffer = b.asFloatBuffer(); buffer.put($a); buffer.put($b);/*from w ww .j av a2s .c o m*/ buffer.put($c); buffer.put($d); buffer.position(0); return buffer; }
From source file:Main.java
public static FloatBuffer makeBuffer(float[] data) { ByteBuffer b = ByteBuffer.allocateDirect(data.length * 4); b.order(ByteOrder.nativeOrder()); FloatBuffer buffer = b.asFloatBuffer(); buffer.put(data); buffer.position(0);//from w w w . j a v a2 s.c o m return buffer; }
From source file:Main.java
public static FloatBuffer floatArrayToBuffer(float[] floatArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(floatArray.length * 4); byteBuffer.order(ByteOrder.nativeOrder()); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); floatBuffer.put(floatArray); floatBuffer.position(0);//from w w w . jav a 2 s . c o m return floatBuffer; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(float[] coords) { FloatBuffer fb = createFloatBuffer(coords.length); fb.put(coords); fb.position(0);/*from www . jav a 2 s .c om*/ return fb; }
From source file:Main.java
public static void addVertex3f(FloatBuffer buffer, float x, float y, float z) { buffer.put(x); buffer.put(y);//w w w. j a va2s. c o m buffer.put(z); }
From source file:Main.java
public static FloatBuffer toFloatBufferPositionZero(float[] values) { ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 4); vbb.order(ByteOrder.nativeOrder()); FloatBuffer buffer = vbb.asFloatBuffer(); buffer.put(values); buffer.position(0);//from w ww. j a v a 2 s .com return buffer; }
From source file:Main.java
/** * Allocates a direct float buffer, and populates it with the float array data. *//* ww w . j a v a2 s . c om*/ 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 * SIZEOF_FLOAT); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(coords); fb.position(0); return fb; }
From source file:Main.java
/** * create a Floatbuffer for a given Array * @param array//from www. j a va 2s . c om * @return */ public static FloatBuffer createFloatBuffer(float[] array) { final int floatSize = Float.SIZE / 8; ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length * floatSize); byteBuffer.order(ByteOrder.nativeOrder()); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); floatBuffer.put(array); floatBuffer.position(0); return floatBuffer; }
From source file:Main.java
public static FloatBuffer toFloatBufferPositionZero(float[] values) { final ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 4); vbb.order(ByteOrder.nativeOrder()); final FloatBuffer buffer = vbb.asFloatBuffer(); buffer.put(values); buffer.position(0);/*from w w w . ja va 2s .c o m*/ return buffer; }