aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java113
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java153
3 files changed, 209 insertions, 87 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 8dd335267..011b14321 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -121,16 +121,17 @@ import com.jogamp.opengl.util.texture.TextureState;
using {@link GLDrawableFactory#createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) GLDrawableFactory.createOffscreenDrawable(..)}.<br/>
</p>
<p>
- In case FBO is used and GLSL is available, a fragment shader is utilized
- to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property <code>jogl.gljpanel.noglsl</code>.
- See <a href="#fboGLSLVerticalFlip">details here</a>.
+ <a name="verticalFlip">
+ In case</a> the drawable {@link #isGLOriented()} and {@link #setSkipGLOrientationVerticalFlip(boolean) vertical flip is not skipped},
+ this component performs the required vertical flip to bring the content from OpenGL's orientation into AWT's orientation.
+ See details about <a href="#fboGLSLVerticalFlip">FBO and GLSL vertical flipping</a>.
</p>
<p>
The OpenGL path is concluded by copying the rendered pixels an {@link BufferedImage} via {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)}
for later Java2D composition.
</p>
<p>
- In case the above mentioned GLSL vertical-flipping is not performed,
+ In case {@link #setSkipGLOrientationVerticalFlip(boolean) vertical-flip is not skipped} and <a href="#fboGLSLVerticalFlip">GLSL based vertical-flip</a> is not performed,
{@link System#arraycopy(Object, int, Object, int, int) System.arraycopy(..)} is used line by line.
This step causes more CPU load per frame and is not hardware-accelerated.
</p>
@@ -143,8 +144,12 @@ import com.jogamp.opengl.util.texture.TextureState;
* </P>
*
<a name="fboGLSLVerticalFlip"><h5>FBO / GLSL Vertical Flip</h5></a>
+ In case FBO is used and GLSL is available and {@link #setSkipGLOrientationVerticalFlip(boolean) vertical flip is not skipped}, a fragment shader is utilized
+ to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property <code>jogl.gljpanel.noglsl</code>.
+ <p>
The FBO / GLSL code path uses one texture-unit and binds the FBO texture to it's active texture-target,
see {@link #setTextureUnit(int)} and {@link #getTextureUnit()}.
+ </p>
<p>
The active and dedicated texture-unit's {@link GL#GL_TEXTURE_2D} state is preserved via {@link TextureState}.
See also {@link Texture#textureCallOrder Order of Texture Commands}.
@@ -248,6 +253,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// The backend in use
private volatile Backend backend;
+ private boolean skipGLOrientationVerticalFlip = false;
+
// Used by all backends either directly or indirectly to hook up callbacks
private final Updater updater = new Updater();
@@ -648,7 +655,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
printDrawable = printGLAD.getDelegatedDrawable();
}
- printAWTTiles.setIsGLOriented(printGLAD.isGLOriented());
+ printAWTTiles.setIsGLOriented( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented() );
printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0);
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
if( DEBUG ) {
@@ -981,6 +988,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return oglPipelineUsable();
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Method returns a valid value only <i>after</i>
+ * the backend has been initialized, either {@link #initializeBackend(boolean) eagerly}
+ * or manually via the first display call.<br/>
+ * Method always returns a valid value when called from within a {@link GLEventListener}.
+ * </p>
+ */
@Override
public boolean isGLOriented() {
final Backend b = backend;
@@ -990,6 +1006,25 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return b.getDrawable().isGLOriented();
}
+ /**
+ * Set skipping {@link #isGLOriented()} based vertical flip,
+ * which usually is required by the offscreen backend,
+ * see details about <a href="#verticalFlip">vertical flip</a>
+ * and <a href="#fboGLSLVerticalFlip">FBO / GLSL vertical flip</a>.
+ * <p>
+ * If set to <code>true</code>, user needs to flip the OpenGL rendered scene
+ * <i>if {@link #isGLOriented()} == true</i>, e.g. via the PMV matrix.<br/>
+ * See constraints of {@link #isGLOriented()}.
+ * </p>
+ */
+ public final void setSkipGLOrientationVerticalFlip(boolean v) {
+ skipGLOrientationVerticalFlip = v;
+ }
+ /** See {@link #setSkipGLOrientationVerticalFlip(boolean)}. */
+ public final boolean getSkipGLOrientationVerticalFlip() {
+ return skipGLOrientationVerticalFlip;
+ }
+
@Override
public GLCapabilitiesImmutable getChosenGLCapabilities() {
final Backend b = backend;
@@ -1372,10 +1407,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public boolean isUsingOwnLifecycle() { return false; }
+ public final boolean isUsingOwnLifecycle() { return false; }
@Override
- public void initialize() {
+ public final void initialize() {
if(DEBUG) {
System.err.println(getThreadName()+": OffscreenBackend: initialize()");
}
@@ -1395,7 +1430,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) {
isInitialized = true;
final GL gl = offscreenContext.getGL();
- flipVertical = offscreenDrawable.isGLOriented();
+ flipVertical = !GLJPanel.this.skipGLOrientationVerticalFlip && offscreenDrawable.isGLOriented();
final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities();
offscreenIsFBO = chosenCaps.isFBO();
final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant);
@@ -1454,7 +1489,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void destroy() {
+ public final void destroy() {
if(DEBUG) {
System.err.println(getThreadName()+": OffscreenBackend: destroy() - offscreenContext: "+(null!=offscreenContext)+" - offscreenDrawable: "+(null!=offscreenDrawable));
}
@@ -1502,7 +1537,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void setOpaque(boolean opaque) {
+ public final void setOpaque(boolean opaque) {
if ( opaque != isOpaque() && !useSingletonBuffer ) {
pixelBuffer.dispose();
pixelBuffer = null;
@@ -1511,13 +1546,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public boolean preGL(Graphics g) {
+ public final boolean preGL(Graphics g) {
// Empty in this implementation
return true;
}
@Override
- public void postGL(Graphics g, boolean isDisplay) {
+ public final void postGL(Graphics g, boolean isDisplay) {
if (isDisplay) {
final GL gl = offscreenContext.getGL();
@@ -1671,7 +1706,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public int getTextureUnit() {
+ public final int getTextureUnit() {
if(null != glslTextureRaster && null != offscreenDrawable) { // implies flippedVertical
return ((GLFBODrawable)offscreenDrawable).getTextureUnit();
}
@@ -1679,7 +1714,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void doPaintComponent(Graphics g) {
+ public final void doPaintComponent(Graphics g) {
helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction);
if ( null != alignedImage ) {
@@ -1689,12 +1724,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void doPlainPaint() {
+ public final void doPlainPaint() {
helper.invokeGL(offscreenDrawable, offscreenContext, updaterPlainDisplayAction, updaterInitAction);
}
@Override
- public boolean handleReshape() {
+ public final boolean handleReshape() {
GLDrawableImpl _drawable = offscreenDrawable;
{
final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, offscreenContext, panelWidth, panelHeight);
@@ -1725,27 +1760,27 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public GLContext createContext(GLContext shareWith) {
+ public final GLContext createContext(GLContext shareWith) {
return (null != offscreenDrawable) ? offscreenDrawable.createContext(shareWith) : null;
}
@Override
- public void setContext(GLContext ctx) {
+ public final void setContext(GLContext ctx) {
offscreenContext=(GLContextImpl)ctx;
}
@Override
- public GLContext getContext() {
+ public final GLContext getContext() {
return offscreenContext;
}
@Override
- public GLDrawable getDrawable() {
+ public final GLDrawable getDrawable() {
return offscreenDrawable;
}
@Override
- public GLCapabilitiesImmutable getChosenGLCapabilities() {
+ public final GLCapabilitiesImmutable getChosenGLCapabilities() {
if (offscreenDrawable == null) {
return null;
}
@@ -1753,7 +1788,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public GLProfile getGLProfile() {
+ public final GLProfile getGLProfile() {
if (offscreenDrawable == null) {
return null;
}
@@ -1811,10 +1846,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private GraphicsConfiguration workaroundConfig;
@Override
- public boolean isUsingOwnLifecycle() { return true; }
+ public final boolean isUsingOwnLifecycle() { return true; }
@Override
- public void initialize() {
+ public final void initialize() {
if(DEBUG) {
System.err.println(getThreadName()+": J2DOGL: initialize()");
}
@@ -1823,7 +1858,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void destroy() {
+ public final void destroy() {
Java2D.invokeWithOGLContextCurrent(null, new Runnable() {
@Override
public void run() {
@@ -1844,12 +1879,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void setOpaque(boolean opaque) {
+ public final void setOpaque(boolean opaque) {
// Empty in this implementation
}
@Override
- public GLContext createContext(GLContext shareWith) {
+ public final GLContext createContext(GLContext shareWith) {
if(null != shareWith) {
throw new GLException("J2DOGLBackend cannot create context w/ additional shared context, since it already needs to share the context w/ J2D.");
}
@@ -1857,43 +1892,43 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void setContext(GLContext ctx) {
+ public final void setContext(GLContext ctx) {
joglContext=ctx;
}
@Override
- public GLContext getContext() {
+ public final GLContext getContext() {
return joglContext;
}
@Override
- public GLDrawable getDrawable() {
+ public final GLDrawable getDrawable() {
return joglDrawable;
}
@Override
- public int getTextureUnit() { return -1; }
+ public final int getTextureUnit() { return -1; }
@Override
- public GLCapabilitiesImmutable getChosenGLCapabilities() {
+ public final GLCapabilitiesImmutable getChosenGLCapabilities() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
return new GLCapabilities(null);
}
@Override
- public GLProfile getGLProfile() {
+ public final GLProfile getGLProfile() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
return GLProfile.getDefault(GLProfile.getDefaultDevice());
}
@Override
- public boolean handleReshape() {
+ public final boolean handleReshape() {
// Empty in this implementation
return true;
}
@Override
- public boolean preGL(Graphics g) {
+ public final boolean preGL(Graphics g) {
final GL2 gl = joglContext.getGL().getGL2();
// Set up needed state in JOGL context from Java2D context
gl.glEnable(GL2.GL_SCISSOR_TEST);
@@ -2030,7 +2065,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void postGL(Graphics g, boolean isDisplay) {
+ public final void postGL(Graphics g, boolean isDisplay) {
// Cause OpenGL pipeline to flush its results because
// otherwise it's possible we will buffer up multiple frames'
// rendering results, resulting in apparent mouse lag
@@ -2047,7 +2082,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void doPaintComponent(final Graphics g) {
+ public final void doPaintComponent(final Graphics g) {
// This is a workaround for an issue in the Java 2D / JOGL
// bridge (reported by an end user as JOGL Issue 274) where Java
// 2D can occasionally leave its internal OpenGL context current
@@ -2196,11 +2231,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void doPlainPaint() {
+ public final void doPlainPaint() {
helper.invokeGL(joglDrawable, joglContext, updaterPlainDisplayAction, updaterInitAction);
}
- private void captureJ2DState(GL gl, Graphics g) {
+ private final void captureJ2DState(GL gl, Graphics g) {
gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, drawBuffer, 0);
gl.glGetIntegerv(GL2.GL_READ_BUFFER, readBuffer, 0);
if (Java2D.isFBOEnabled() &&
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 3d7db0465..ff5de7cb0 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
@@ -61,6 +61,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
private GLUniformData pmvMatrixUniform = null;
private GLUniformData colorU = null;
private float view_rotx = 20.0f, view_roty = 30.0f;
+ private boolean flipVerticalInGLOrientation = false;
private final float view_rotz = 0.0f;
private float panX = 0.0f, panY = 0.0f, panZ=0.0f;
@@ -119,6 +120,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
public void setDoRotation(boolean rotate) { this.doRotate = rotate; }
public void setClearBuffers(boolean v) { clearBuffers = v; }
public void setVerbose(boolean v) { verbose = v; }
+ public void setFlipVerticalInGLOrientation(boolean v) { flipVerticalInGLOrientation=v; }
public void setPMVUseBackingArray(boolean pmvUseBackingArray) {
this.pmvUseBackingArray = pmvUseBackingArray;
@@ -186,10 +188,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
drawable.setGLEventListenerInitState(this, false);
return;
}
- System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
if(verbose) {
+ System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse);
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());
@@ -307,7 +309,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
gl.glFinish(); // make sure .. for shared context (impacts OSX 10.9)
isInit = true;
- System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this);
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this);
+ }
}
public final boolean isInit() { return isInit; }
@@ -343,7 +347,9 @@ 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 "+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(verbose) {
+ 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;
@@ -388,6 +394,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f);
+ if(flipVerticalInGLOrientation && gl.getContext().getGLDrawable().isGLOriented() ) {
+ pmvMatrix.glRotatef(180f, 1.0f, 0.0f, 0.0f);
+ }
st.uniform(gl, pmvMatrixUniform);
st.useProgram(gl, false);
@@ -399,7 +408,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
public void dispose(GLAutoDrawable drawable) {
if( !isInit ) { return; }
isInit = false;
- System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse);
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse);
+ }
final Object upstreamWidget = drawable.getUpstreamWidget();
if (upstreamWidget instanceof Window) {
final Window window = (Window) upstreamWidget;
@@ -425,7 +436,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.destroy(gl);
st = null;
- System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN");
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN");
+ }
}
@Override
@@ -482,9 +495,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.useProgram(gl, true);
pmvMatrix.glPushMatrix();
pmvMatrix.glTranslatef(panX, panY, panZ);
- pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
- pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
- pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+ final float flipVF = ( flipVerticalInGLOrientation && drawable.isGLOriented() ) ? -1f : 1f;
+ pmvMatrix.glRotatef(flipVF*view_rotx, 1.0f, 0.0f, 0.0f);
+ pmvMatrix.glRotatef(flipVF*view_roty, 0.0f, 1.0f, 0.0f);
+ pmvMatrix.glRotatef(flipVF*view_rotz, 0.0f, 0.0f, 1.0f);
gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f);
gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
index 18ec289d8..3133a449d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
@@ -69,10 +69,16 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
}
- public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height,
- final int frameCount, final boolean initMT, final boolean useGLJPanel, final boolean useGLCanvas,
- final boolean useAnim, final boolean overlap) {
- final GLAnimatorControl animator = useAnim ? new Animator() : null;
+ public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final int width,
+ final int height, final int frameCount, final boolean initMT, final boolean useGLJPanel,
+ final boolean useSwingDoubleBuffer, final boolean useGLCanvas, final boolean useAnim, final boolean overlap) {
+ final GLAnimatorControl animator;
+ if( useAnim ) {
+ animator = new Animator();
+ animator.start();
+ } else {
+ animator = null;
+ }
final int eWidth, eHeight;
{
final int cols = (int)Math.round(Math.sqrt(frameCount));
@@ -81,7 +87,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
eHeight = height/rows-32;
}
System.err.println("Frame size: "+width+"x"+height+" -> "+frameCount+" x "+eWidth+"x"+eHeight+", overlap "+overlap);
-
+ System.err.println("SkipGLOrientationVerticalFlip "+skipGLOrientationVerticalFlip+", useGears "+useGears+", initMT "+initMT+", useAnim "+useAnim);
final JFrame[] frame = new JFrame[frameCount];
final long[] t = new long[10];
if( wait ) {
@@ -106,9 +112,10 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
}
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
+ panel.setDoubleBuffered(useSwingDoubleBuffer);
// panel.setBounds(0, 0, width, height);
final Dimension eSize = new Dimension(eWidth, eHeight);
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, caps, useGears, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null );
+ final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null );
if( null != glad ) {
glad.addGLEventListener(new GLEventListener() {
@Override
@@ -218,19 +225,26 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ canvas.addGLEventListener(g);
}
if( null != anim ) {
anim.add(canvas);
}
return canvas;
}
- private GLAutoDrawable createGLJPanel(boolean initMT, GLCapabilitiesImmutable caps, boolean useGears, GLAnimatorControl anim, Dimension size) {
+ private GLAutoDrawable createGLJPanel(boolean initMT, boolean useSwingDoubleBuffer, GLCapabilitiesImmutable caps, boolean useGears, boolean skipGLOrientationVerticalFlip, GLAnimatorControl anim, Dimension size) {
GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
+ canvas.setDoubleBuffered(useSwingDoubleBuffer);
+ canvas.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ g.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
+ canvas.addGLEventListener(g);
}
if( null != anim ) {
anim.add(canvas);
@@ -243,66 +257,116 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
static GLCapabilitiesImmutable caps = null;
+ //
+ // NOP
+ //
+
@Test
public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException {
- test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
}
@Test
public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */,
- true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test02NopGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test03NopGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test04GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ }
+
+ //
+ // Gears
+ //
+
+ @Test
+ public void test10GearsNoGLDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test11GearsGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test12GearsGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
}
@Test
- public void test02NopGLJPanelDefGridSingle() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ public void test13GearsGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
}
@Test
- public void test03NopGLJPanelDefGridMT() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ public void test14GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
}
+
+ //
+ // Overlap + NOP
+ //
+
+
@Test
- public void test10NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException {
- test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ public void test20NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException {
+ test(null, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
}
@Test
- public void test11NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */,
- true /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ public void test21NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
}
@Test
- public void test12NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ public void test22NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
}
@Test
- public void test13NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ public void test23NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
}
// @Test
- public void test04NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ public void testXXNopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
}
// @Test
- public void test05NopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException {
+ public void testXXNopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException {
GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
- test(caps, false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */,
- false /* useGLCanvas */, false /*useAnim*/, false);
+ test(caps, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false);
}
static long duration = 0; // ms
@@ -312,9 +376,11 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
volatile int initCount = 0;
public static void main(String[] args) {
- boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useGears = false, manual=false;
- boolean overlap = false;
+ boolean manual=false;
boolean waitMain = false;
+ boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useSwingDoubleBuffer=false;
+ boolean useGears = false, skipGLOrientationVerticalFlip=false, useAnim = false;
+ boolean overlap = false;
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -333,12 +399,18 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
useGLJPanel = false;
useGLCanvas = true;
manual = true;
+ } else if(args[i].equals("-swingDoubleBuffer")) {
+ useSwingDoubleBuffer = true;
} else if(args[i].equals("-glnone")) {
useGLJPanel = false;
useGLCanvas = false;
manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
+ } else if(args[i].equals("-anim")) {
+ useAnim = true;
+ } else if(args[i].equals("-userVertFlip")) {
+ skipGLOrientationVerticalFlip = true;
} else if(args[i].equals("-overlap")) {
overlap = true;
} else if(args[i].equals("-wait")) {
@@ -357,7 +429,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( manual ) {
GLProfile.initSingleton();
TestPerf001GLJPanelInit02AWT demo = new TestPerf001GLJPanelInit02AWT();
- demo.test(null, useGears, width, height, frameCount, initMT, useGLJPanel, useGLCanvas, false /*useAnim*/, overlap /* overlap */);
+ demo.test(null, useGears, skipGLOrientationVerticalFlip, width, height, frameCount,
+ initMT, useGLJPanel, useSwingDoubleBuffer, useGLCanvas, useAnim, overlap);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit02AWT.class.getName());
}