List of usage examples for java.nio ByteBuffer asFloatBuffer
public abstract FloatBuffer asFloatBuffer();
From source file:Main.java
public static FloatBuffer newFloatBuffer(int numFloats) { ByteBuffer buffer = ByteBuffer.allocateDirect(numFloats * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); }
From source file:Main.java
public static FloatBuffer toFloatBuffer(float[] v) { ByteBuffer buff = ByteBuffer.allocateDirect(v.length * 4); buff.order(ByteOrder.nativeOrder()); FloatBuffer buffer = buff.asFloatBuffer(); buffer.put(v);//from www . ja va 2 s .c o m buffer.position(0); return buffer; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(int size) { ByteBuffer buffer = ByteBuffer.allocateDirect(size * BYTES_PER_FLOAT); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); }
From source file:Main.java
public static FloatBuffer makeFloatBuffer(float[] i_arr) { ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(i_arr);/* w w w . j a v a 2 s .c o m*/ fb.position(0); return fb; }
From source file:Main.java
/** * /*from ww w.j a v a2 s . c om*/ * @since 1.0.0 * @param v * @return the FloatBuffer */ public static FloatBuffer toFloatBuffer(float[] v) { ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 4); buf.order(ByteOrder.nativeOrder()); FloatBuffer buffer = buf.asFloatBuffer(); buffer.put(v); 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);//from w ww . j a v a2s . com buffer.position(0); return buffer; }
From source file:Main.java
public static FloatBuffer makeFloatBuffer3(float $a, float $b, float $c) { ByteBuffer b = ByteBuffer.allocateDirect(3 * BYTES_PER_FLOAT); b.order(ByteOrder.nativeOrder()); FloatBuffer buffer = b.asFloatBuffer(); buffer.put($a);//from w ww. j ava 2 s. c o m buffer.put($b); buffer.put($c); buffer.position(0); return buffer; }
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);// ww w . java 2 s.co m fb.position(0); 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);/* w w w.jav a 2s . co m*/ buffer.put($b); buffer.put($c); buffer.put($d); buffer.position(0); return buffer; }
From source file:Main.java
public static FloatBuffer createFloatBuffer(float[] triangleCoords) { FloatBuffer vertexbuffer;/* w w w . j a va 2 s. com*/ ByteBuffer bb = ByteBuffer.allocateDirect(triangleCoords.length * 4);// 9*4 bb.order(ByteOrder.nativeOrder()); vertexbuffer = bb.asFloatBuffer(); vertexbuffer.put(triangleCoords); vertexbuffer.position(0); return vertexbuffer; }