Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class Main {
    /**
     * Creates a {@link FloatBuffer} based on the given data.
     *
     * @param data the data for the buffer
     * @return the float buffer
     */
    public static FloatBuffer createFloatBuffer(final float[] data) {
        ByteBuffer bbVertices = ByteBuffer.allocateDirect(data.length * 4);
        bbVertices.order(ByteOrder.nativeOrder());
        final FloatBuffer fBuffer = bbVertices.asFloatBuffer();
        fBuffer.put(data);
        fBuffer.position(0);
        return fBuffer;
    }
}