Example usage for java.nio FloatBuffer flip

List of usage examples for java.nio FloatBuffer flip

Introduction

In this page you can find the example usage for java.nio FloatBuffer flip.

Prototype

public final Buffer flip() 

Source Link

Document

Flips this buffer.

Usage

From source file:Main.java

public static FloatBuffer createFloatBuffer(final FloatBuffer reuseStore, final float... data) {
    if (data == null) {
        return null;
    }//from w w  w  . j a v  a 2 s.c  o  m
    final FloatBuffer buff;
    if (reuseStore == null || reuseStore.capacity() != data.length) {
        buff = createFloatBuffer(data.length);
    } else {
        buff = reuseStore;
        buff.clear();
    }
    buff.clear();
    buff.put(data);
    buff.flip();
    return buff;
}

From source file:appeng.client.render.renderable.ItemRenderable.java

@Override
public void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage) {
    Pair<ItemStack, Matrix4f> pair = f.apply(te);
    if (pair != null && pair.getLeft() != null) {
        GlStateManager.pushMatrix();//  w w  w.  j ava 2  s .com
        if (pair.getRight() != null) {
            FloatBuffer matrix = BufferUtils.createFloatBuffer(16);
            pair.getRight().store(matrix);
            matrix.flip();
            GlStateManager.multMatrix(matrix);
        }
        Minecraft.getMinecraft().getRenderItem().renderItem(pair.getLeft(), TransformType.GROUND);
        GlStateManager.popMatrix();
    }
}

From source file:BufferTest.java

private long bulkPut(float[] data, int elements, FloatBuffer target, int testTime) {
    long start = System.currentTimeMillis();
    long elapsed = 0;
    int reps = 0;

    target.clear();/* ww  w  .j  av a2  s .c o  m*/

    do {
        target.put(data, 0, elements);
        target.flip();

        reps++;
        elapsed = System.currentTimeMillis() - start;
    } while (elapsed < testTime);

    long bytes = (long) elements * (long) reps * 4;

    return bytes / elapsed / 1024;
}

From source file:BufferTest.java

private long singlePut(float[] data, int elements, FloatBuffer target, int testTime) {
    long start = System.currentTimeMillis();
    long elapsed = 0;
    int reps = 0;

    target.clear();// ww w .  ja  v  a2s  . co m

    do {
        for (int i = 0; i < elements; i++) {
            target.put(data[i]);
        }
        target.flip();
        reps++;
        elapsed = System.currentTimeMillis() - start;
    } while (elapsed < testTime);

    long bytes = (long) elements * (long) reps * 4;

    return bytes / elapsed / 1024;
}