Here you can find the source of createFloatBuffer(int nElements, int stride)
Parameter | Description |
---|---|
nElements | Number of elements to create. |
stride | The stride between elements. |
public static final FloatBuffer createFloatBuffer(int nElements, int stride)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static final int FLOAT_SIZE_BYTES = 4; public static final FloatBuffer createFloatBuffer(float[] floatData) { FloatBuffer buffer = ByteBuffer .allocateDirect(floatData.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer() .put(floatData);/*from w ww . java 2 s . com*/ buffer.position(0); return buffer; } /** * @param nElements Number of elements to create. * @param stride The stride between elements. * @return The constructed FloatBuffer */ public static final FloatBuffer createFloatBuffer(int nElements, int stride) { FloatBuffer buffer = ByteBuffer .allocateDirect(nElements * stride * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); buffer.position(0); return buffer; } }