Android FloatBuffer Create createFloatBuffer(int nElements, int stride)

Here you can find the source of createFloatBuffer(int nElements, int stride)

Description

create Float Buffer

Declaration

public static final FloatBuffer createFloatBuffer(int nElements,
            int stride) 

Method Source Code

//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 final FloatBuffer createFloatBuffer(float[] floatData) {
        FloatBuffer buffer = ByteBuffer
                .allocateDirect(floatData.length * BYTES_PER_FLOAT)
                .order(ByteOrder.nativeOrder()).asFloatBuffer()
                .put(floatData);//from  w ww .  java  2  s  .c om
        buffer.position(0);

        return buffer;
    }

    public static final FloatBuffer createFloatBuffer(int nElements,
            int stride) {
        FloatBuffer buffer = ByteBuffer
                .allocateDirect(nElements * stride * BYTES_PER_FLOAT)
                .order(ByteOrder.nativeOrder()).asFloatBuffer();
        buffer.position(0);

        return buffer;
    }
}

Related

  1. createFloatBuffer(float[] floatData)
  2. createFloatBuffer(float[] floatData)
  3. createFloatBuffer(int capacity)
  4. createFloatBuffer(int floatCount)
  5. createFloatBuffer(int nElements, int stride)
  6. createFloatBuffer(int size)
  7. createFloatBuffer(int size)
  8. createFloatBuffer(int size)
  9. createDirectFloatBuffer( final int capacity)