don't need to copy vertex array to buffers when using indirect buffers

This commit is contained in:
codeanticode
2013-02-18 12:05:47 -05:00
parent 053202518b
commit dc23eb6f7f
2 changed files with 91 additions and 60 deletions

View File

@@ -2862,6 +2862,16 @@ public class PGL {
}
protected static void updateByteBuffer(ByteBuffer buf, byte[] arr,
int offset, int size) {
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
buf.position(4 * offset);
buf.put(arr, 4 * offset, 4 * size);
buf.rewind();
}
}
protected static void getByteArray(ByteBuffer buf, byte[] arr) {
if (!buf.hasArray() || buf.array() != arr) {
buf.position(0);
@@ -2941,6 +2951,16 @@ public class PGL {
}
protected static void updateShortBuffer(ShortBuffer buf, short[] arr,
int offset, int size) {
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
buf.position(4 * offset);
buf.put(arr, 4 * offset, 4 * size);
buf.rewind();
}
}
protected static void getShortArray(ShortBuffer buf, short[] arr) {
if (!buf.hasArray() || buf.array() != arr) {
buf.position(0);
@@ -3020,6 +3040,16 @@ public class PGL {
}
protected static void updateIntBuffer(IntBuffer buf, int[] arr,
int offset, int size) {
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
buf.position(4 * offset);
buf.put(arr, 4 * offset, 4 * size);
buf.rewind();
}
}
protected static void getIntArray(IntBuffer buf, int[] arr) {
if (!buf.hasArray() || buf.array() != arr) {
buf.position(0);
@@ -3098,6 +3128,16 @@ public class PGL {
}
protected static void updateFloatBuffer(FloatBuffer buf, float[] arr,
int offset, int size) {
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
buf.position(4 * offset);
buf.put(arr, 4 * offset, 4 * size);
buf.rewind();
}
}
protected static void getFloatArray(FloatBuffer buf, float[] arr) {
if (!buf.hasArray() || buf.array() != arr) {
buf.position(0);
@@ -3339,38 +3379,56 @@ public class PGL {
// NEWT mouse listener
class NEWTMouseListener extends com.jogamp.newt.event.MouseAdapter {
boolean pointerInside = false;
@Override
public void mousePressed(com.jogamp.newt.event.MouseEvent e) {
nativeMouseEvent(e, MouseEvent.PRESS);
if (pointerInside) {
nativeMouseEvent(e, MouseEvent.PRESS);
}
}
@Override
public void mouseReleased(com.jogamp.newt.event.MouseEvent e) {
nativeMouseEvent(e, MouseEvent.RELEASE);
if (pointerInside) {
nativeMouseEvent(e, MouseEvent.RELEASE);
}
}
@Override
public void mouseClicked(com.jogamp.newt.event.MouseEvent e) {
nativeMouseEvent(e, MouseEvent.CLICK);
if (pointerInside) {
nativeMouseEvent(e, MouseEvent.CLICK);
}
}
@Override
public void mouseDragged(com.jogamp.newt.event.MouseEvent e) {
nativeMouseEvent(e, MouseEvent.DRAG);
if (pointerInside) {
nativeMouseEvent(e, MouseEvent.DRAG);
}
}
@Override
public void mouseMoved(com.jogamp.newt.event.MouseEvent e) {
nativeMouseEvent(e, MouseEvent.MOVE);
if (pointerInside) {
nativeMouseEvent(e, MouseEvent.MOVE);
}
}
@Override
public void mouseWheelMoved(com.jogamp.newt.event.MouseEvent e) {
if (pointerInside) {
nativeMouseEvent(e, MouseEvent.WHEEL);
}
}
@Override
public void mouseEntered(com.jogamp.newt.event.MouseEvent e) {
PApplet.println("mouse entered");
pointerInside = true;
nativeMouseEvent(e, MouseEvent.ENTER);
}
@Override
public void mouseExited(com.jogamp.newt.event.MouseEvent e) {
PApplet.println("mouse exited");
pointerInside = false;
nativeMouseEvent(e, MouseEvent.EXIT);
}
@Override
public void mouseWheelMoved(com.jogamp.newt.event.MouseEvent e) {
nativeMouseEvent(e, MouseEvent.WHEEL);
}
}
// NEWT key listener