diff options
author | Kenneth Russel <[email protected]> | 2005-07-18 23:15:37 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-18 23:15:37 +0000 |
commit | 35435c313ba527c9bea35a14f72492d2f80a9c84 (patch) | |
tree | ae7f1ed0a184d990292f0e295fa943c0139868a0 /src/net/java/games/jogl/impl | |
parent | 8f5492988de9fddf61623b7274915c777ad3a97d (diff) |
Moved pbuffer creation support from MacOSXOnscreenGLDrawable to
MacOSXGLContextFactory. This completes the transition from creating
pbuffers as a subordinate object of a GLCanvas to creating them as
standalone GLDrawables. Deleted code from GLAutoDrawable and all
implementations related to pbuffer instantiation.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@328 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl')
11 files changed, 64 insertions, 173 deletions
diff --git a/src/net/java/games/jogl/impl/GLContextImpl.java b/src/net/java/games/jogl/impl/GLContextImpl.java index fd164321f..6094d6795 100755 --- a/src/net/java/games/jogl/impl/GLContextImpl.java +++ b/src/net/java/games/jogl/impl/GLContextImpl.java @@ -145,22 +145,6 @@ public abstract class GLContextImpl extends GLContext { protected abstract GL createGL(); /** - * Pbuffer support; indicates whether this context is capable of - * creating a subordinate pbuffer context (distinct from an - * "offscreen context", which is typically software-rendered on all - * platforms). - */ - public abstract boolean canCreatePbufferContext(); - - /** - * Pbuffer support; creates a subordinate GLDrawable for a pbuffer - * associated with this context. - */ - public abstract GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight); - - /** * Pbuffer support; given that this is a GLContext associated with a * pbuffer, binds this pbuffer to its texture target. */ diff --git a/src/net/java/games/jogl/impl/GLPbufferImpl.java b/src/net/java/games/jogl/impl/GLPbufferImpl.java index 6e83f0d0e..7583abe89 100644 --- a/src/net/java/games/jogl/impl/GLPbufferImpl.java +++ b/src/net/java/games/jogl/impl/GLPbufferImpl.java @@ -135,16 +135,6 @@ public class GLPbufferImpl implements GLPbuffer { maybeDoSingleThreadedWorkaround(swapBuffersOnEventDispatchThreadAction, swapBuffersAction, false); } - public boolean canCreateOffscreenDrawable() { - return false; - } - - public GLPbuffer createOffscreenDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - throw new GLException("Not supported"); - } - public void bindTexture() { // Doesn't make much sense to try to do this on the event dispatch // thread given that it has to be called while the context is current diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java index cde1d54b1..f6b7cebf1 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java @@ -233,16 +233,6 @@ public abstract class MacOSXGLContext extends GLContextImpl throw new GLException("Should not call this"); } - public boolean canCreatePbufferContext() { - return false; - } - - public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - throw new GLException("Not supported"); - } - public void bindPbufferToTexture() { throw new GLException("Should not call this"); } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java index a3c502b7c..150468bfb 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java @@ -40,8 +40,12 @@ package net.java.games.jogl.impl.macosx; import java.awt.Component; +import java.awt.EventQueue; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import net.java.games.jogl.*; import net.java.games.jogl.impl.*; @@ -73,4 +77,42 @@ public class MacOSXGLContextFactory extends GLContextFactory { GLCapabilitiesChooser chooser) { return new MacOSXOffscreenGLDrawable(capabilities); } + + public boolean canCreateGLPbuffer(GLCapabilities capabilities, + int initialWidth, + int initialHeight) { + return true; + } + + public GLPbuffer createGLPbuffer(final GLCapabilities capabilities, + final int initialWidth, + final int initialHeight, + final GLContext shareWith) { + final List returnList = new ArrayList(); + Runnable r = new Runnable() { + public void run() { + MacOSXPbufferGLDrawable pbufferDrawable = new MacOSXPbufferGLDrawable(capabilities, + initialWidth, + initialHeight); + GLPbufferImpl pbuffer = new GLPbufferImpl(pbufferDrawable, shareWith); + returnList.add(pbuffer); + } + }; + maybeDoSingleThreadedWorkaround(r); + return (GLPbuffer) returnList.get(0); + } + + private void maybeDoSingleThreadedWorkaround(Runnable action) { + if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) { + try { + EventQueue.invokeAndWait(action); + } catch (InvocationTargetException e) { + throw new GLException(e.getTargetException()); + } catch (InterruptedException e) { + throw new GLException(e); + } + } else { + action.run(); + } + } } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLDrawable.java b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLDrawable.java index d7da03ec0..1118680ca 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLDrawable.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLDrawable.java @@ -56,8 +56,6 @@ public class MacOSXOffscreenGLDrawable extends MacOSXPbufferGLDrawable { destroy(); initWidth = width; initHeight = height; - // Floating-point frame buffers are never used with offscreen - // drawables (in GLJPanel) so don't need a GL object here - createPbuffer(null); + createPbuffer(); } } diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java index 6dd2c4b4a..6accb37c0 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java @@ -46,8 +46,6 @@ import net.java.games.jogl.impl.*; public class MacOSXOnscreenGLContext extends MacOSXGLContext { protected MacOSXOnscreenGLDrawable drawable; - // Variables for pbuffer support - List pbuffersToInstantiate = new ArrayList(); public MacOSXOnscreenGLContext(MacOSXOnscreenGLDrawable drawable, GLContext shareWith) { @@ -55,18 +53,6 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { this.drawable = drawable; } - public boolean canCreatePbufferContext() { - return true; - } - - public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - MacOSXPbufferGLDrawable buf = new MacOSXPbufferGLDrawable(capabilities, initialWidth, initialHeight); - pbuffersToInstantiate.add(buf); - return buf; - } - protected int makeCurrentImpl() throws GLException { try { int lockRes = drawable.lockSurface(); @@ -87,12 +73,6 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext { // of an ancestor, but this also wasn't sufficient and left garbage on the // screen in some situations. CGL.updateContext(nsContext, drawable.getView()); - // Instantiate any pending pbuffers - while (!pbuffersToInstantiate.isEmpty()) { - MacOSXPbufferGLDrawable buf = - (MacOSXPbufferGLDrawable) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1); - buf.createPbuffer(getGL()); - } } else { // View might not have been ready drawable.unlockSurface(); diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLDrawable.java b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLDrawable.java index fc5f3c22e..282d8a08b 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLDrawable.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLDrawable.java @@ -61,6 +61,8 @@ public class MacOSXPbufferGLDrawable extends MacOSXGLDrawable { super(capabilities, null); this.initWidth = initialWidth; this.initHeight = initialHeight; + + createPbuffer(); } public GLContext createContext(GLContext shareWith) { @@ -91,7 +93,19 @@ public class MacOSXPbufferGLDrawable extends MacOSXGLDrawable { return height; } - public void createPbuffer(GL gl) { + public GLCapabilities getCapabilities() { + return capabilities; + } + + public long getPbuffer() { + return pBuffer; + } + + public void swapBuffers() throws GLException { + // FIXME: do we need to do anything if the pbuffer is double-buffered? + } + + protected void createPbuffer() { int renderTarget; if (capabilities.getOffscreenRenderToTextureRectangle()) { width = initWidth; @@ -105,9 +119,15 @@ public class MacOSXPbufferGLDrawable extends MacOSXGLDrawable { int internalFormat = GL.GL_RGBA; if (capabilities.getOffscreenFloatingPointBuffers()) { + // FIXME: want to check availability of GL_APPLE_float_pixels + // extension, but need valid OpenGL context in order to do so -- + // in worst case would need to create dummy window / GLCanvas + // (undesirable) -- could maybe also do this with pbuffers + /* if (!gl.isExtensionAvailable("GL_APPLE_float_pixels")) { throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available"); } + */ switch (capabilities.getRedBits()) { case 16: internalFormat = GL.GL_RGBA_FLOAT16_APPLE; break; case 32: internalFormat = GL.GL_RGBA_FLOAT32_APPLE; break; @@ -125,18 +145,6 @@ public class MacOSXPbufferGLDrawable extends MacOSXGLDrawable { } } - public GLCapabilities getCapabilities() { - return capabilities; - } - - public long getPbuffer() { - return pBuffer; - } - - public void swapBuffers() throws GLException { - // FIXME: do we need to do anything if the pbuffer is double-buffered? - } - private int getNextPowerOf2(int number) { if (((number-1) & number) == 0) { //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0 diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index 64cb74868..1c0365571 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -56,7 +56,6 @@ public class WindowsGLContext extends GLContextImpl { private GLProcAddressTable glProcAddressTable; // Handle to GLU32.dll private long hglu32; - private boolean haveWGLARBPbuffer = true; static { functionNameMap = new HashMap(); @@ -159,8 +158,6 @@ public class WindowsGLContext extends GLContextImpl { if (created) { resetGLFunctionAvailability(); - haveWGLARBPbuffer = (isExtensionAvailable("WGL_ARB_pbuffer") && - isExtensionAvailable("WGL_ARB_pixel_format")); return CONTEXT_CURRENT_NEW; } return CONTEXT_CURRENT; @@ -263,16 +260,6 @@ public class WindowsGLContext extends GLContextImpl { throw new GLException("Should not call this"); } - public boolean canCreatePbufferContext() { - return false; - } - - public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - throw new GLException("Not supported"); - } - public void bindPbufferToTexture() { throw new GLException("Should not call this"); } @@ -288,8 +275,4 @@ public class WindowsGLContext extends GLContextImpl { protected long getHGLRC() { return hglrc; } - - protected boolean haveWGLARBPbuffer() { - return haveWGLARBPbuffer; - } } diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java index b3ed2a03c..18c98e3cc 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java @@ -46,8 +46,6 @@ import net.java.games.jogl.impl.*; public class WindowsOnscreenGLContext extends WindowsGLContext { protected WindowsOnscreenGLDrawable drawable; - // Variables for pbuffer support - protected List pbuffersToInstantiate = new ArrayList(); public WindowsOnscreenGLContext(WindowsOnscreenGLDrawable drawable, GLContext shareWith) { @@ -55,24 +53,6 @@ public class WindowsOnscreenGLContext extends WindowsGLContext { this.drawable = drawable; } - public boolean canCreatePbufferContext() { - return false; - /* - return haveWGLARBPbuffer(); - */ - } - - public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - throw new GLException("No longer supported"); - /* - WindowsPbufferGLDrawable buf = new WindowsPbufferGLDrawable(capabilities, initialWidth, initialHeight); - pbuffersToInstantiate.add(buf); - return buf; - */ - } - protected int makeCurrentImpl() throws GLException { try { int lockRes = drawable.lockSurface(); @@ -92,26 +72,6 @@ public class WindowsOnscreenGLContext extends WindowsGLContext { } } int ret = super.makeCurrentImpl(); - /* - if ((ret == CONTEXT_CURRENT) || - (ret == CONTEXT_CURRENT_NEW)) { - // Instantiate any pending pbuffers - // NOTE that we supply the drawable a GL instance for our - // context and that we eliminate all pipelines for it -- see - // WindowsPbufferGLDrawable.destroy() - if (!pbuffersToInstantiate.isEmpty()) { - GL tmpGL = createGL(); - while (!pbuffersToInstantiate.isEmpty()) { - WindowsPbufferGLDrawable buf = - (WindowsPbufferGLDrawable) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1); - buf.createPbuffer(tmpGL, drawable.getHDC()); - if (DEBUG) { - System.err.println(getThreadName() + ": created pbuffer " + buf); - } - } - } - } - */ return ret; } catch (RuntimeException e) { try { diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java index fd22d0ee5..dd6448265 100644 --- a/src/net/java/games/jogl/impl/x11/X11GLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11GLContext.java @@ -277,16 +277,6 @@ public abstract class X11GLContext extends GLContextImpl { throw new GLException("Should not call this"); } - public boolean canCreatePbufferContext() { - return false; - } - - public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - throw new GLException("Not supported"); - } - public void bindPbufferToTexture() { throw new GLException("Should not call this"); } diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java index cc4375117..952bb9f4f 100644 --- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java @@ -46,8 +46,6 @@ import net.java.games.jogl.impl.*; public class X11OnscreenGLContext extends X11GLContext { protected X11OnscreenGLDrawable drawable; - // Variables for pbuffer support - List pbuffersToInstantiate = new ArrayList(); public X11OnscreenGLContext(X11OnscreenGLDrawable drawable, GLContext shareWith) { @@ -55,24 +53,6 @@ public class X11OnscreenGLContext extends X11GLContext { this.drawable = drawable; } - public boolean canCreatePbufferContext() { - return false; - /* - return isExtensionAvailable("GL_ARB_pbuffer"); - */ - } - - public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities, - int initialWidth, - int initialHeight) { - throw new GLException("No longer supported"); - /* - X11PbufferGLDrawable buf = new X11PbufferGLDrawable(capabilities, initialWidth, initialHeight); - pbuffersToInstantiate.add(buf); - return buf; - */ - } - protected int makeCurrentImpl() throws GLException { try { int lockRes = drawable.lockSurface(); @@ -90,20 +70,6 @@ public class X11OnscreenGLContext extends X11GLContext { } } int ret = super.makeCurrentImpl(); - /* - if ((ret == CONTEXT_CURRENT) || - (ret == CONTEXT_CURRENT_NEW)) { - // Instantiate any pending pbuffers - while (!pbuffersToInstantiate.isEmpty()) { - X11PbufferGLDrawable buf = - (X11PbufferGLDrawable) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1); - buf.createPbuffer(getGL(), drawable.getDisplay()); - if (DEBUG) { - System.err.println(getThreadName() + ": created pbuffer " + buf); - } - } - } - */ return ret; } catch (RuntimeException e) { try { |