Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 *-----------------------------------------------------------------------------
 * Copyright (c) 2012, Look! Development Team
 * All rights reserved.
 *
 * Distributed under the terms of the BSD Simplified License.
 *
 * The full license is in the LICENSE file, distributed with this software.
 *-----------------------------------------------------------------------------
 */

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

public class Main {
    /**
     * Make a FloatBuffer from an array of floats
     * 
     * @param f
     *            The array
     * @return the FloatBuffer
     */
    public static FloatBuffer makeFloatBuffer(float[] f) {
        ByteBuffer bytBuffer = ByteBuffer.allocateDirect(f.length * 4);
        bytBuffer.order(ByteOrder.nativeOrder());

        FloatBuffer floatBuffer = bytBuffer.asFloatBuffer();
        floatBuffer.put(f);
        floatBuffer.position(0);

        return floatBuffer;
    }
}