aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java28
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java26
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java47
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java4
7 files changed, 60 insertions, 85 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
index 1e938c200..b3a0de845 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
@@ -39,8 +39,6 @@ import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
-import jogamp.opengl.GLDrawableFactoryImpl;
-
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -50,33 +48,11 @@ public class TestGLExtensionQueryOffscreen {
public static void main(final String[] args) {
final TestGLExtensionQueryOffscreen instance = new TestGLExtensionQueryOffscreen();
- instance.testJogl2ExtensionCheck1();
- instance.testJogl2ExtensionCheck2();
- }
-
- /**
- * @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended
- */
- @Test
- public void testJogl2ExtensionCheck1() {
- final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory();
- final GLContext sharedContext = factory.getOrCreateSharedContext(null);
- sharedContext.makeCurrent();
- String extensions;
- try {
- extensions = sharedContext.getGL().glGetString(GL.GL_EXTENSIONS);
- } finally {
- sharedContext.release();
- }
- final String[] tabExtensions = extensions.split(" ");
- final SortedSet<String> setExtensions = new TreeSet<String>();
- Collections.addAll(setExtensions, tabExtensions);
- System.out.println("SharedContext: "+sharedContext);
- System.out.println("SharedContext: "+setExtensions);
+ instance.testJogl2ExtensionCheck();
}
@Test
- public void testJogl2ExtensionCheck2() {
+ public void testJogl2ExtensionCheck() {
final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
index f91e34c12..a0e846d7d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
@@ -1,6 +1,7 @@
package com.jogamp.opengl.test.junit.jogl.acore;
import jogamp.nativewindow.x11.X11Util;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
@@ -10,22 +11,21 @@ import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLOffscreenAutoDrawable;
-import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
/**
- * Tests the closing the device of GLWindow and GLPBuffer in JOGL
+ * Tests the closing the device of GLWindow and off-screen GLAutoDrawable using FBO and PBuffer in JOGL
*/
-@SuppressWarnings("deprecation")
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestNEWTCloseX11DisplayBug565 {
@Test
- public void testX11WindowMemoryLeak() throws Exception {
+ public void test01X11WindowMemoryLeak() throws Exception {
GLProfile.initSingleton(); // ensure shared resource runner is done
try {
for ( int j = 0; j < 10; j++ ) {
@@ -64,7 +64,7 @@ public class TestNEWTCloseX11DisplayBug565 {
@Test
- public void testX11WindowMemoryLeakGLPbuffer() throws Exception {
+ public void test02X11WindowMemoryLeakPBufferAutoDrawable() throws Exception {
GLProfile.initSingleton(); // ensure shared resource runner is done
try {
for ( int j = 0; j < 10; j++ ) {
@@ -75,17 +75,9 @@ public class TestNEWTCloseX11DisplayBug565 {
open0 = 0;
}
final GLProfile glp = GLProfile.getDefault( );
- final GLCapabilitiesImmutable caps = new GLCapabilities( glp );
-
-
- final GLPbuffer buffer = GLDrawableFactory.getFactory( glp ).createGLPbuffer(
- null,
- caps,
- new DefaultGLCapabilitiesChooser(),
- 256,
- 256,
- null
- );
+ final GLCapabilities caps = new GLCapabilities( glp );
+ caps.setPBuffer(true);
+ final GLAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable(null, caps, null, 256, 256);
buffer.display();
buffer.destroy();
@@ -106,7 +98,7 @@ public class TestNEWTCloseX11DisplayBug565 {
}
@Test
- public void testX11WindowMemoryLeakFBOAutoDrawable() throws Exception {
+ public void test03X11WindowMemoryLeakFBOAutoDrawable() throws Exception {
GLProfile.initSingleton(); // ensure shared resource runner is done
try {
for ( int j = 0; j < 10; j++ ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
index 7138513d5..ec377662f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
@@ -30,10 +30,9 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;
-import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
import jogamp.nativewindow.jawt.JAWTUtil;
@@ -47,7 +46,6 @@ import org.junit.runners.MethodSorters;
import com.jogamp.common.util.RunnableTask;
import com.jogamp.opengl.test.junit.util.UITestCase;
-@SuppressWarnings("deprecation")
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPBufferDeadlockAWT extends UITestCase {
static GLProfile glp;
@@ -62,12 +60,8 @@ public class TestPBufferDeadlockAWT extends UITestCase {
}
protected void runTestGL( final GLCapabilities caps ) throws InterruptedException, InvocationTargetException {
- final GLPbuffer pbuffer = GLDrawableFactory.getFactory( GLProfile.getGL2ES2() ).createGLPbuffer(
- null,
- caps, new DefaultGLCapabilitiesChooser(),
- 512, 512,
- null
- );
+ caps.setPBuffer(true);
+ final GLAutoDrawable pbuffer = GLDrawableFactory.getFactory( caps.getGLProfile() ).createOffscreenAutoDrawable(null, caps, null, 512, 512);
final boolean[] done = {false};
final Runnable pbufferCreationAction = new Runnable() {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
index 19c96af14..c85c7467f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
@@ -57,7 +57,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
/**
- * Tests for bug 461, a failure of GLDrawableFactory.createGLPbuffer() on Windows
+ * Tests for bug 461, a failure of GLDrawableFactory.createOffscreenAutoDrawable(..) on Windows
* when the stencil buffer is turned on.
*
* @author Wade Walker (from code sample provided by Owen Dimond)
@@ -97,7 +97,6 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
/* @Override */
public void display(final GLAutoDrawable drawable) {
render(offScreenBuffer);
- // BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false);
final BufferedImage outputImage = awtGLReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */);
Assert.assertNotNull(outputImage);
final ImageIcon imageIcon = new ImageIcon(outputImage);
@@ -145,14 +144,13 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
final GLDrawableFactory fac = GLDrawableFactory.getFactory(glp);
Assert.assertNotNull(fac);
- Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) );
-
final GLCapabilities glCap = new GLCapabilities(glp);
Assert.assertNotNull(glCap);
// COMMENTING OUT THIS LINE FIXES THE ISSUE.
// Setting this in JOGL1 works. Thus this is a JOGL2 issue.
glCap.setSampleBuffers(true);
+ glCap.setNumSamples(4);
// Without line below, there is an error on Windows.
// glCap.setDoubleBuffered(false); // implicit double buffer -> MSAA + FBO
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java
index 1e0f8fe4a..85bf2ceb3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.awt;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
@@ -40,7 +39,7 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
@@ -52,18 +51,19 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
/**
- * Tests for bug 461, a failure of GLDrawableFactory.createGLPbuffer() on Windows
+ * Tests for bug 461, a failure of PBuffer GLDrawableFactory.createOffscreenAutoDrawable(..) on Windows
* when the stencil buffer is turned on.
*
- * @author Wade Walker (from code sample provided by Owen Dimond)
+ * @author Wade Walker (from code sample provided by Owen Dimond), et al.
*/
-@SuppressWarnings("deprecation")
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implements GLEventListener {
JFrame jframe;
- GLPbuffer offScreenBuffer;
+ GLOffscreenAutoDrawable offScreenBuffer;
+ AWTGLReadBufferUtil screenshot;
private void render(final GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
@@ -83,6 +83,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement
/* @Override */
public void init(final GLAutoDrawable drawable) {
+ screenshot = new AWTGLReadBufferUtil(drawable.getGLProfile(), false);
}
/* @Override */
@@ -92,7 +93,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement
/* @Override */
public void display(final GLAutoDrawable drawable) {
render(offScreenBuffer);
- final BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false);
+ final BufferedImage outputImage = screenshot.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */);
Assert.assertNotNull(outputImage);
final ImageIcon imageIcon = new ImageIcon(outputImage);
final JLabel imageLabel = new JLabel(imageIcon);
@@ -101,6 +102,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement
/* @Override */
public void dispose(final GLAutoDrawable drawable) {
+ screenshot.dispose(drawable.getGL());
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -113,7 +115,23 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement
}
@Test
- public void testOffscreenSupersampling() throws InterruptedException, InvocationTargetException {
+ public void test01DefaultOffscreenSupersampling() throws InterruptedException, InvocationTargetException {
+ final GLProfile glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+ final GLCapabilities glCap = new GLCapabilities(glp);
+ test(glCap);
+ }
+
+ @Test
+ public void test02PBufferOffscreenSupersampling() throws InterruptedException, InvocationTargetException {
+ final GLProfile glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+ final GLCapabilities glCap = new GLCapabilities(glp);
+ glCap.setPBuffer(true);
+ test(glCap);
+ }
+
+ void test(final GLCapabilities glCap) throws InterruptedException, InvocationTargetException {
jframe = new JFrame("Offscreen Supersampling");
Assert.assertNotNull(jframe);
jframe.setSize( 300, 300);
@@ -123,20 +141,13 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement
}
});
- final GLProfile glp = GLProfile.get(GLProfile.GL2);
- Assert.assertNotNull(glp);
-
- final GLDrawableFactory fac = GLDrawableFactory.getFactory(glp);
+ final GLDrawableFactory fac = GLDrawableFactory.getFactory(glCap.getGLProfile());
Assert.assertNotNull(fac);
- Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) );
-
- final GLCapabilities glCap = new GLCapabilities(glp);
- Assert.assertNotNull(glCap);
-
// COMMENTING OUT THIS LINE FIXES THE ISSUE.
// Setting this in JOGL1 works. Thus this is a JOGL2 issue.
glCap.setSampleBuffers(true);
+ glCap.setNumSamples(4);
// Without line below, there is an error on Windows.
glCap.setDoubleBuffered(false);
@@ -144,7 +155,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement
glCap.setStencilBits(1);
//makes a new buffer
- offScreenBuffer = fac.createGLPbuffer(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null);
+ offScreenBuffer = fac.createOffscreenAutoDrawable(null, glCap, null, 200, 200);
Assert.assertNotNull(offScreenBuffer);
offScreenBuffer.addGLEventListener(this);
offScreenBuffer.display();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
index a42564dbc..c1b29b371 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.test.junit.jogl.caps;
import java.io.File;
-import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
@@ -41,7 +40,7 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
-import com.jogamp.opengl.util.awt.Screenshot;
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
import com.jogamp.opengl.util.texture.TextureIO;
import java.awt.image.BufferedImage;
@@ -56,6 +55,8 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug605FlippedImageAWT extends UITestCase {
class FlippedImageTest implements GLEventListener {
+ AWTGLReadBufferUtil screenshot;
+
public void display(final GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
@@ -87,34 +88,35 @@ public class TestBug605FlippedImageAWT extends UITestCase {
final int height = drawable.getSurfaceHeight();
final String fname = getSnapshotFilename(0, null, caps, width, height, false, TextureIO.PNG, null);
+ final BufferedImage image;
try {
- Screenshot.writeToFile(new File(fname), width, height, false);
+ image = screenshot.readPixelsToBufferedImage(gl, 0, 0, width, height, true /* awtOrientation */);
+ screenshot.write(new File(fname));
} catch (final GLException e) {
throw e;
- } catch (final IOException e) {
- throw new GLException(e);
}
- testFlipped(width, height);
+ testFlipped(image, width, height);
}
public void init(final GLAutoDrawable drawable) {
final GL gl = drawable.getGL();
System.err.println("GL_RENDERER: "+gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: "+gl.glGetString(GL.GL_VERSION));
+ screenshot = new AWTGLReadBufferUtil(drawable.getGLProfile(), false);
}
public void reshape(final GLAutoDrawable glDrawable, final int x, final int y, final int w, final int h) {}
public void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {}
- public void dispose(final GLAutoDrawable drawable) {}
+ public void dispose(final GLAutoDrawable drawable) {
+ screenshot.dispose(drawable.getGL());
+ }
}
static final int green = 0x0000ff00; // above
static final int red = 0x00ff0000; // below
- private void testFlipped(final int width, final int height) {
+ private void testFlipped(final BufferedImage image, final int width, final int height) {
// Default origin 0/0 is lower left corner, so is the memory layout
// However AWT origin 0/0 is upper left corner
- final BufferedImage image = Screenshot.readToBufferedImage(width, height);
-
final int below = image.getRGB(0, height-1) & 0x00ffffff;
System.err.println("below: 0x"+Integer.toHexString(below));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
index 32e0be3e1..96db8e564 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
@@ -32,6 +32,7 @@ import com.jogamp.opengl.util.glsl.ShaderState;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLBufferStorage;
import javax.media.opengl.GLDrawable;
import org.junit.Assert;
@@ -55,7 +56,8 @@ public class GLSLMiscHelper {
Assert.assertEquals(data.enabled()?GL.GL_TRUE:GL.GL_FALSE, qi[0]);
gl.glGetVertexAttribiv(data.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0);
Assert.assertEquals(data.getVBOName(), qi[0]);
- Assert.assertEquals(data.getSizeInBytes(), gl.glGetBufferSize(data.getVBOName()));
+ final GLBufferStorage glStore = gl.getBufferStorage(data.getVBOName());
+ Assert.assertEquals("GLBufferStorage size mismatch, storage "+glStore, data.getSizeInBytes(), null != glStore ? glStore.getSize() : -1);
}
public static void pause(final long ms) throws InterruptedException {