diff options
author | Sven Gothel <[email protected]> | 2009-10-05 02:54:59 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-05 02:54:59 -0700 |
commit | 76bf2e5a7f23def0a3bf2b688791b593ecb283ab (patch) | |
tree | 84b7b2a25cc38450dc83a78d1f1ed165195a599e /src/jogl/classes/com/sun/opengl/impl/macosx/cgl | |
parent | 59257476777104ff3f117d87a8205161cb800abf (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/classes/com/sun/opengl/impl/macosx/cgl')
3 files changed, 28 insertions, 48 deletions
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) { |