From 76bf2e5a7f23def0a3bf2b688791b593ecb283ab Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 5 Oct 2009 02:54:59 -0700 Subject: 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. --- .../javax/media/opengl/GLDrawableFactory.java | 53 ++++++++++------------ .../classes/javax/media/opengl/awt/GLJPanel.java | 9 ++-- 2 files changed, 28 insertions(+), 34 deletions(-) (limited to 'src/jogl/classes/javax/media/opengl') 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,
+ * which determines pixel format, on- and offscreen incl. PBuffer type. *

- * The chosen Capabilties are referenced within the target + * The native platform's chosen Capabilties are referenced within the target * NativeWindow's AbstractGraphicsConfiguration.

* * In case {@link javax.media.nativewindow.Capabilties#isOnscreen()} is true,
- * 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 chooser is redundant in this case. + * an onscreen GLDrawable will be realized. *

* In case {@link javax.media.nativewindow.Capabilties#isOnscreen()} is false,
* either a Pbuffer drawable is created if {@link javax.media.opengl.GLCapabilities#isPBuffer()} is true,
- * or a simple offscreen drawable is creates, the latter is unlikely to be hardware accelerated.
- * The chooser will be used to determine the pixel format. + * or a simple offscreen drawable is creates. The latter is unlikely to be hardware accelerated.
*

- * 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.

+ * + * @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}.

- * - * See the note in the overview documentation on - * context sharing. + * Creates a Pbuffer GLDrawable with the given capabilites and dimensions.

* * @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; -- cgit v1.2.3