aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-12-16 04:18:15 +0100
committerSven Gothel <[email protected]>2010-12-16 04:18:15 +0100
commit96a0e0706258824c1dd524d4cbd7682a904b84f4 (patch)
tree48784cf9a3ac72b9faaf0f602fcb5210be493eee /src
parente38af7beda4edaa719240dda50df0a6611528586 (diff)
Fix WGL Bitmap Offscreen Drawable
In conjunction with the gluegen investigation (gluegen: fbdedff789077b5ffa07811590f771b6f9a4f3a7), on Windows the type LONG is always 32bit, hence we have to declare: typedef __int32 LONG; Besides, WGL_DRAW_TO_PBUFFER_ARB and WGL_DRAW_TO_BITMAP_ARB were missing in the WGL/ARB attribute query, and the latter was not set in caps -> attributes. Added fail safe exception for null chosen caps, if X11/WGL algo fails to determine.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java53
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java22
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java16
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01NEWT.java)194
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java184
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java6
9 files changed, 286 insertions, 203 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java
index 8780af7b3..18c868c6d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java
@@ -40,6 +40,7 @@
package com.jogamp.opengl.impl.windows.wgl;
+import com.jogamp.common.nio.PointerBuffer;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.SurfaceChangeable;
import javax.media.opengl.GLContext;
@@ -73,11 +74,19 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
}
private void create() {
+ int werr;
NativeSurface ns = getNativeSurface();
+ if(DEBUG) {
+ System.err.println("WindowsBitmapWGLDrawable (1): "+ns);
+ }
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getRequestedCapabilities();
int width = getWidth();
int height = getHeight();
+
+ //
+ // 1. Create DIB Section
+ //
BITMAPINFO info = BITMAPINFO.create();
BITMAPINFOHEADER header = info.getBmiHeader();
int bitsPerPixel = (capabilities.getRedBits() +
@@ -89,7 +98,8 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
// NOTE: negating the height causes the DIB to be in top-down row
// order rather than bottom-up; ends up being correct during pixel
// readback
- header.setBiHeight(-1 * height);
+ // header.setBiHeight(-1 * height);
+ header.setBiHeight(height);
header.setBiPlanes((short) 1);
header.setBiBitCount((short) bitsPerPixel);
header.setBiXPelsPerMeter(0);
@@ -97,22 +107,42 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
header.setBiClrUsed(0);
header.setBiClrImportant(0);
header.setBiCompression(GDI.BI_RGB);
- header.setBiSizeImage(width * height * bitsPerPixel / 8);
+ int byteNum = width * height * ( bitsPerPixel >> 3 ) ;
+ header.setBiSizeImage(byteNum);
+
+ PointerBuffer pb = PointerBuffer.allocateDirect(1);
+ hbitmap = GDI.CreateDIBSection(0, info, GDI.DIB_RGB_COLORS, pb, 0, 0);
+ werr = GDI.GetLastError();
+ if(DEBUG) {
+ long p = ( pb.capacity() > 0 ) ? pb.get(0) : 0;
+ System.err.println("WindowsBitmapWGLDrawable: pb sz/ptr "+pb.capacity() + ", "+toHexString(p));
+ System.err.println("WindowsBitmapWGLDrawable: " + width+"x"+height +
+ ", bpp " + bitsPerPixel +
+ ", bytes " + byteNum +
+ ", header sz " + header.size() +
+ ", DIB ptr num " + pb.capacity()+
+ ", "+capabilities+
+ ", werr "+werr);
+ }
+ if (hbitmap == 0) {
+ throw new GLException("Error creating offscreen bitmap of " + ns + ", werr " + werr);
+ }
+ //
+ // 2. Create memory DC (device context) , and associate it with the DIB.
+ //
long hdc = GDI.CreateCompatibleDC(0);
+ werr = GDI.GetLastError();
if (hdc == 0) {
- System.out.println("LastError: " + GDI.GetLastError());
- throw new GLException("Error creating device context for offscreen OpenGL context");
+ GDI.DeleteObject(hbitmap);
+ hbitmap = 0;
+ throw new GLException("Error creating device context for offscreen OpenGL context, werr "+werr);
}
((SurfaceChangeable)ns).setSurfaceHandle(hdc);
-
- hbitmap = GDI.CreateDIBSection(hdc, info, GDI.DIB_RGB_COLORS, null, 0, 0);
- if (hbitmap == 0) {
- GDI.DeleteDC(hdc);
- hdc = 0;
- throw new GLException("Error creating offscreen bitmap of width " + width +
- ", height " + height);
+ if(DEBUG) {
+ System.err.println("WindowsBitmapWGLDrawable (2): "+ns);
}
+
if ((origbitmap = GDI.SelectObject(hdc, hbitmap)) == 0) {
GDI.DeleteObject(hbitmap);
hbitmap = 0;
@@ -120,6 +150,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
hdc = 0;
throw new GLException("Error selecting bitmap into new device context");
}
+
config.updateGraphicsConfiguration(getFactory(), ns, null);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index 47b33dd6b..41889e703 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -144,7 +144,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
if(!WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
- iattributes, sharedCtx, -1, true, floatModeTmp)){
+ iattributes, sharedCtx, -1, floatModeTmp)){
throw new GLException("Pbuffer-related extensions not supported");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 3db69be50..0ff1832d1 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -186,6 +186,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
static int fillAttribsForGeneralWGLARBQuery(boolean haveWGLARBMultisample, int[] iattributes) {
int niattribs = 0;
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_BITMAP_ARB;
iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
@@ -275,7 +277,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
{
if ( !WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
- iattributes, sharedContext, accelerationMode, false, null))
+ iattributes, sharedContext, accelerationMode, null))
{
if (DEBUG) {
System.err.println("wglChoosePixelFormatARB1: GLCapabilities2AttribList failed: " + GDI.GetLastError());
@@ -403,8 +405,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
static boolean GLCapabilities2AttribList(GLCapabilitiesImmutable caps,
int[] iattributes,
GLContextImpl sharedCtx,
- int accellerationValue,
- boolean pbuffer,
+ int accellerationValue,
int[] floatMode) throws GLException {
boolean haveWGLChoosePixelFormatARB = sharedCtx.isExtensionAvailable(WGL_ARB_pixel_format);
boolean haveWGLARBMultisample = sharedCtx.isExtensionAvailable(WGL_ARB_multisample);
@@ -417,6 +418,9 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return false;
}
+ boolean onscreen = caps.isOnscreen();
+ boolean pbuffer = caps.isPBuffer();
+
int niattribs = 0;
iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
@@ -425,11 +429,14 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
iattributes[niattribs++] = accellerationValue;
}
- if (pbuffer) {
+ if (onscreen) {
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
+ iattributes[niattribs++] = GL.GL_TRUE;
+ } else if (pbuffer) {
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
iattributes[niattribs++] = GL.GL_TRUE;
} else {
- iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_BITMAP_ARB;
iattributes[niattribs++] = GL.GL_TRUE;
}
@@ -620,7 +627,10 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
res.setPBuffer(usePBuffer);
} else {
if(DEBUG) {
- System.err.println("WGL DrawableType does not match: req(onscrn "+onscreen+", pbuffer "+usePBuffer+"), got(onscreen "+( 0 != (drawableTypeBits & WINDOW_BIT) )+", pbuffer "+( 0 != (drawableTypeBits & PBUFFER_BIT) )+", pixmap "+( 0 != (drawableTypeBits & BITMAP_BIT))+")");
+ System.err.println("WGL DrawableType does not match: req(onscrn "+onscreen+", pbuffer "+usePBuffer+
+ "), got(onscreen "+( 0 != (drawableTypeBits & WINDOW_BIT) )+
+ ", pbuffer "+( 0 != (drawableTypeBits & PBUFFER_BIT) )+
+ ", bitmap "+( 0 != (drawableTypeBits & BITMAP_BIT))+")");
}
return null;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 051dc5bad..0996438db 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -275,8 +275,14 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
pixelFormatCaps = availableCaps[chosenIndex];
pfdID = pformats[chosenIndex];
+ if( null == pixelFormatCaps) {
+ throw new GLException("Null Capabilities with "+
+ " chosen pfdID: native recommended "+ (recommendedIndex+1) +
+ " chosen "+pfdID);
+ }
if (DEBUG) {
- System.err.println("!!! chosen pfdID "+pfdID+", caps " + pixelFormatCaps);
+ System.err.println("!!! chosen pfdID (ARB): native recommended "+ (recommendedIndex+1) +
+ " chosen "+pfdID+", caps " + pixelFormatCaps);
}
}
} finally {
@@ -359,8 +365,14 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
pixelFormatCaps = availableCaps[chosenIndex];
pfdID = pformats[chosenIndex];
+ if( null == pixelFormatCaps) {
+ throw new GLException("Null Capabilities with "+
+ " chosen pfdID: native recommended "+ (recommendedIndex+1) +
+ " chosen "+pfdID);
+ }
if (DEBUG) {
- System.err.println("!!! chosen pfdID "+pfdID+", idx " + chosenIndex + ", caps " + pixelFormatCaps);
+ System.err.println("!!! chosen pfdID (GDI): native recommended "+ (recommendedIndex+1) +
+ " chosen "+pfdID+", caps " + pixelFormatCaps);
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 47110add9..3a18b3a2a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -39,8 +39,16 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen,
CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
+ if(null == screen) {
+ throw new NativeWindowException("Null screen");
+ }
+ if(null == capsChosen) {
+ throw new NativeWindowException("Null chosen caps");
+ }
+ if(null == capsRequested) {
+ throw new NativeWindowException("Null requested caps");
+ }
this.screen = screen;
-
this.capabilitiesChosen = capsChosen;
this.capabilitiesRequested = capsRequested;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
index 6be732a63..3ad2c4213 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
@@ -72,7 +72,7 @@ public class Surface2File implements SurfaceUpdatedListener {
File file = File.createTempFile(basename + shotNum + "-", ".ppm");
TextureIO.write(readBufferUtil.getTextureData(), file);
- System.out.println("Wrote: " + file.getAbsolutePath() + ", ...");
+ System.err.println("Wrote: " + file.getAbsolutePath() + ", ...");
shotNum++;
readBufferUtil.rewindPixelBuffer();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
index 8851e4f7f..6a02bc03b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
@@ -38,7 +38,6 @@ import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.opengl.GLWindow;
import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -50,7 +49,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
import java.io.IOException;
-public class TestOffscreen01NEWT extends UITestCase {
+public class TestOffscreen01GLPBufferNEWT extends UITestCase {
static GLProfile glpDefault;
static GLDrawableFactory glDrawableFactory;
static int width, height;
@@ -87,25 +86,14 @@ public class TestOffscreen01NEWT extends UITestCase {
window.setSize(width, height);
GLWindow glWindow = GLWindow.create(window);
Assert.assertNotNull(glWindow);
- try {
- glWindow.setVisible(true);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
+ glWindow.setVisible(true);
+
GLEventListener demo = new RedSquare();
WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
glWindow.addGLEventListener(demo);
while ( glWindow.getTotalFrames() < 2) {
- try {
- glWindow.display();
- } catch (Throwable t) {
- // stop test and ignore if pbuffer cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
+ glWindow.display();
}
if(null!=glWindow) {
@@ -192,28 +180,17 @@ public class TestOffscreen01NEWT extends UITestCase {
windows[i].setSize(width, height);
glWindows[i] = GLWindow.create(windows[i]);
Assert.assertNotNull(glWindows[i]);
- try {
- glWindows[i].setVisible(true);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
+ glWindows[i].setVisible(true);
+
demos[i] = new RedSquare();
WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
glWindows[i].addGLEventListener(demos[i]);
}
- try {
- while ( glWindows[0].getTotalFrames() < 2) {
- for(i=0; i<winnum; i++) {
- glWindows[i].display();
- }
+ while ( glWindows[0].getTotalFrames() < 2) {
+ for(i=0; i<winnum; i++) {
+ glWindows[i].display();
}
- } catch (Throwable t) {
- // stop test and ignore if pbuffer cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
}
for(i=0; i<winnum; i++) {
@@ -257,31 +234,18 @@ public class TestOffscreen01NEWT extends UITestCase {
windows[i].setSize(width, height);
glWindows[i] = GLWindow.create(windows[i]);
Assert.assertNotNull(glWindows[i]);
- try {
- glWindows[i].setVisible(true);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
+ glWindows[i].setVisible(true);
demos[i] = new RedSquare();
WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
glWindows[i].addGLEventListener(demos[i]);
}
- try {
- while ( glWindows[0].getTotalFrames() < 2) {
- for(i=0; i<winnum; i++) {
- glWindows[i].display();
- }
+ while ( glWindows[0].getTotalFrames() < 2) {
+ for(i=0; i<winnum; i++) {
+ glWindows[i].display();
}
- } catch (Throwable t) {
- // stop test and ignore if pbuffer cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
}
-
for(i=0; i<winnum; i++) {
if(null!=glWindows[i]) {
glWindows[i].destroy();
@@ -316,13 +280,7 @@ public class TestOffscreen01NEWT extends UITestCase {
window.setSize(width, height);
GLWindow glWindow = GLWindow.create(window);
Assert.assertNotNull(glWindow);
- try {
- glWindow.setVisible(true);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
+ glWindow.setVisible(true);
GLWindow windowOnScreen = null;
WindowListener wl=null;
@@ -332,13 +290,7 @@ public class TestOffscreen01NEWT extends UITestCase {
GLEventListener demo = new RedSquare();
Assert.assertNotNull(demo);
- try {
- WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
- } catch (Throwable t) {
- // stop test and ignore if pbuffer cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
+ WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
if(null!=windowOnScreen) {
windowOnScreen.destroy();
@@ -357,122 +309,8 @@ public class TestOffscreen01NEWT extends UITestCase {
}
}
- @Test
- public void test11OffscreenWindowPixmap() {
- // Offscreen doesn't work on >= GL3 (ATI)
- GLProfile glp = GLProfile.get(GLProfile.GL2);
- Assert.assertNotNull(glp);
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
-
- GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
-
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
- Window window = NewtFactory.createWindow(screen, caps2);
- Assert.assertNotNull(window);
- window.setSize(width, height);
- GLWindow glWindow = GLWindow.create(window);
- Assert.assertNotNull(glWindow);
- try {
- glWindow.setVisible(true);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
- GLEventListener demo = new RedSquare();
- WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
- glWindow.addGLEventListener(demo);
-
- while ( glWindow.getTotalFrames() < 2) {
- try {
- glWindow.display();
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
- }
-
- if(null!=glWindow) {
- glWindow.destroy();
- }
- if(null!=window) {
- window.destroy();
- }
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
- }
-
- @Test
- public void test14OffscreenSnapshotWithDemoPixmap() {
- // Offscreen doesn't work on >= GL3 (ATI)
- GLProfile glp = GLProfile.get(GLProfile.GL2);
- Assert.assertNotNull(glp);
- GLCapabilities caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
-
- GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
-
- System.out.println("Create Window 1");
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
- Window window = NewtFactory.createWindow(screen, caps2);
- Assert.assertNotNull(window);
- window.setSize(width, height);
- GLWindow glWindow = GLWindow.create(window);
- Assert.assertNotNull(glWindow);
- try {
- glWindow.setVisible(true);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
-
- GLWindow windowOnScreen = null;
- WindowListener wl=null;
- MouseListener ml=null;
- SurfaceUpdatedListener ul=null;
-
- GLEventListener demo = new RedSquare();
- Assert.assertNotNull(demo);
-
- try {
- WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
- } catch (Throwable t) {
- // stop test and ignore if pixmap cannot be used
- t.printStackTrace();
- Assume.assumeNoException(t);
- }
-
- if(null!=windowOnScreen) {
- windowOnScreen.destroy();
- }
- if(null!=glWindow) {
- glWindow.destroy();
- }
- if(null!=window) {
- window.destroy();
- }
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
- }
public static void main(String args[]) throws IOException {
- String tstname = TestOffscreen01NEWT.class.getName();
+ String tstname = TestOffscreen01GLPBufferNEWT.class.getName();
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
tstname,
"filtertrace=true",
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
new file mode 100644
index 000000000..d92b4ffbf
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
@@ -0,0 +1,184 @@
+/**
+ * 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.offscreen;
+
+
+import com.jogamp.newt.Display;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.event.WindowListener;
+import com.jogamp.newt.opengl.GLWindow;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.media.opengl.*;
+import javax.media.nativewindow.*;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import java.io.IOException;
+
+public class TestOffscreen02BitmapNEWT extends UITestCase {
+ static GLProfile glpDefault;
+ static GLDrawableFactory glDrawableFactory;
+ static int width, height;
+ GLCapabilities capsDefault;
+
+ @BeforeClass
+ public static void initClass() {
+ GLProfile.initSingleton(true);
+ glpDefault = GLProfile.getDefault();
+ Assert.assertNotNull(glpDefault);
+ glDrawableFactory = GLDrawableFactory.getFactory(glpDefault);
+ System.out.println("INFO: PBuffer supported: "+ glDrawableFactory.canCreateGLPbuffer(null));
+ width = 640;
+ height = 480;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ @Before
+ public void init() {
+ capsDefault = new GLCapabilities(glpDefault);
+ Assert.assertNotNull(capsDefault);
+ }
+
+ @Test
+ public void test11OffscreenWindowPixmap() {
+ // Offscreen doesn't work on >= GL3 (ATI)
+ GLProfile glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+ GLCapabilities caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
+
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Window window = NewtFactory.createWindow(screen, caps2);
+ Assert.assertNotNull(window);
+ window.setSize(width, height);
+ GLWindow glWindow = GLWindow.create(window);
+ Assert.assertNotNull(glWindow);
+ glWindow.setVisible(true);
+
+ GLEventListener demo = new RedSquare();
+ WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
+ glWindow.addGLEventListener(demo);
+
+ while ( glWindow.getTotalFrames() < 2) {
+ glWindow.display();
+ }
+
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
+ }
+ if(null!=screen) {
+ screen.destroy();
+ }
+ if(null!=display) {
+ display.destroy();
+ }
+ }
+
+ @Test
+ public void test14OffscreenSnapshotWithDemoPixmap() {
+ // Offscreen doesn't work on >= GL3 (ATI)
+ GLProfile glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+ GLCapabilities caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+
+ GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
+
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+ Window window = NewtFactory.createWindow(screen, caps2);
+ Assert.assertNotNull(window);
+ window.setSize(width, height);
+ GLWindow glWindow = GLWindow.create(window);
+ Assert.assertNotNull(glWindow);
+ glWindow.setVisible(true);
+
+ GLWindow windowOnScreen = null;
+ WindowListener wl=null;
+ MouseListener ml=null;
+ SurfaceUpdatedListener ul=null;
+
+ GLEventListener demo = new RedSquare();
+ Assert.assertNotNull(demo);
+
+ WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
+
+ if(null!=windowOnScreen) {
+ windowOnScreen.destroy();
+ }
+ if(null!=glWindow) {
+ glWindow.destroy();
+ }
+ if(null!=window) {
+ window.destroy();
+ }
+ if(null!=screen) {
+ screen.destroy();
+ }
+ if(null!=display) {
+ display.destroy();
+ }
+ }
+ public static void main(String args[]) throws IOException {
+ String tstname = TestOffscreen02BitmapNEWT.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" } );
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
index ba9896d4b..4420a5107 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -95,9 +95,9 @@ public class WindowUtilNEWT {
}
if(debug) {
- System.out.println("+++++++++++++++++++++++++++");
- System.out.println(windowOffScreen);
- System.out.println("+++++++++++++++++++++++++++");
+ System.err.println("+++++++++++++++++++++++++++");
+ System.err.println(windowOffScreen);
+ System.err.println("+++++++++++++++++++++++++++");
}
while ( windowOffScreen.getTotalFrames() < frames) {