Android FloatBuffer Copy copyFloatBuffer(FloatBuffer paramFloatBuffer)

Here you can find the source of copyFloatBuffer(FloatBuffer paramFloatBuffer)

Description

copy Float Buffer

Declaration

public static FloatBuffer copyFloatBuffer(FloatBuffer paramFloatBuffer) 

Method Source Code

//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import java.nio.FloatBuffer;

public class Main {
    public static FloatBuffer copyFloatBuffer(FloatBuffer paramFloatBuffer) {
        return copyFloatBufferAsByteBuffer(paramFloatBuffer)
                .asFloatBuffer();//from w  w w. j a  va2 s  .com
    }

    public static ByteBuffer copyFloatBufferAsByteBuffer(
            FloatBuffer paramFloatBuffer) {
        ByteBuffer localByteBuffer = newByteBuffer(paramFloatBuffer
                .remaining() * 4);
        paramFloatBuffer.mark();
        localByteBuffer.asFloatBuffer().put(paramFloatBuffer);
        paramFloatBuffer.reset();
        localByteBuffer.rewind();
        return localByteBuffer;
    }

    public static ByteBuffer newByteBuffer(int paramInt) {
        ByteBuffer localByteBuffer = ByteBuffer.allocateDirect(paramInt);
        localByteBuffer.order(ByteOrder.nativeOrder());
        return localByteBuffer;
    }
}

Related

  1. copyInternal(final FloatBuffer buf, final int fromPos, final int toPos, final int length)
  2. copyInternalVector3(final FloatBuffer buf, final int fromPos, final int toPos)