Here you can find the source of floatArrayToFloatBuffer(float[] data)
Parameter | Description |
---|---|
data | The float array to convert. |
public static FloatBuffer floatArrayToFloatBuffer(float[] data)
//package com.java2s; /**/* w ww. ja va2s . c o m*/ * The MIT License (MIT) * Wrath Utils Copyright (c) 2016 Trent Spears */ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { /** * Converts an array of primitive floats to a {@link java.nio.FloatBuffer}. * @param data The float array to convert. * @return Returns the {@link java.nio.FloatBuffer} form of the float array. */ public static FloatBuffer floatArrayToFloatBuffer(float[] data) { FloatBuffer ret = ByteBuffer.allocateDirect(data.length << 2).order(ByteOrder.nativeOrder()) .asFloatBuffer(); ret.put(data).flip(); return ret; } }