diff options
3 files changed, 60 insertions, 6 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java index a2d0e0150..9ea599b30 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java @@ -57,7 +57,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // Dispatching GLDrawable construction in respect to the NativeWindow Capabilities // - public GLDrawable createGLDrawable(NativeWindow target) { + public GLDrawable createGLDrawable(NativeWindow target, GLCapabilitiesChooser chooser) { if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -74,13 +74,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(caps.isPBuffer() && canCreateGLPbuffer()) { // PBUFFER result = createGLPbufferDrawable(caps, - null /* GLCapabilitiesChooser */, + chooser, target.getWidth(), target.getHeight()); } if(null==result) { result = createOffscreenDrawable(caps, - null /* GLCapabilitiesChooser */, + chooser, target.getWidth(), target.getHeight()); } @@ -91,6 +91,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return result; } + public GLDrawable createGLDrawable(NativeWindow target) { + return createGLDrawable(target, null); + } + /** Creates a (typically hw-accelerated) Pbuffer GLDrawable. */ public abstract GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities, GLCapabilitiesChooser chooser, @@ -108,6 +112,11 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { /** Creates a (typically hw-accelerated) onscreen GLDrawable. */ public abstract GLDrawableImpl createOnscreenDrawable(NativeWindow target); + public GLPbuffer createGLPbuffer(GLDrawable pbufferDrawable, + GLContext shareWith) { + return new GLPbufferImpl((GLDrawableImpl)pbufferDrawable, shareWith); + } + protected GLDrawableFactoryImpl() { super(); } diff --git a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java index 8aba26fc6..966b1e63e 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java @@ -62,6 +62,18 @@ public class GLPbufferImpl implements GLPbuffer { public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext parentContext) { + GLCapabilities caps = (GLCapabilities) + pbufferDrawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + if(caps.isOnscreen()) { + if(caps.isPBuffer()) { + throw new IllegalArgumentException("Error: Given drawable is Onscreen and Pbuffer: "+pbufferDrawable); + } + throw new IllegalArgumentException("Error: Given drawable is Onscreen: "+pbufferDrawable); + } else { + if(!caps.isPBuffer()) { + throw new IllegalArgumentException("Error: Given drawable is not Pbuffer: "+pbufferDrawable); + } + } this.pbufferDrawable = pbufferDrawable; context = (GLContextImpl) pbufferDrawable.createContext(parentContext); context.setSynchronized(true); diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 48a8fe9e0..aade017eb 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -178,11 +178,22 @@ public abstract class GLDrawableFactory { } /** - * Returns a GLDrawable that wraps a platform-specific window system + * Returns a GLDrawable according to it's chosen Capabilities. + * <p> + * The 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. - * support it, selects a pixel format compatible with the supplied + * is being used, hence the <code>chooser</code> is redundant in this case. + * <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. + * <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 @@ -195,6 +206,12 @@ public abstract class GLDrawableFactory { * * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ + public abstract GLDrawable createGLDrawable(NativeWindow target, GLCapabilitiesChooser chooser) + throws IllegalArgumentException, GLException; + + /** + * @see #createGLDrawable(NativeWindow, GLCapabilitiesChooser) + */ public abstract GLDrawable createGLDrawable(NativeWindow target) throws IllegalArgumentException, GLException; @@ -208,6 +225,22 @@ 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>. + * + * @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) + throws GLException; + + /** * Creates a GLPbuffer with the given capabilites and dimensions. <P> * * See the note in the overview documentation on |