Java FloatBuffer Copy copy(float[] vertices, FloatBuffer floatBuffer, int numFloats, int offset)

Here you can find the source of copy(float[] vertices, FloatBuffer floatBuffer, int numFloats, int offset)

Description

copy

License

Apache License

Declaration

public static void copy(float[] vertices, FloatBuffer floatBuffer, int numFloats, int offset) 

Method Source Code


//package com.java2s;
/*//ww w.  j  a  va2  s. c o m
 * Notice: This is a modified version of a libgdx file. See https://github.com/libgdx/libgdx for the original work.
 *
 * Copyright 2011 See libgdx AUTHORS file.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

public class Main {
    public static void copy(float[] vertices, ByteBuffer byteBuffer, int numFloats, int offset) {
        byteBuffer.position(0);
        byteBuffer.limit(numFloats << 2);

        for (int index = 0; index < numFloats; index++)
            byteBuffer.putFloat(vertices[index + offset]);

        byteBuffer.position(0);
    }

    public static void copy(float[] vertices, FloatBuffer floatBuffer, int numFloats, int offset) {
        floatBuffer.position(0);
        floatBuffer.limit(numFloats);

        for (int index = 0; index < numFloats; index++)
            floatBuffer.put(vertices[index + offset]);

        floatBuffer.position(0);
    }

    public static void copy(float[] vertices, int sourceOffset, int count, ByteBuffer byteBuffer) {
        for (int index = 0; index < count; index++)
            byteBuffer.putFloat(vertices[index + sourceOffset]);
    }
}

Related

  1. copy(final FloatBuffer source, final int fromPos, final FloatBuffer destination, final int toPos, final int length)
  2. copyFloatBuffer(FloatBuffer buf)
  3. copyInternal(FloatBuffer buf, int fromPos, int toPos, int length)
  4. copyInternalVector2(final FloatBuffer buf, final int fromPos, final int toPos)
  5. copyInternalVector3(FloatBuffer buf, int fromPos, int toPos)