Java examples for java.nio:FloatBuffer
setup FloatBuffer
/**//from ww w .j av a2 s . c o m * * You can modify and use this source freely * only for the development of application related Live2D. * * (c) Live2D Inc. All rights reserved. */ //package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static FloatBuffer setupFloatBuffer(FloatBuffer preBuffer, float[] array) { if (preBuffer == null || preBuffer.capacity() < array.length) { preBuffer = createFloatBuffer(array.length * 2); } else { preBuffer.clear(); } preBuffer.put(array); preBuffer.position(0); return preBuffer; } public static FloatBuffer createFloatBuffer(int floatCount) { ByteBuffer data = ByteBuffer.allocateDirect(floatCount * 4); data.order(ByteOrder.nativeOrder()); FloatBuffer p1 = data.asFloatBuffer(); return p1; } }