Skip to content

Commit 0ad9ce8

Browse files
committed
completed transition to direct buffers
1 parent 58801d5 commit 0ad9ce8

3 files changed

Lines changed: 548 additions & 337 deletions

File tree

core/src/processing/opengl/PGL.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.nio.FloatBuffer;
3434
import java.nio.IntBuffer;
3535
import java.nio.ShortBuffer;
36+
import java.util.Arrays;
3637
import java.util.Timer;
3738
import java.util.TimerTask;
3839

@@ -2561,6 +2562,42 @@ protected static FloatBuffer allocateDirectFloatBuffer(int size) {
25612562
}
25622563

25632564

2565+
protected static void fillBuffer(ByteBuffer buf, int i0, int i1, byte val) {
2566+
int n = i1 - i0 + 1;
2567+
byte[] temp = new byte[n];
2568+
Arrays.fill(temp, 0, n, val);
2569+
buf.position(i0);
2570+
buf.put(temp, 0, n);
2571+
}
2572+
2573+
2574+
protected static void fillBuffer(ShortBuffer buf, int i0, int i1, short val) {
2575+
int n = i1 - i0 + 1;
2576+
short[] temp = new short[n];
2577+
Arrays.fill(temp, 0, n, val);
2578+
buf.position(i0);
2579+
buf.put(temp, 0, n);
2580+
}
2581+
2582+
2583+
protected static void fillBuffer(IntBuffer buf, int i0, int i1, int val) {
2584+
int n = i1 - i0 + 1;
2585+
int[] temp = new int[n];
2586+
Arrays.fill(temp, 0, n, val);
2587+
buf.position(i0);
2588+
buf.put(temp, 0, n);
2589+
}
2590+
2591+
2592+
protected static void fillBuffer(FloatBuffer buf, int i0, int i1, float val) {
2593+
int n = i1 - i0 + 1;
2594+
float[] temp = new float[n];
2595+
Arrays.fill(temp, 0, n, val);
2596+
buf.position(i0);
2597+
buf.put(temp, 0, n);
2598+
}
2599+
2600+
25642601
///////////////////////////////////////////////////////////
25652602

25662603
// Java specific stuff

0 commit comments

Comments
 (0)