summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-29 13:51:32 +0100
committerSven Gothel <[email protected]>2013-10-29 13:51:32 +0100
commit9f2a9df0a4b7093925c8854b37fba053469a4b35 (patch)
tree838148c91d619f99e70e26f4d8ba958e41f7fbb5 /src/test
parentd8074fb1df1bdb63fdb97585c797c15d34695e9c (diff)
Bug 776 GLContext Sharing: Add copy-ctor to GLArrayData* w/ sliced Buffer; Refine GearsObject* GLArrayDataServer copying; GearsES*: Init VBO eagerly
Add copy-ctor to GLArrayData* w/ sliced Buffer to allow general sharing of VBO via these high-level types. Refine GearsObject* GLArrayDataServer copying (commit bcfaa149b9803ce33c5a356cbcb45f7dfd3e4361): Utilize new GLArrayData* copy-ctor. GearsES*: Init VBO eagerly, allowing VBO usage after init(..).
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java36
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java54
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java15
5 files changed, 65 insertions, 58 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java
index 7adcce2ae..4d5d69539 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java
@@ -23,6 +23,7 @@ package com.jogamp.opengl.test.junit.jogl.demos;
import java.nio.FloatBuffer;
import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.util.GLArrayDataServer;
@@ -46,11 +47,32 @@ public abstract class GearsObject {
public GLArrayDataServer insideRadiusCyl;
public boolean isShared;
- public abstract GLArrayDataServer createInterleaveClone(GLArrayDataServer ads);
public abstract GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage);
public abstract void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components);
public abstract void draw(GL gl, float x, float y, float angle);
+ private GLArrayDataServer createInterleavedClone(GLArrayDataServer ads) {
+ final GLArrayDataServer n = new GLArrayDataServer(ads);
+ n.setInterleavedOffset(0);
+ return n;
+ }
+
+ private void init(GL2ES2 gl, GLArrayDataServer array) {
+ array.enableBuffer(gl, true);
+ array.enableBuffer(gl, false);
+ }
+
+ /** Init VBO and data .. */
+ public final void init(GL _gl) {
+ final GL2ES2 gl = _gl.getGL2ES2();
+ init(gl, frontFace);
+ init(gl, frontSide);
+ init(gl, backFace);
+ init(gl, backSide);
+ init(gl, outwardFace);
+ init(gl, insideRadiusCyl);
+ }
+
public void destroy(GL gl) {
if(!isShared) {
// could be already destroyed by shared configuration
@@ -84,17 +106,17 @@ public abstract class GearsObject {
public GearsObject ( GearsObject shared ) {
isShared = true;
- frontFace = createInterleaveClone(shared.frontFace);
+ frontFace = createInterleavedClone(shared.frontFace);
addInterleavedVertexAndNormalArrays(frontFace, 3);
- backFace = createInterleaveClone(shared.backFace);
+ backFace = createInterleavedClone(shared.backFace);
addInterleavedVertexAndNormalArrays(backFace, 3);
- frontSide = createInterleaveClone(shared.frontSide);
+ frontSide = createInterleavedClone(shared.frontSide);
addInterleavedVertexAndNormalArrays(frontSide, 3);
- backSide= createInterleaveClone(shared.backSide);
+ backSide= createInterleavedClone(shared.backSide);
addInterleavedVertexAndNormalArrays(backSide, 3);
- outwardFace = createInterleaveClone(shared.outwardFace);
+ outwardFace = createInterleavedClone(shared.outwardFace);
addInterleavedVertexAndNormalArrays(outwardFace, 3);
- insideRadiusCyl = createInterleaveClone(shared.insideRadiusCyl);
+ insideRadiusCyl = createInterleavedClone(shared.insideRadiusCyl);
addInterleavedVertexAndNormalArrays(insideRadiusCyl, 3);
gearColor = shared.gearColor;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index db1f217ba..9f191d3b6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -162,6 +162,7 @@ public class GearsES1 implements GLEventListener {
/* make the gears */
if(null == gear1) {
gear1 = new GearsObjectES1(gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f);
+ gear1.init(gl);
System.err.println("gear1 created: "+gear1);
} else {
usesSharedGears = true;
@@ -170,6 +171,7 @@ public class GearsES1 implements GLEventListener {
if(null == gear2) {
gear2 = new GearsObjectES1(gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f);
+ gear2.init(gl);
System.err.println("gear2 created: "+gear2);
} else {
usesSharedGears = true;
@@ -178,6 +180,7 @@ public class GearsES1 implements GLEventListener {
if(null == gear3) {
gear3 = new GearsObjectES1(gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f);
+ gear3.init(gl);
System.err.println("gear3 created: "+gear3);
} else {
usesSharedGears = true;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
index 6c9587931..1edf1c3a8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
@@ -41,21 +41,6 @@ public class GearsObjectES1 extends GearsObject {
}
@Override
- public GLArrayDataServer createInterleaveClone(GLArrayDataServer ads) {
- final FloatBuffer fb0 = (FloatBuffer) ads.getBuffer();
- final FloatBuffer fb1 = fb0.slice();
- // manual 'unseal'
- fb1.position(fb1.limit());
- fb1.limit(fb1.capacity());
-
- final GLArrayDataServer adsClone = GLArrayDataServer.createFixedInterleaved(ads.getComponentCount(), ads.getComponentType(), ads.getNormalized(),
- ads.getStride(), fb1, ads.getVBOUsage());
- adsClone.setVBOName(ads.getVBOName());
- adsClone.seal(true);
- return adsClone;
- }
-
- @Override
public GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage) {
return GLArrayDataServer.createFixedInterleaved(comps, dataType, normalized, initialSize, vboUsage);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 60242d604..6c5ddf6e6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -45,7 +45,6 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLContext;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
@@ -109,11 +108,11 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
}
@Override
public void startTileRendering(TileRendererBase tr) {
- System.err.println("GearsES2.startTileRendering: "+tr);
+ System.err.println("GearsES2.startTileRendering: "+sid()+""+tr);
}
@Override
public void endTileRendering(TileRendererBase tr) {
- System.err.println("GearsES2.endTileRendering: "+tr);
+ System.err.println("GearsES2.endTileRendering: "+sid()+""+tr);
}
public void setIgnoreFocus(boolean v) { ignoreFocus = v; }
@@ -178,18 +177,20 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
return wait<POLL_DIVIDER;
}
+ private final String sid() { return "0x"+Integer.toHexString(hashCode()); }
+
@Override
public void init(GLAutoDrawable drawable) {
- if(null != sharedGears && sharedGears.getGear1() == null ) {
- System.err.println(Thread.currentThread()+" GearsES2.init: pending shared Gears .. re-init later XXXXX");
+ if(null != sharedGears && !sharedGears.isInit() ) {
+ System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": pending shared Gears .. re-init later XXXXX");
drawable.setGLEventListenerInitState(this, false);
return;
}
- System.err.println(Thread.currentThread()+" GearsES2.init: tileRendererInUse "+tileRendererInUse);
+ System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
if(verbose) {
- System.err.println("GearsES2 init on "+Thread.currentThread());
+ System.err.println("GearsES2 init "+sid()+" on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
System.err.println("INIT GL IS: " + gl.getClass().getName());
System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
@@ -236,49 +237,53 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
gear3 = new GearsObjectES2(sharedGears.getGear3(), st, pmvMatrix, pmvMatrixUniform, colorU);
usesSharedGears = true;
if(verbose) {
- System.err.println("gear1 created w/ share: "+sharedGears.getGear1()+" -> "+gear1);
- System.err.println("gear2 created w/ share: "+sharedGears.getGear2()+" -> "+gear2);
- System.err.println("gear3 created w/ share: "+sharedGears.getGear3()+" -> "+gear3);
+ System.err.println("gear1 "+sid()+" created w/ share: "+sharedGears.getGear1()+" -> "+gear1);
+ System.err.println("gear2 "+sid()+" created w/ share: "+sharedGears.getGear2()+" -> "+gear2);
+ System.err.println("gear3 "+sid()+" created w/ share: "+sharedGears.getGear3()+" -> "+gear3);
}
} else {
if(null == gear1) {
gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear1.init(gl);
if(verbose) {
- System.err.println("gear1 created: "+gear1);
+ System.err.println("gear1 "+sid()+" created: "+gear1);
}
} else {
final GearsObjectES2 _gear1 = gear1;
gear1 = new GearsObjectES2(_gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
usesSharedGears = true;
if(verbose) {
- System.err.println("gear1 created w/ share: "+_gear1+" -> "+gear1);
+ System.err.println("gear1 "+sid()+" created w/ share: "+_gear1+" -> "+gear1);
}
}
if(null == gear2) {
gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear2.init(gl);
if(verbose) {
- System.err.println("gear2 created: "+gear2);
+ System.err.println("gear2 "+sid()+" created: "+gear2);
}
} else {
final GearsObjectES2 _gear2 = gear2;
gear2 = new GearsObjectES2(_gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
usesSharedGears = true;
if(verbose) {
- System.err.println("gear2 created w/ share: "+_gear2+" -> "+gear2);
+ System.err.println("gear2 "+sid()+" created w/ share: "+_gear2+" -> "+gear2);
}
}
if(null == gear3) {
gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear3.init(gl);
if(verbose) {
+ System.err.println("gear3 "+sid()+" created: "+gear2);
}
} else {
final GearsObjectES2 _gear3 = gear3;
gear3 = new GearsObjectES2(_gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
usesSharedGears = true;
if(verbose) {
- System.err.println("gear3 created w/ share: "+_gear3+" -> "+gear3);
+ System.err.println("gear3 "+sid()+" created w/ share: "+_gear3+" -> "+gear3);
}
}
}
@@ -299,10 +304,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.useProgram(gl, false);
- System.err.println(Thread.currentThread()+" GearsES2.init FIN");
+ System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this);
isInit = true;
}
+ public final boolean isInit() { return isInit; }
+
private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() {
@Override
public void gestureDetected(GestureEvent gh) {
@@ -334,7 +341,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) {
final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse);
+ System.err.println(Thread.currentThread()+" GearsES2.reshape "+sid()+" "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse);
if( !gl.hasGLSL() ) {
return;
@@ -371,7 +378,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
final float _w = r - l;
final float _h = t - b;
if(verbose) {
- System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h);
+ System.err.println(">> angle "+sid()+" "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h);
}
pmvMatrix.glFrustumf(l, r, b, t, 5.0f, 200.0f);
@@ -390,7 +397,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
public void dispose(GLAutoDrawable drawable) {
if( !isInit ) { return; }
isInit = false;
- System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse);
+ System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse);
final Object upstreamWidget = drawable.getUpstreamWidget();
if (upstreamWidget instanceof Window) {
final Window window = (Window) upstreamWidget;
@@ -416,7 +423,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.destroy(gl);
st = null;
- System.err.println(Thread.currentThread()+" GearsES2.dispose FIN");
+ System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN");
}
@Override
@@ -424,7 +431,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
if( !isInit ) { return; }
GLAnimatorControl anim = drawable.getAnimator();
if( verbose && ( null == anim || !anim.isAnimating() ) ) {
- System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
+ System.err.println(Thread.currentThread()+" GearsES2.display "+sid()+" "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
}
// Turn the gears' teeth
if(doRotate) {
@@ -485,6 +492,11 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
gl.glDisable(GL.GL_CULL_FACE);
}
+ @Override
+ public String toString() {
+ return "GearsES2[obj "+sid()+" 1 "+gear1+", 2 "+gear2+", 3 "+gear3+"]";
+ }
+
boolean confinedFixedCenter = false;
public void setConfinedFixedCenter(boolean v) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
index 89006d28c..82e9089cf 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
@@ -78,21 +78,6 @@ public class GearsObjectES2 extends GearsObject {
}
@Override
- public GLArrayDataServer createInterleaveClone(GLArrayDataServer ads) {
- final FloatBuffer fb0 = (FloatBuffer) ads.getBuffer();
- final FloatBuffer fb1 = fb0.slice();
- // manual 'unseal'
- fb1.position(fb1.limit());
- fb1.limit(fb1.capacity());
-
- final GLArrayDataServer adsClone = GLArrayDataServer.createGLSLInterleaved(ads.getComponentCount(), ads.getComponentType(), ads.getNormalized(),
- ads.getStride(), fb1, ads.getVBOUsage());
- adsClone.setVBOName(ads.getVBOName());
- adsClone.seal(true);
- return adsClone;
- }
-
- @Override
public GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage) {
return GLArrayDataServer.createGLSLInterleaved(comps, dataType, normalized, initialSize, vboUsage);
}