List of usage examples for java.nio FloatBuffer put
public FloatBuffer put(FloatBuffer src)
From source file:Main.java
/** * Creates a {@link FloatBuffer} based on the given data. * * @param data the data for the buffer//from w w w . ja v a 2s .com * @return the float buffer */ public static FloatBuffer createFloatBuffer(final float[] data) { ByteBuffer bbVertices = ByteBuffer.allocateDirect(data.length * 4); bbVertices.order(ByteOrder.nativeOrder()); final FloatBuffer fBuffer = bbVertices.asFloatBuffer(); fBuffer.put(data); fBuffer.position(0); return fBuffer; }
From source file:Main.java
public static void addColorf(FloatBuffer buffer, float r, float g, float b, float a) { buffer.put(r); buffer.put(g);/*from w w w .ja v a 2 s . c om*/ buffer.put(b); buffer.put(a); }
From source file:Main.java
/** * Make a FloatBuffer from an array of floats * /*from w ww . j a va 2s .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 FloatBuffer replaceFloats(FloatBuffer dest, float... src) { dest.clear();//from w ww . j a v a 2 s .c o m dest.put(src); dest.position(0); return dest; }
From source file:Main.java
public static FloatBuffer makeFloatBuffer(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);/*from w w w .j a v a 2 s. c om*/ return floatBuffer; }
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); return fb;// w w w . ja v a2 s . c o m }
From source file:Main.java
public static FloatBuffer createFloatBuffer(float... floats) { FloatBuffer fb = createFloatBuffer(floats.length); fb.put(floats); fb.position(0);/* w w w.ja v a 2s . 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();/*from w ww. j ava2 s .c o m*/ buffer.put(arr).position(0); return buffer; }
From source file:Main.java
public static FloatBuffer getBufferFromFloatArray(float[] array) { FloatBuffer result = ByteBuffer.allocateDirect(array.length * 4).order(ByteOrder.nativeOrder()) .asFloatBuffer();/*from w w w.j a va 2 s. com*/ result.put(array).position(0); return result; }
From source file:Main.java
public static FloatBuffer floatArrayToNativeFloatBuffer(float[] floats) { FloatBuffer floatBuffer = ByteBuffer.allocateDirect(floats.length * 4).order(ByteOrder.nativeOrder()) .asFloatBuffer();//from www. j a v a2 s . c om floatBuffer.put(floats).position(0); return floatBuffer; }