-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBufferUtils2.java
executable file
·60 lines (51 loc) · 1.68 KB
/
BufferUtils2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package jToolkit4FixedPipeline.common;
import org.lwjgl.BufferUtils;
import java.nio.*;
/**
* A collection of convenience methods that should be in BufferUtils but aren't
* @author Astemir Eleev
*/
public class BufferUtils2 {
public static ByteBuffer toBuffer(byte[] src) {
ByteBuffer buffer = BufferUtils.createByteBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
public static CharBuffer toBuffer(char[] src) {
CharBuffer buffer = BufferUtils.createCharBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
public static DoubleBuffer toBuffer(double[] src) {
DoubleBuffer buffer = BufferUtils.createDoubleBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
public static FloatBuffer toBuffer(float[] src) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
public static IntBuffer toBuffer(int[] src) {
IntBuffer buffer = BufferUtils.createIntBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
public static LongBuffer toBuffer(long[] src) {
LongBuffer buffer = BufferUtils.createLongBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
public static ShortBuffer toBuffer(short[] src) {
ShortBuffer buffer = BufferUtils.createShortBuffer(src.length);
buffer.put(src);
buffer.rewind();
return buffer;
}
}