aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java2
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java4
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java193
4 files changed, 204 insertions, 7 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 266868d69..352c1e25e 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -236,7 +236,7 @@ public class WindowsWGLContext extends GLContextImpl {
throw new GLException("Unable to create temp OpenGL context for device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()));
}
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
- throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Error making temp context current: 0x" + toHexString(temp_hglrc) + ", werr: 0x"+Integer.toHexString(WGL.GetLastError()));
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
@@ -264,7 +264,7 @@ public class WindowsWGLContext extends GLContextImpl {
WGL.wglDeleteContext(temp_hglrc);
if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
- throw new GLException("Cannot make previous verified context current: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Cannot make previous verified context current: 0x" + toHexString(hglrc) + ", werr: 0x" + Integer.toHexString(WGL.GetLastError()));
}
} else {
if(glCaps.getGLProfile().isGL3()) {
@@ -281,14 +281,14 @@ public class WindowsWGLContext extends GLContextImpl {
if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(hglrc);
- throw new GLException("Error making old context current: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Error making old context current: 0x" + toHexString(hglrc) + ", werr: 0x" + Integer.toHexString(WGL.GetLastError()));
}
}
if(0!=share) {
if (!WGL.wglShareLists(share, hglrc)) {
throw new GLException("wglShareLists(" + toHexString(share) +
- ", " + toHexString(hglrc) + ") failed: error code 0x" +
+ ", " + toHexString(hglrc) + ") failed: werr 0x" +
Integer.toHexString(WGL.GetLastError()));
}
}
@@ -310,7 +310,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (WGL.wglGetCurrentContext() != hglrc) {
if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
- throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError()) + ", " + this);
+ throw new GLException("Error making context current: 0x" + toHexString(hglrc) + ", werr: 0x" + Integer.toHexString(WGL.GetLastError()) + ", " + this);
} else {
if (DEBUG && VERBOSE) {
System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
@@ -333,7 +333,7 @@ public class WindowsWGLContext extends GLContextImpl {
protected void releaseImpl() throws GLException {
if (!wglMakeContextCurrent(0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Error freeing OpenGL context, werr: 0x" + Integer.toHexString(WGL.GetLastError()));
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index 712ac029a..1d7f696b2 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -276,7 +276,7 @@ public abstract class X11GLXContext extends GLContextImpl {
drawable.getNativeWindow().getSurfaceHandle(),
drawableRead.getNativeWindow().getSurfaceHandle(),
temp_context)) {
- throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(context)+", drawable "+drawable);
+ throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_context)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
index 9dded09e6..ee2c85502 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
@@ -94,6 +94,7 @@ public class TestOffscreen01NEWT {
glWindow.setVisible(true);
GLEventListener demo = new RedSquare();
WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
+ glWindow.addGLEventListener(demo);
while ( glWindow.getTotalFrames() < 2) {
glWindow.display();
@@ -186,6 +187,7 @@ public class TestOffscreen01NEWT {
glWindows[i].setVisible(true);
demos[i] = new RedSquare();
WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
+ glWindows[i].addGLEventListener(demos[i]);
}
while ( glWindows[0].getTotalFrames() < 2) {
@@ -238,6 +240,7 @@ public class TestOffscreen01NEWT {
glWindows[i].setVisible(true);
demos[i] = new RedSquare();
WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
+ glWindows[i].addGLEventListener(demos[i]);
}
while ( glWindows[0].getTotalFrames() < 2) {
@@ -331,6 +334,7 @@ public class TestOffscreen01NEWT {
glWindow.setVisible(true);
GLEventListener demo = new RedSquare();
WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
+ glWindow.addGLEventListener(demo);
while ( glWindow.getTotalFrames() < 2) {
glWindow.display();
diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java
new file mode 100755
index 000000000..6415d553b
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.test.junit.newt;
+
+import java.lang.reflect.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+import javax.media.opengl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.*;
+
+import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
+import com.jogamp.newt.opengl.*;
+
+import java.io.IOException;
+
+import com.jogamp.test.junit.util.*;
+import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
+
+public class TestParenting01NEWT {
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ width = 640;
+ height = 480;
+ }
+
+ static Window createWindow(NativeWindow parent, Screen screen, Capabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
+ Assert.assertNotNull(caps);
+ caps.setOnscreen(onscreen);
+ // System.out.println("Requested: "+caps);
+
+ //
+ // Create native windowing resources .. X11/Win/OSX
+ //
+ Window window;
+ if(null==parent) {
+ window = NewtFactory.createWindow(screen, caps, onscreen && undecorated);
+ } else {
+ window = NewtFactory.createWindow(parent.getWindowHandle(), screen, caps, onscreen && undecorated);
+ }
+ Assert.assertNotNull(window);
+ window.setSize(width, height);
+ Assert.assertTrue(false==window.isVisible());
+ window.setVisible(true);
+ Assert.assertTrue(true==window.isVisible());
+ Assert.assertTrue(width==window.getWidth());
+ Assert.assertTrue(height==window.getHeight());
+ // System.out.println("Created: "+window);
+
+ //
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // equivalent to GLAutoDrawable methods: setVisible(true)
+ //
+ caps = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ Assert.assertNotNull(caps);
+ Assert.assertTrue(caps.getGreenBits()>5);
+ Assert.assertTrue(caps.getBlueBits()>5);
+ Assert.assertTrue(caps.getRedBits()>5);
+ Assert.assertTrue(caps.isOnscreen()==onscreen);
+
+ return window;
+ }
+
+ static void destroyWindow(Display display, Screen screen, Window window, GLWindow glWindow) {
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
+ }
+ if(null!=screen) {
+ screen.destroy();
+ }
+ if(null!=display) {
+ display.destroy();
+ }
+ }
+
+ @Test
+ public void testWindowParentingNewtOnNewt() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(null);
+ Assert.assertNotNull(caps);
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+
+ Window window1 = createWindow( null, screen, caps, width, height, true /* onscreen */, false /* undecorated */);
+ Window window2 = createWindow(window1, screen, caps, width/2, height/2, true /* onscreen */, false /* undecorated */);
+
+ GLWindow glWindow1 = GLWindow.create(window1);
+ Assert.assertNotNull(glWindow1);
+ GLEventListener demo1 = new RedSquare();
+ setDemoFields(demo1, window1, glWindow1, false);
+ glWindow1.addGLEventListener(demo1);
+
+ GLWindow glWindow2 = GLWindow.create(window2);
+ Assert.assertNotNull(glWindow2);
+ GLEventListener demo2 = new Gears();
+ setDemoFields(demo2, window2, glWindow2, false);
+ glWindow2.addGLEventListener(demo2);
+
+ glWindow1.setVisible(true);
+ glWindow2.setVisible(true);
+
+ int x = window1.getX();
+ int y = window1.getY();
+ long duration = 2000;
+ long step = 20;
+ while (duration>0) {
+ // glWindow1.display();
+ glWindow2.display();
+ Thread.sleep(step); // 1000 ms
+ duration -= step;
+ x += 10;
+ y += 10;
+ // window1.setPosition(x,y);
+ }
+ destroyWindow(null, null, window2, glWindow2);
+ destroyWindow(display, screen, window1, null);
+ }
+
+ public static void setDemoFields(GLEventListener demo, Window window, GLWindow glWindow, boolean debug) {
+ Assert.assertNotNull(demo);
+ Assert.assertNotNull(window);
+ if(debug) {
+ MiscUtils.setFieldIfExists(demo, "glDebug", true);
+ MiscUtils.setFieldIfExists(demo, "glTrace", true);
+ }
+ if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
+ MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
+ }
+ }
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestParenting01NEWT.class.getName();
+ org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
+ tstname,
+ "filtertrace=true",
+ "haltOnError=false",
+ "haltOnFailure=false",
+ "showoutput=true",
+ "outputtoformatters=true",
+ "logfailedtests=true",
+ "logtestlistenerevents=true",
+ "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
+ "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
+ }
+
+}