aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-02-26 17:04:03 +0100
committerSven Gothel <[email protected]>2014-02-26 17:04:03 +0100
commit80a0ddd084e674fbfff007e6a83eec6162aaa32d (patch)
tree10ae3efcd51e174997943f40a5ea8c9bd39a8b75
parentd84812b6fb398c73cb3f339ab13d74b7e6822181 (diff)
parent72d44215a266ccb569efbd5af3142385c4442fe9 (diff)
Merge branch 'master' into 2.2-train
-rw-r--r--make/scripts/tests.sh2
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java5
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java82
5 files changed, 80 insertions, 30 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index ad7222bc5..72b1e4e74 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -414,7 +414,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $*
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
index 472bfbd58..2351826cb 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
@@ -298,7 +298,7 @@ public class GLBufferObjectTracker {
public synchronized final GLBufferStorage mapBuffer(final GLBufferStateTracker bufferStateTracker,
final GL caller, final int target, final long offset, final long length, final int access,
final MapBufferRangeDispatch dispatch, final long glProcAddress) throws GLException {
- return this.mapBufferImpl(bufferStateTracker, caller, target, true /* useRange */, length, access, access, dispatch, glProcAddress);
+ return this.mapBufferImpl(bufferStateTracker, caller, target, true /* useRange */, offset, length, access, dispatch, glProcAddress);
}
/**
* Must be called when mapping GL buffer objects via {@link GL2#mapNamedBuffer(int, int)}.
@@ -319,7 +319,7 @@ public class GLBufferObjectTracker {
*/
public synchronized final GLBufferStorage mapBuffer(final int bufferName, final long offset, final long length, final int access, final MapBufferRangeDispatch dispatch,
final long glProcAddress) throws GLException {
- return this.mapBufferImpl(0 /* target */, bufferName, true /* isNamedBuffer */, false /* useRange */, 0 /* offset */, 0 /* length */, access, dispatch, glProcAddress);
+ return this.mapBufferImpl(0 /* target */, bufferName, true /* isNamedBuffer */, true /* useRange */, offset, length, access, dispatch, glProcAddress);
}
/**
* @throws GLException if buffer is not bound to target
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 20ab7a2ee..bb7b44795 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -432,7 +432,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
public final boolean hideCursor() {
AWTEDTExecutor.singleton.invoke(false, new Runnable() {
public void run() {
- component.setCursor(AWTMisc.getNullCursor());
+ final Cursor cursor = AWTMisc.getNullCursor();
+ if( null != cursor ) {
+ component.setCursor(cursor);
+ }
} } );
return true;
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index 069cffeb8..3099f293d 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -50,6 +50,8 @@ import javax.media.nativewindow.util.PixelFormat;
import javax.media.nativewindow.util.PixelFormatUtil;
import javax.swing.MenuSelectionManager;
+import jogamp.nativewindow.jawt.JAWTUtil;
+
public class AWTMisc {
public static JFrame getJFrame(Component c) {
@@ -174,9 +176,18 @@ public class AWTMisc {
static final HashMap<Integer, Cursor> cursorMap = new HashMap<Integer, Cursor>();
static final Cursor nulCursor;
static {
- final Toolkit toolkit = Toolkit.getDefaultToolkit();
- final BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
- nulCursor = toolkit.createCustomCursor(img, new Point(0,0), "nullCursor");
+ Cursor _nulCursor = null;
+ try {
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ final BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
+ _nulCursor = toolkit.createCustomCursor(img, new Point(0,0), "nullCursor");
+ } catch (Exception he) {
+ if( JAWTUtil.DEBUG ) {
+ System.err.println("Catched exception: "+he.getMessage());
+ he.printStackTrace();
+ }
+ }
+ nulCursor = _nulCursor;
}
public static synchronized Cursor getNullCursor() { return nulCursor; }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
index ac82c74ea..23778ecf6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
@@ -36,6 +36,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES3;
import javax.media.opengl.GL2GL3;
import javax.media.opengl.GLBufferStorage;
import javax.media.opengl.GLCapabilities;
@@ -57,44 +58,65 @@ public class TestMapBufferRead01NEWT extends UITestCase {
static final boolean DEBUG = false;
@Test
- public void testWriteRead01a() throws InterruptedException {
+ public void testWriteRead01aMap() throws InterruptedException {
if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
System.err.println("Test requires GL2/GL3 profile.");
return;
}
ByteBuffer verticiesBB = ByteBuffer.allocate(4*9);
verticiesBB.order(ByteOrder.nativeOrder());
- testWriteRead01(verticiesBB);
+ testWriteRead01(verticiesBB, false /* useRange */);
}
@Test
- public void testWriteRead01b() throws InterruptedException {
+ public void testWriteRead01bMap() throws InterruptedException {
if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
System.err.println("Test requires GL2/GL3 profile.");
return;
}
ByteBuffer verticiesBB = Buffers.newDirectByteBuffer(4*9);
- testWriteRead01(verticiesBB);
+ testWriteRead01(verticiesBB, false /* useRange */);
}
- private void testWriteRead01(ByteBuffer verticiesBB) throws InterruptedException {
+ @Test
+ public void testWriteRead02aMapRange() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL3) && !!GLProfile.isAvailable(GLProfile.GLES3)) {
+ System.err.println("Test requires GL3 or GLES3 profile.");
+ return;
+ }
+ ByteBuffer verticiesBB = ByteBuffer.allocate(4*9);
+ verticiesBB.order(ByteOrder.nativeOrder());
+ testWriteRead01(verticiesBB, true/* useRange */);
+ }
+ @Test
+ public void testWriteRead02bMapRange() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL3) && !!GLProfile.isAvailable(GLProfile.GLES3)) {
+ System.err.println("Test requires GL3 or GLES3 profile.");
+ return;
+ }
+ ByteBuffer verticiesBB = Buffers.newDirectByteBuffer(4*9);
+ testWriteRead01(verticiesBB, true /* useRange */);
+ }
+
+ private void testWriteRead01(ByteBuffer verticiesBB, boolean useRange) throws InterruptedException {
+ final GLProfile glp = GLProfile.getMaxProgrammable(true);
final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(
- new GLCapabilities(GLProfile.getGL2GL3()), 800, 600, true);
+ new GLCapabilities(glp), 800, 600, true);
try {
final GL gl = winctx.context.getGL();
int[] vertexBuffer = new int[1];
- verticiesBB.putFloat(0);
- verticiesBB.putFloat(0.5f);
- verticiesBB.putFloat(0);
+ verticiesBB.putFloat(-0.3f);
+ verticiesBB.putFloat(-0.2f);
+ verticiesBB.putFloat(-0.1f);
- verticiesBB.putFloat(0.5f);
- verticiesBB.putFloat(-0.5f);
- verticiesBB.putFloat(0);
+ verticiesBB.putFloat(0.1f);
+ verticiesBB.putFloat(0.2f);
+ verticiesBB.putFloat(0.3f);
- verticiesBB.putFloat(-0.5f);
- verticiesBB.putFloat(-0.5f);
- verticiesBB.putFloat(0);
+ verticiesBB.putFloat(0.4f);
+ verticiesBB.putFloat(0.5f);
+ verticiesBB.putFloat(0.6f);
verticiesBB.rewind();
if(DEBUG) {
for(int i=0; i < verticiesBB.capacity(); i+=4) {
@@ -106,28 +128,42 @@ public class TestMapBufferRead01NEWT extends UITestCase {
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer[0]);
- // gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_READ);
- gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_DRAW);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL2ES3.GL_STATIC_READ);
+ // gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_DRAW);
final int bufferName = gl.getBoundBuffer(GL.GL_ARRAY_BUFFER);
final GLBufferStorage bufferStorage = gl.getBufferStorage(bufferName);
System.err.println("gpu-01 GL_ARRAY_BUFFER -> bufferName "+bufferName+" -> "+bufferStorage);
Assert.assertEquals("Buffer storage's bytes-buffer not null before map", null, bufferStorage.getMappedBuffer());
- final ByteBuffer bb = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2GL3.GL_READ_ONLY);
- Assert.assertNotNull(bb);
- System.err.println("gpu-02 mapped GL_ARRAY_BUFFER -> "+bb);
+ final int floatOffset, byteOffset, mapByteLength;
+ final ByteBuffer bb;
+ if( useRange ) {
+ floatOffset = 3;
+ byteOffset = Buffers.SIZEOF_FLOAT*floatOffset;
+ mapByteLength = verticiesBB.capacity()-byteOffset;
+ bb = gl.glMapBufferRange(GL.GL_ARRAY_BUFFER, byteOffset, mapByteLength, GL.GL_MAP_READ_BIT);
+ } else {
+ floatOffset = 0;
+ byteOffset = 0;
+ mapByteLength = verticiesBB.capacity();
+ bb = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2GL3.GL_READ_ONLY);
+ }
+ System.err.println("gpu-02 mapped GL_ARRAY_BUFFER, floatOffset "+floatOffset+", byteOffset "+byteOffset+", mapByteLength "+mapByteLength+" -> "+bb);
System.err.println("gpu-03 GL_ARRAY_BUFFER -> bufferName "+bufferName+" -> "+bufferStorage);
- Assert.assertEquals("Buffer storage size not equals buffer storage size", bufferStorage.getSize(), bb.capacity());
- Assert.assertEquals("Buffer storage's bytes-buffer not equal with mapped bytes-buffer", bufferStorage.getMappedBuffer(), bb);
+ Assert.assertNotNull(bb);
+ Assert.assertEquals("BufferStorage size less byteOffset not equals buffer storage size", bufferStorage.getSize()-byteOffset, bb.capacity());
+ Assert.assertEquals("BufferStorage's bytes-buffer not equal with mapped bytes-buffer", bufferStorage.getMappedBuffer(), bb);
+ Assert.assertEquals("Buffer storage size not equals mapByteLength", mapByteLength, bb.capacity());
if(DEBUG) {
+ System.err.println("floatOffset "+floatOffset+", byteOffset "+byteOffset);
for(int i=0; i < bb.capacity(); i+=4) {
System.err.println("gpu "+i+": "+bb.getFloat(i));
}
}
for(int i=0; i < bb.capacity(); i+=4) {
- Assert.assertEquals(verticiesBB.getFloat(i), bb.getFloat(i), 0.0);
+ Assert.assertEquals(verticiesBB.getFloat(byteOffset+i), bb.getFloat(i), 0.0001f);
}
gl.glUnmapBuffer(GL.GL_ARRAY_BUFFER);
Assert.assertEquals("Buffer storage's bytes-buffer not null after unmap", null, bufferStorage.getMappedBuffer());