mirror of
https://github.com/samsonjs/media.git
synced 2026-04-11 12:15:47 +00:00
Add GlUtil createBuffer overload which doesn't copy values
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217846755
This commit is contained in:
parent
1ef3efaa90
commit
8f3c3e2841
1 changed files with 16 additions and 7 deletions
|
|
@ -95,14 +95,23 @@ public final class GlUtil {
|
|||
return program;
|
||||
}
|
||||
|
||||
/** Allocates a FloatBuffer with the given data. */
|
||||
/**
|
||||
* Allocates a FloatBuffer with the given data.
|
||||
*
|
||||
* @param data Used to initialize the new buffer.
|
||||
*/
|
||||
public static FloatBuffer createBuffer(float[] data) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(data.length * C.BYTES_PER_FLOAT);
|
||||
byteBuffer.order(ByteOrder.nativeOrder());
|
||||
FloatBuffer buffer = byteBuffer.asFloatBuffer();
|
||||
buffer.put(data);
|
||||
buffer.flip();
|
||||
return buffer;
|
||||
return (FloatBuffer) createBuffer(data.length).put(data).flip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a FloatBuffer.
|
||||
*
|
||||
* @param capacity The new buffer's capacity, in floats.
|
||||
*/
|
||||
public static FloatBuffer createBuffer(int capacity) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(capacity * C.BYTES_PER_FLOAT);
|
||||
return byteBuffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue