summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-05 02:54:59 -0700
committerSven Gothel <[email protected]>2009-10-05 02:54:59 -0700
commit76bf2e5a7f23def0a3bf2b688791b593ecb283ab (patch)
tree84b7b2a25cc38450dc83a78d1f1ed165195a599e /src/jogl
parent59257476777104ff3f117d87a8205161cb800abf (diff)
GLDrawableFactory Cleanup (-> On- Offscreen and PBuffer)
- Base all PBuffer/Offscreen GLDrawable creators on a prev. created 'NativeWindow + SurfaceChangeable' instance. Simplifies implementation path. This also removes the almost cyclic referencing of GLWindow -> OffscreenWindow GLWindow -> Drawable -> NullWindow -> OffscreenWindow Now it is just GLWindow -> OffscreenWindow GLWindow -> Drawable -> OffscreenWindow - createGLDrawable() shall be used for all types now, especially if you want to pass the offscreen NativeWindow and benefit from the surfaceChangedListener etc .. - Add public createOffscreenDrawable(..) - EGLDrawable: - Query surface only if not 0 - [re]create surface only if needed, using 'ownEGL*' flag for destruction only.
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java127
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java51
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java33
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java25
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java57
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java37
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java31
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java16
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java37
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java45
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java39
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java14
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java41
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java53
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java9
16 files changed, 262 insertions, 361 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 66abcf841..aa775c3ae 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -44,7 +44,6 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.gluegen.runtime.*;
import com.sun.nativewindow.impl.NWReflection;
-import com.sun.nativewindow.impl.NullWindow;
import java.lang.reflect.*;
/** Extends GLDrawableFactory with a few methods for handling
@@ -58,48 +57,36 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
//---------------------------------------------------------------------------
// Dispatching GLDrawable construction in respect to the NativeWindow Capabilities
//
- public GLDrawable createGLDrawable(NativeWindow target0, GLCapabilitiesChooser chooser) {
- if (target0 == null) {
+ public GLDrawable createGLDrawable(NativeWindow target) {
+ if (target == null) {
throw new IllegalArgumentException("Null target");
}
- AbstractGraphicsConfiguration config = target0.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- NativeWindow target1 = NativeWindowFactory.getNativeWindow(target0, config);
- GLCapabilities caps = (GLCapabilities) target1.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilities caps = (GLCapabilities) target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
GLDrawable result = null;
if(caps.isOnscreen()) {
if(caps.isPBuffer()) {
throw new IllegalArgumentException("Onscreen target can't be PBuffer: "+caps);
}
if(DEBUG) {
- System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target1);
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
}
- result = createOnscreenDrawable(target1);
+ result = createOnscreenDrawable(target);
} else {
- GLCapabilities caps2 = (GLCapabilities) caps.clone();
- // OFFSCREEN !DOUBLE_BUFFER
- caps2.setDoubleBuffered(false);
- if(caps2.isPBuffer() && canCreateGLPbuffer()) {
+ if( ! ( target instanceof SurfaceChangeable ) ) {
+ throw new IllegalArgumentException("Passed NativeWindow must implement SurfaceChangeable for offscreen: "+target);
+ }
+ if(caps.isPBuffer() && canCreateGLPbuffer()) {
if(DEBUG) {
- System.out.println("GLDrawableFactoryImpl.createGLDrawable -> PbufferDrawable: "+target1);
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable -> PbufferDrawable: "+target);
}
- result = createGLPbufferDrawable(caps2,
- chooser,
- target1.getWidth(),
- target1.getHeight());
+ result = createGLPbufferDrawable(target);
}
if(null==result) {
if(DEBUG) {
- System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable: "+target1);
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable: "+target);
}
- result = createOffscreenDrawable(caps2,
- chooser,
- target1.getWidth(),
- target1.getHeight());
- }
- // Set upstream NativeWindow from caller to NullWindow for SurfaceUpdatedListener event
- NativeWindow nw = result.getNativeWindow();
- if(nw instanceof NullWindow) {
- ((NullWindow)nw).setUpstreamNativeWindow(target0);
+ result = createOffscreenDrawable(target);
}
}
if(DEBUG) {
@@ -108,32 +95,80 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
return result;
}
- public GLDrawable createGLDrawable(NativeWindow target) {
- return createGLDrawable(target, null);
- }
+ //---------------------------------------------------------------------------
+ //
+ // Onscreen GLDrawable construction
+ //
- /** Creates a (typically hw-accelerated) Pbuffer GLDrawable. */
- public abstract GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int initialWidth,
- int initialHeight);
+ protected abstract GLDrawableImpl createOnscreenDrawable(NativeWindow target);
- /** Creates a (typically software-accelerated) offscreen GLDrawable
- used to implement the fallback rendering path of the
- GLJPanel. */
- public abstract GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height);
+ //---------------------------------------------------------------------------
+ //
+ // PBuffer GLDrawable construction
+ //
- /** Creates a (typically hw-accelerated) onscreen GLDrawable. */
- public abstract GLDrawableImpl createOnscreenDrawable(NativeWindow target);
+ /** Target must implement SurfaceChangeable */
+ protected abstract GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target);
- public GLPbuffer createGLPbuffer(GLDrawable pbufferDrawable,
+ protected GLDrawableImpl createGLPbufferDrawable(NativeWindow target) {
+ if (!canCreateGLPbuffer()) {
+ throw new GLException("Pbuffer support not available with current graphics card");
+ }
+ return createGLPbufferDrawableImpl(target);
+ }
+
+ public GLDrawable createGLPbufferDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ int width,
+ int height) {
+ if(height<=0 || height<=0) {
+ throw new GLException("Width and height of pbuffer must be positive (were (" +
+ width + ", " + height + "))");
+ }
+ capabilities.setDoubleBuffered(false); // FIXME
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(true);
+ return createGLPbufferDrawable( createOffscreenWindow(capabilities, chooser, height, height) );
+ }
+
+ public GLPbuffer createGLPbuffer(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ int width,
+ int height,
GLContext shareWith) {
- return new GLPbufferImpl((GLDrawableImpl)pbufferDrawable, shareWith);
+ return new GLPbufferImpl( (GLDrawableImpl) createGLPbufferDrawable(capabilities, chooser, height, height),
+ shareWith);
+ }
+
+
+ //---------------------------------------------------------------------------
+ //
+ // Offscreen GLDrawable construction
+ //
+
+ protected abstract GLDrawableImpl createOffscreenDrawable(NativeWindow target) ;
+
+ public GLDrawable createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ int width,
+ int height) {
+ if(width<=0 || height<=0) {
+ throw new GLException("Width and height of pbuffer must be positive (were (" +
+ width + ", " + height + "))");
+ }
+ capabilities.setDoubleBuffered(false); // FIXME
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(false);
+ return createOffscreenDrawable( createOffscreenWindow(capabilities, chooser, width, height) );
}
+ /**
+ * creates an offscreen NativeWindow, which must implement SurfaceChangeable as well,
+ * so the windowing system related implementation is able to set the surface handle.
+ */
+ protected abstract NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser,
+ int width, int height);
+
protected GLDrawableFactoryImpl() {
super();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index 6901be23e..f109c9497 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -44,8 +44,8 @@ import javax.media.nativewindow.egl.*;
import javax.media.opengl.*;
public abstract class EGLDrawable extends GLDrawableImpl {
- protected boolean ownEGLDisplay = false;
- protected boolean ownEGLSurface = false;
+ protected boolean ownEGLDisplay = false; // for destruction
+ protected boolean ownEGLSurface = false; // for destruction
private EGLGraphicsConfiguration eglConfig;
protected long eglDisplay;
protected long eglSurface;
@@ -78,24 +78,22 @@ public abstract class EGLDrawable extends GLDrawableImpl {
protected abstract long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle);
private void recreateSurface() {
- if(ownEGLSurface) {
- // create a new EGLSurface ..
- if(EGL.EGL_NO_SURFACE!=eglSurface) {
- EGL.eglDestroySurface(eglDisplay, eglSurface);
- }
+ // create a new EGLSurface ..
+ if(EGL.EGL_NO_SURFACE!=eglSurface) {
+ EGL.eglDestroySurface(eglDisplay, eglSurface);
+ }
- if(DEBUG) {
- System.err.println("createSurface using eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+eglConfig);
- }
+ if(DEBUG) {
+ System.err.println("createSurface using eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+eglConfig);
+ }
- eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle());
- if (EGL.EGL_NO_SURFACE==eglSurface) {
- throw new GLException("Creation of window surface failed: "+eglConfig+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- }
+ eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle());
+ if (EGL.EGL_NO_SURFACE==eglSurface) {
+ throw new GLException("Creation of window surface failed: "+eglConfig+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
- if(DEBUG) {
- System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getSurfaceHandle())+" -> 0x"+Long.toHexString(eglSurface));
- }
+ if(DEBUG) {
+ System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getSurfaceHandle())+" -> 0x"+Long.toHexString(eglSurface));
}
}
@@ -121,8 +119,10 @@ public abstract class EGLDrawable extends GLDrawableImpl {
if (null == eglConfig) {
throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
}
+
int[] tmp = new int[1];
- if (EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0)) {
+ if ( 0 != component.getSurfaceHandle() &&
+ EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) {
// component holds static EGLSurface
eglSurface = component.getSurfaceHandle();
if(DEBUG) {
@@ -133,6 +133,8 @@ public abstract class EGLDrawable extends GLDrawableImpl {
ownEGLSurface=true;
eglConfig.updateGraphicsConfiguration();
+
+ recreateSurface();
}
} else {
throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
@@ -174,19 +176,8 @@ public abstract class EGLDrawable extends GLDrawableImpl {
} else if(DEBUG) {
System.err.println("Chosen eglConfig: "+eglConfig);
}
- /**
- eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle());
- while ( EGL.EGL_NO_SURFACE == eglSurface ) {
- - blacklist EGLConfig entry
- - retry ..
- if ( no more EGLConfigs available ) {
- break .. or .. exception
- }
- eglConfig.updateGraphicsConfiguration();
- eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle());
- } */
+ recreateSurface();
}
- recreateSurface();
} finally {
unlockSurface();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 90aecdabc..e9a622cc5 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -68,39 +68,22 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return new EGLOnscreenDrawable(this, target);
}
- public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(false);
+ protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
throw new GLException("Not yet implemented");
}
public boolean canCreateGLPbuffer() {
return true;
}
- public GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight) {
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(true);
- return new EGLPbufferDrawable(this, capabilities, chooser,
- initialWidth, initialHeight);
+
+ protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) {
+ return new EGLPbufferDrawable(this, target);
}
- public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight,
- final GLContext shareWith) {
- GLDrawableImpl pbufferDrawable = createGLPbufferDrawable(
- capabilities,
- chooser, initialWidth, initialHeight);
- return new GLPbufferImpl(pbufferDrawable, shareWith);
+ protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ NullWindow nw = new NullWindow(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capabilities, chooser));
+ nw.setSize(width, height);
+ return nw;
}
public GLContext createExternalGLContext() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index 473490afc..b155dc9d1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -262,5 +262,30 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
out.println(prefix+"["+i+"] "+caps[i]);
}
}
+
+ protected static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(GLCapabilities caps, GLCapabilitiesChooser chooser) {
+ if(caps.isOnscreen()) {
+ throw new GLException("Error: Onscreen set: "+caps);
+ }
+ long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
+ }
+ if (!EGL.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
+ DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, 0);
+ EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(caps, chooser, s);
+ if (null == eglConfig) {
+ EGL.eglTerminate(eglDisplay);
+ throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println("Chosen eglConfig: "+eglConfig);
+ }
+ return eglConfig;
+ }
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
index b1ae3550a..e16420b3a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
@@ -43,24 +43,17 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
import com.sun.opengl.impl.*;
-import com.sun.nativewindow.impl.NullWindow;
public class EGLPbufferDrawable extends EGLDrawable {
private int texFormat;
protected static final boolean useTexture = false; // No yet ..
- protected EGLPbufferDrawable(EGLDrawableFactory factory,
- GLCapabilities caps,
- GLCapabilitiesChooser chooser,
- int width, int height) {
- super(factory, new NullWindow(createEGLGraphicsConfiguration(caps, chooser)));
- if (width <= 0 || height <= 0) {
- throw new GLException("Width and height of pbuffer must be positive (were (" +
- width + ", " + height + "))");
- }
+ protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeWindow target) {
+ super(factory, target);
+ ownEGLDisplay = true;
// get choosen ones ..
- caps = (GLCapabilities) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ GLCapabilities caps = (GLCapabilities) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if(useTexture) {
this.texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ;
@@ -68,54 +61,28 @@ public class EGLPbufferDrawable extends EGLDrawable {
this.texFormat = EGL.EGL_NO_TEXTURE;
}
- NullWindow nw = (NullWindow) getNativeWindow();
- nw.setSize(width, height);
-
- ownEGLDisplay = true;
-
if (DEBUG) {
System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
- }
- protected static EGLGraphicsConfiguration createEGLGraphicsConfiguration(GLCapabilities caps, GLCapabilitiesChooser chooser) {
- if(caps.isOnscreen()) {
- throw new GLException("Error: Onscreen set: "+caps);
- }
- if(!caps.isPBuffer()) {
- throw new GLException("Error: PBuffer not set: "+caps);
- }
- long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
- } else if(DEBUG) {
- System.err.println("eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
- }
- if (!EGL.eglInitialize(eglDisplay, null, null)) {
- throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- }
- EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
- DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, 0);
- EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, s);
- if (null == eglConfig) {
- EGL.eglTerminate(eglDisplay);
- throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
- } else if(DEBUG) {
- System.err.println("Chosen eglConfig: "+eglConfig);
+ setRealized(true);
+
+ if (DEBUG) {
+ System.out.println("Created pbuffer: " + this);
}
- return eglConfig;
+
}
protected long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle) {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat);
long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0);
if (EGL.EGL_NO_SURFACE==surf) {
throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+nw.getWidth()+"x"+nw.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError()));
} else if(DEBUG) {
- System.err.println("setSurface result: eglSurface 0x"+Long.toHexString(surf));
+ System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf));
}
- nw.setSurfaceHandle(surf);
+ ((SurfaceChangeable)nw).setSurfaceHandle(surf);
return surf;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index ee1ba732d..f8c15b7f2 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -69,40 +69,23 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
return new MacOSXOnscreenCGLDrawable(this, target);
}
- public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(false);
- return new MacOSXOffscreenCGLDrawable(this, aScreen, capabilities, chooser, width, height);
+ protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
+ return new MacOSXOffscreenCGLDrawable(this, target);
}
public boolean canCreateGLPbuffer() {
return true;
}
- public GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight) {
+ protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) {
+ return new MacOSXPbufferCGLDrawable(this, target);
+ }
+
+ protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(true);
- return new MacOSXPbufferCGLDrawable(this, screen, capabilities, chooser,
- initialWidth, initialHeight);
- }
-
- public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight,
- final GLContext shareWith) {
- GLDrawableImpl drawable = createGLPbufferDrawable( capabilities, chooser, initialWidth, initialHeight);
- return new GLPbufferImpl(drawable, shareWith);
+ NullWindow nw = new NullWindow(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen, true));
+ nw.setSize(width, height);
+ return nw;
}
public GLContext createExternalGLContext() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
index 3ff1c0a91..3448b008a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
@@ -46,12 +46,8 @@ import com.sun.opengl.impl.*;
public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable {
public MacOSXOffscreenCGLDrawable(GLDrawableFactory factory,
- AbstractGraphicsScreen absScreen,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- super(factory, absScreen, capabilities, chooser, width, height);
+ NativeWindow target) {
+ super(factory, target);
}
public GLContext createContext(GLContext shareWith) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index 9b6d8267d..c90e5d6bd 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -42,7 +42,6 @@ package com.sun.opengl.impl.macosx.cgl;
import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.sun.opengl.impl.*;
-import com.sun.nativewindow.impl.NullWindow;
public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
private static final boolean DEBUG = Debug.debug("MacOSXPbufferCGLDrawable");
@@ -57,16 +56,19 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
// semantic is that contains an NSView
protected long pBuffer;
- public MacOSXPbufferCGLDrawable(GLDrawableFactory factory,
- AbstractGraphicsScreen absScreen,
- GLCapabilities caps,
- GLCapabilitiesChooser chooser,
- int width, int height) {
- super(factory, new NullWindow(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, absScreen, true)), true);
- NullWindow nw = (NullWindow) getNativeWindow();
- nw.setSize(width, height);
+ public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeWindow target) {
+ super(factory, target, true);
+
+ if (DEBUG) {
+ System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
+ }
+
initOpenGLImpl();
createPbuffer();
+
+ if (DEBUG) {
+ System.err.println("Created pbuffer " + this);
+ }
}
public GLContext createContext(GLContext shareWith) {
@@ -94,7 +96,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
private void createPbuffer() {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
@@ -104,7 +106,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
} else {
int w = getNextPowerOf2(getWidth());
int h = getNextPowerOf2(getHeight());
- nw.setSize(w, h);
+ ((SurfaceChangeable)nw).setSize(w, h);
renderTarget = GL.GL_TEXTURE_2D;
}
@@ -134,10 +136,9 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
if (pBuffer == 0) {
throw new GLException("pbuffer creation error: CGL.createPBuffer() failed");
}
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + nw + " for " + this);
- }
+
+ ((SurfaceChangeable)nw).setSurfaceHandle(pBuffer);
+
}
private int getNextPowerOf2(int number) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index a3e5f6da4..35fbcc6f5 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -48,14 +48,8 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private long origbitmap;
private long hbitmap;
- public WindowsOffscreenWGLDrawable(GLDrawableFactory factory,
- AbstractGraphicsScreen absScreen,
- GLCapabilities requestedCapabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(requestedCapabilities, chooser, absScreen)), true);
- ((NullWindow) getNativeWindow()).setSize(width, height);
+ public WindowsOffscreenWGLDrawable(GLDrawableFactory factory, NativeWindow target) {
+ super(factory, target, true);
create();
}
@@ -94,7 +88,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
System.out.println("LastError: " + WGL.GetLastError());
throw new GLException("Error creating device context for offscreen OpenGL context");
}
- nw.setSurfaceHandle(hdc);
+ ((SurfaceChangeable)nw).setSurfaceHandle(hdc);
hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, 0, 0, 0);
if (hbitmap == 0) {
@@ -115,7 +109,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
}
public void destroy() {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
if (nw.getSurfaceHandle() != 0) {
// Must destroy bitmap and device context
WGL.SelectObject(nw.getSurfaceHandle(), origbitmap);
@@ -123,7 +117,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
WGL.DeleteDC(nw.getSurfaceHandle());
origbitmap = 0;
hbitmap = 0;
- nw.setSurfaceHandle(0);
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index 41a4e3877..798eafad3 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -42,7 +42,6 @@ package com.sun.opengl.impl.windows.wgl;
import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.sun.opengl.impl.*;
-import com.sun.nativewindow.impl.NullWindow;
public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private long cachedParentHdc;
@@ -52,28 +51,20 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private int floatMode;
- public WindowsPbufferWGLDrawable(GLDrawableFactory factory,
- AbstractGraphicsScreen absScreen,
- GLCapabilities requestedCapabilities,
- final GLCapabilitiesChooser chooser,
- int width,
- int height,
+ public WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeWindow target,
WindowsWGLDrawable dummyDrawable,
WGLExt wglExt) {
- super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
- requestedCapabilities, chooser, absScreen) ), true);
- if (width <= 0 || height <= 0) {
- throw new GLException("Width and height of pbuffer must be positive (were (" +
- width + ", " + height + "))");
- }
- NullWindow nw = (NullWindow) getNativeWindow();
- nw.setSize(width, height);
+ super(factory, target, true);
if (DEBUG) {
- System.out.println("Pbuffer caps: " + requestedCapabilities);
+ System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
createPbuffer(dummyDrawable.getNativeWindow().getSurfaceHandle(), wglExt);
+
+ if (DEBUG) {
+ System.err.println("Created pbuffer " + this);
+ }
}
public GLContext createContext(GLContext shareWith) {
@@ -81,7 +72,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
public void destroy() {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
if (nw.getSurfaceHandle() != 0) {
// Must release DC and pbuffer
// NOTE that since the context is not current, glGetError() can
@@ -91,7 +82,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (wglExt.wglReleasePbufferDCARB(buffer, nw.getSurfaceHandle()) == 0) {
throw new GLException("Error releasing pbuffer device context: error code " + WGL.GetLastError());
}
- nw.setSurfaceHandle(0);
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
if (!wglExt.wglDestroyPbufferARB(buffer)) {
throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError());
}
@@ -261,10 +252,10 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
throw new GLException("pbuffer creation error: wglGetPbufferDC() failed");
}
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
// Set up instance variables
buffer = tmpBuffer;
- nw.setSurfaceHandle(tmpHdc);
+ ((SurfaceChangeable)nw).setSurfaceHandle(tmpHdc);
cachedWGLExt = wglExt;
cachedParentHdc = parentHdc;
@@ -320,11 +311,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
width = tmp[0];
wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 );
height = tmp[0];
- nw.setSize(width, height);
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + width + " x " + height);
- }
+ ((SurfaceChangeable)nw).setSize(width, height);
}
private static String wglGetLastError() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 9137e4c7b..af65861b9 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -46,6 +46,7 @@ import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.NWReflection;
import com.sun.gluegen.runtime.DynamicLookupHelper;
+import com.sun.nativewindow.impl.NullWindow;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
private static final boolean VERBOSE = Debug.verbose();
@@ -78,15 +79,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return new WindowsOnscreenWGLDrawable(this, target);
}
- public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(false);
- return new WindowsOffscreenWGLDrawable(this, aScreen, capabilities, chooser, width, height);
+ protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
+ return new WindowsOffscreenWGLDrawable(this, target);
}
private boolean pbufferSupportInitialized = false;
@@ -124,17 +118,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return canCreateGLPbuffer;
}
- public GLDrawableImpl createGLPbufferDrawable(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight) {
- if (!canCreateGLPbuffer()) {
- throw new GLException("Pbuffer support not available with current graphics card");
- }
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(true);
- final GLCapabilities caps = capabilities;
+ protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
final List returnList = new ArrayList();
final GLDrawableFactory factory = this;
Runnable r = new Runnable() {
@@ -148,10 +132,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
dummyContext.makeCurrent();
WGLExt dummyWGLExt = dummyContext.getWGLExt();
try {
- AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(factory, aScreen, caps, chooser,
- initialWidth,
- initialHeight,
+ GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(factory, target,
dummyDrawable,
dummyWGLExt);
returnList.add(pbufferDrawable);
@@ -169,16 +150,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return (GLDrawableImpl) returnList.get(0);
}
- public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight,
- final GLContext shareWith) {
- GLDrawableImpl pbufferDrawable = createGLPbufferDrawable(
- capabilities, chooser, initialWidth, initialHeight);
- return new GLPbufferImpl(pbufferDrawable, shareWith);
+ protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
+ NullWindow nw = new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
+ capabilities, chooser, screen) );
+ nw.setSize(width, height);
+ return nw;
}
-
+
public GLContext createExternalGLContext() {
return WindowsExternalWGLContext.create(this, null);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index f278d76d0..f6c911c63 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -72,15 +72,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return new X11OnscreenGLXDrawable(this, target);
}
- public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(false);
- return new X11OffscreenGLXDrawable(this, screen, capabilities, chooser, width, height);
+ protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
+ return new X11OffscreenGLXDrawable(this, target);
}
private boolean pbufferSupportInitialized = false;
@@ -117,29 +110,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return canCreateGLPbuffer;
}
- public GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight) {
- if (!canCreateGLPbuffer()) {
- throw new GLException("Pbuffer support not available with current graphics card");
- }
-
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(true);
- AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
- return new X11PbufferGLXDrawable(this, screen, capabilities, chooser,
- initialWidth, initialHeight);
+ protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) {
+ return new X11PbufferGLXDrawable(this, target);
}
- public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight,
- final GLContext shareWith) {
- GLDrawableImpl drawable = createGLPbufferDrawable(capabilities, chooser, initialWidth, initialHeight);
- return new GLPbufferImpl(drawable, shareWith);
+ protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
+ NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen));
+ nw.setSize(width, height);
+ return nw;
}
public GLContext createExternalGLContext() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index 4c4546854..98eca44d9 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -42,19 +42,13 @@ package com.sun.opengl.impl.x11.glx;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
-import com.sun.nativewindow.impl.NullWindow;
import com.sun.nativewindow.impl.x11.*;
public class X11OffscreenGLXDrawable extends X11GLXDrawable {
private long pixmap;
- protected X11OffscreenGLXDrawable(GLDrawableFactory factory, AbstractGraphicsScreen screen,
- GLCapabilities caps,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen)), true);
- ((NullWindow) getNativeWindow()).setSize(width, height);
+ protected X11OffscreenGLXDrawable(GLDrawableFactory factory, NativeWindow target) {
+ super(factory, target, true);
create();
}
@@ -63,7 +57,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
}
private void create() {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
XVisualInfo vis = config.getXVisualInfo();
int bitsPerPixel = vis.depth();
@@ -85,7 +79,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
pixmap = 0;
throw new GLException("glXCreateGLXPixmap failed");
}
- nw.setSurfaceHandle(drawable);
+ ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
if (DEBUG) {
System.err.println("Created pixmap " + toHexString(pixmap) +
", GLXPixmap " + toHexString(drawable) +
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index 0f758a2f7..ddb96ae6b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -43,27 +43,24 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.sun.opengl.impl.*;
import com.sun.opengl.impl.x11.glx.*;
-import com.sun.nativewindow.impl.NullWindow;
import com.sun.nativewindow.impl.x11.*;
public class X11PbufferGLXDrawable extends X11GLXDrawable {
- protected X11PbufferGLXDrawable(GLDrawableFactory factory, AbstractGraphicsScreen screen,
- GLCapabilities caps,
+ protected X11PbufferGLXDrawable(GLDrawableFactory factory, NativeWindow target) {
+ /* GLCapabilities caps,
GLCapabilitiesChooser chooser,
- int width, int height) {
- super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen)), true);
- if (width <= 0 || height <= 0) {
- throw new GLException("Width and height of pbuffer must be positive (were (" +
- width + ", " + height + "))");
- }
- NullWindow nw = (NullWindow) getNativeWindow();
- nw.setSize(width, height);
+ int width, int height */
+ super(factory, target, true);
if (DEBUG) {
- System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
+ System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
createPbuffer();
+
+ if (DEBUG) {
+ System.err.println("Created pbuffer " + this);
+ }
}
public GLContext createContext(GLContext shareWith) {
@@ -73,7 +70,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
public void destroy() {
getFactoryImpl().lockToolkit();
try {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
if (nw.getSurfaceHandle() != 0) {
GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
}
@@ -96,7 +93,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
throw new GLException("Null display");
}
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
@@ -118,26 +115,22 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
iattributes[niattribs++] = nw.getHeight();
iattributes[niattribs++] = 0;
- long drawable = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0);
- if (drawable == 0) {
+ long pbuffer = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0);
+ if (pbuffer == 0) {
// FIXME: query X error code for detail error message
throw new GLException("pbuffer creation error: glXCreatePbuffer() failed");
}
// Set up instance variables
- nw.setSurfaceHandle(drawable);
+ ((SurfaceChangeable)nw).setSurfaceHandle(pbuffer);
// Determine the actual width and height we were able to create.
int[] tmp = new int[1];
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, tmp, 0);
+ GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_WIDTH, tmp, 0);
int width = tmp[0];
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, tmp, 0);
+ GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0);
int height = tmp[0];
- nw.setSize(width, height);
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + width + " x " + height);
- }
+ ((SurfaceChangeable)nw).setSize(width, height);
} finally {
getFactoryImpl().unlockToolkit();
}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index aade017eb..b7c81cbed 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -177,28 +177,23 @@ public abstract class GLDrawableFactory {
public void shutdown() {
}
+ //----------------------------------------------------------------------
+ // Methods to create high-level objects
+
/**
- * Returns a GLDrawable according to it's chosen Capabilities.
+ * Returns a GLDrawable according to it's chosen Capabilities,<br>
+ * which determines pixel format, on- and offscreen incl. PBuffer type.
* <p>
- * The chosen Capabilties are referenced within the target
+ * The native platform's chosen Capabilties are referenced within the target
* NativeWindow's AbstractGraphicsConfiguration.<p>
*
* In case {@link javax.media.nativewindow.Capabilties#isOnscreen()} is true,<br>
- * it wraps a platform-specific window system
- * object, such as an AWT or LCDUI Canvas.
- * On platforms which support pixel format, the NativeWindow's AbstractGraphicsConfiguration
- * is being used, hence the <code>chooser</code> is redundant in this case.
+ * an onscreen GLDrawable will be realized.
* <p>
* In case {@link javax.media.nativewindow.Capabilties#isOnscreen()} is false,<br>
* either a Pbuffer drawable is created if {@link javax.media.opengl.GLCapabilities#isPBuffer()} is true,<br>
- * or a simple offscreen drawable is creates, the latter is unlikely to be hardware accelerated.<br>
- * The <code>chooser</code> will be used to determine the pixel format.
+ * or a simple offscreen drawable is creates. The latter is unlikely to be hardware accelerated.<br>
* <p>
- * GLCapabilities, or if the passed GLCapabilities object is null,
- * uses a default set of capabilities. On these platforms, uses
- * either the supplied GLCapabilitiesChooser object, or if the
- * passed GLCapabilitiesChooser object is null, uses a
- * DefaultGLCapabilitiesChooser instance.
*
* @throws IllegalArgumentException if the passed target is null
* @throws GLException if any window system-specific errors caused
@@ -206,17 +201,19 @@ public abstract class GLDrawableFactory {
*
* @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
- public abstract GLDrawable createGLDrawable(NativeWindow target, GLCapabilitiesChooser chooser)
+ public abstract GLDrawable createGLDrawable(NativeWindow target)
throws IllegalArgumentException, GLException;
- /**
- * @see #createGLDrawable(NativeWindow, GLCapabilitiesChooser)
+ /**
+ * Creates a Offscreen GLDrawable with the given capabilites and dimensions. <P>
+ *
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the Offscreen to fail.
*/
- public abstract GLDrawable createGLDrawable(NativeWindow target)
- throws IllegalArgumentException, GLException;
-
- //----------------------------------------------------------------------
- // Methods to create high-level objects
+ public abstract GLDrawable createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ int width, int height)
+ throws GLException;
/**
* Returns true if it is possible to create a GLPbuffer. Some older
@@ -225,19 +222,15 @@ public abstract class GLDrawableFactory {
public abstract boolean canCreateGLPbuffer();
/**
- * Creates a GLPbuffer with the given drawable, which must be Pbuffer drawable,
- * created by {@link #createGLDrawable}.<p>
- *
- * See the note in the overview documentation on
- * <a href="../../../overview-summary.html#SHARING">context sharing</a>.
+ * Creates a Pbuffer GLDrawable with the given capabilites and dimensions. <P>
*
* @throws GLException if any window system-specific errors caused
* the creation of the GLPbuffer to fail.
- *
- * @see #createGLDrawable(NativeWindow, GLCapabilitiesChooser)
*/
- public abstract GLPbuffer createGLPbuffer(GLDrawable pbufferDrawable,
- GLContext shareWith)
+ public abstract GLDrawable createGLPbufferDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ int initialWidth,
+ int initialHeight)
throws GLException;
/**
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index fe55b2dbd..e4758211e 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -909,10 +909,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
public void initialize() {
// Fall-through path: create an offscreen context instead
- offscreenDrawable = factory.createOffscreenDrawable(offscreenCaps,
- chooser,
- Math.max(1, panelWidth),
- Math.max(1, panelHeight));
+ offscreenDrawable = (GLDrawableImpl) factory.createOffscreenDrawable(
+ offscreenCaps,
+ chooser,
+ Math.max(1, panelWidth),
+ Math.max(1, panelHeight));
offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith);
offscreenContext.setSynchronized(true);
isInitialized = true;