summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-03-21 07:38:11 +0100
committerSven Gothel <[email protected]>2011-03-21 07:38:11 +0100
commit694eb0c9309b3705a8bdb582f0c287aa77169996 (patch)
tree1d7388c668b6cbc1ff21697454591f97dedb0612 /src
parentab93183b90e83b9aebc29031c7b88b9a3dc58ff5 (diff)
Fix Bug #460 - GLCanvas NPE
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug460GLCanvasNPEAWT.java80
2 files changed, 84 insertions, 1 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 086a17362..4e6c29e01 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -745,12 +745,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
@Override
public String toString() {
+ final int dw = (null!=drawable) ? drawable.getWidth() : -1;
+ final int dh = (null!=drawable) ? drawable.getHeight() : -1;
+
return "AWT-GLCanvas[Realized "+isRealized()+
",\n\t"+((null!=drawable)?drawable.getClass().getName():"null-drawable")+
",\n\tRealized "+isRealized()+
",\n\tFactory "+getFactory()+
",\n\thandle 0x"+Long.toHexString(getHandle())+
- ",\n\tDrawable size "+drawable.getWidth()+"x"+drawable.getHeight()+
+ ",\n\tDrawable size "+dw+"x"+dh+
",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
",\n\tvisible "+isVisible()+
",\n\t"+awtConfig+"]";
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug460GLCanvasNPEAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug460GLCanvasNPEAWT.java
new file mode 100644
index 000000000..fea835377
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug460GLCanvasNPEAWT.java
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.util.Collections;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Test;
+
+public class TestBug460GLCanvasNPEAWT {
+
+ public static void main(String[] args) {
+ TestBug460GLCanvasNPEAWT instance = new TestBug460GLCanvasNPEAWT();
+ instance.testJogl2ExtensionCheck();
+ }
+
+ @Test
+ public void testJogl2ExtensionCheck() {
+ GLProfile.initSingleton(false);
+// GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCanvas glc = new GLCanvas(caps);
+ GLDrawableFactory usine = glc.getFactory();
+ GLCapabilitiesImmutable glci = glc.getChosenGLCapabilities();
+ GLCapabilitiesChooser glcc = new DefaultGLCapabilitiesChooser();
+ AbstractGraphicsDevice agd = usine.getDefaultDevice();
+
+ GLPbuffer pbuffer = usine.createGLPbuffer(agd, glci, glcc, 256, 256, null);
+ GLContext context = pbuffer.getContext();
+ context.makeCurrent();
+ GL2 gl = pbuffer.getContext().getGL().getGL2();
+
+ String extensions = gl.glGetString(GL.GL_EXTENSIONS);
+ String[] tabExtensions = extensions.split(" ");
+ SortedSet<String> setExtensions = new TreeSet<String>();
+ Collections.addAll(setExtensions, tabExtensions);
+ System.out.println(setExtensions);
+ }
+}
+