Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static final int BYTES_PER_FLOAT = 4; public static FloatBuffer createFloatBuffer(int size) { ByteBuffer buffer = ByteBuffer.allocateDirect(size * BYTES_PER_FLOAT); buffer.order(ByteOrder.nativeOrder()); return buffer.asFloatBuffer(); } public static FloatBuffer createFloatBuffer(float[] coords) { FloatBuffer fb = createFloatBuffer(coords.length); fb.put(coords); fb.position(0); return fb; } }