diff options
author | sg215889 <[email protected]> | 2009-07-24 07:29:28 -0700 |
---|---|---|
committer | sg215889 <[email protected]> | 2009-07-24 07:29:28 -0700 |
commit | 0906140a18690a9dced8dec12dfdd8cf4c95a4df (patch) | |
tree | 52f67514b575a61aeba975fad00fd5ab60a52435 /src/jogl/classes/com/sun/opengl/impl/x11/glx | |
parent | 1f65dedf406455731fb682404a01c96aa85d5ae1 (diff) |
Add: Extended support for CVM crosscompile:
- Clean up X11 dependency
- NativeWindow:
- Seperate X11 out of core.
- Add nativewindow.x11.jar and nativewindow.x11.cdc.jar
- Newt:
- Seperate X11,win,osx out of core.
- Add newt.x11.jar, newt.win.jar, newt.osx.jar and the CDC variants
Fix: External Context & Drawable (X11 and Windows)
- Properly fetch current context values (ctx, display, drawable, ..)
- Create GraphicsConfiguration based on the given pixelformat/FBConfig
Fix: Java2D OpenGL Usage
- Using the external context as shared for the external drawable
- JAWTUtil: Skip locking in case of OGL-Flush-Queue
- TODO: Windows FBO still does not work .. (X11 is fine)
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/impl/x11/glx')
11 files changed, 282 insertions, 364 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java index 6491c33da..0603f1cf0 100755 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java @@ -40,6 +40,7 @@ package com.sun.opengl.impl.x11.glx; import javax.media.nativewindow.*; +import javax.media.nativewindow.x11.*; import javax.media.opengl.*; import com.sun.opengl.impl.*; import com.sun.nativewindow.impl.NullWindow; @@ -50,21 +51,42 @@ public class X11ExternalGLXContext extends X11GLXContext { private boolean created = true; private GLContext lastContext; - public X11ExternalGLXContext(AbstractGraphicsScreen screen) { - super(null, null); - getDrawableImpl().getFactoryImpl().lockToolkit(); + private X11ExternalGLXContext(Drawable drawable, long context) { + super(drawable, null); + this.drawable = drawable; + this.context = context; + GLContextShareSet.contextCreated(this); + setGLFunctionAvailability(false); + } + + protected static X11ExternalGLXContext create(GLDrawableFactory factory, GLProfile glp) { + ((GLDrawableFactoryImpl)factory).lockToolkit(); try { - context = GLX.glXGetCurrentContext(); - if (context == 0) { - throw new GLException("Error: attempted to make an external GLContext without a drawable/context current"); - } - NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(screen, false)); - drawable = new Drawable(getGLDrawable().getFactory(), nw); + long context = GLX.glXGetCurrentContext(); + if (context == 0) { + throw new GLException("Error: current context null"); + } + long display = GLX.glXGetCurrentDisplay(); + if (display == 0) { + throw new GLException("Error: current display null"); + } + long drawable = GLX.glXGetCurrentDrawable(); + if (drawable == 0) { + throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current"); + } + int[] val = new int[1]; + GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0); + X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]); + + GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0); + X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); + + NullWindow nw = new NullWindow(cfg); + nw.setSurfaceHandle(drawable); + return new X11ExternalGLXContext(new Drawable(factory, nw), context); } finally { - getDrawableImpl().getFactoryImpl().unlockToolkit(); + ((GLDrawableFactoryImpl)factory).unlockToolkit(); } - GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false); } protected void create() { @@ -108,7 +130,7 @@ public class X11ExternalGLXContext extends X11GLXContext { } // Need to provide the display connection to extension querying APIs - class Drawable extends X11GLXDrawable { + static class Drawable extends X11GLXDrawable { Drawable(GLDrawableFactory factory, NativeWindow comp) { super(factory, comp, true); } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java index 9a5e42382..75a6b221a 100755 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java @@ -40,6 +40,7 @@ package com.sun.opengl.impl.x11.glx; import javax.media.nativewindow.*; +import javax.media.nativewindow.x11.*; import javax.media.opengl.*; import com.sun.opengl.impl.*; import com.sun.nativewindow.impl.NullWindow; @@ -50,54 +51,58 @@ import com.sun.gluegen.runtime.PointerBuffer; public class X11ExternalGLXDrawable extends X11GLXDrawable { private int fbConfigID; private int renderType; - private long readDrawable; - private X11ExternalGLXDrawable(GLDrawableFactory factory, NativeWindow component) { + private X11ExternalGLXDrawable(GLDrawableFactory factory, NativeWindow component, int renderType) { super(factory, component, true); - readDrawable = GLX.glXGetCurrentReadDrawable(); + this.renderType = renderType; // Need GLXFBConfig ID in order to properly create new contexts // on this drawable - long display = getNativeWindow().getDisplayHandle(); - long context = GLX.glXGetCurrentContext(); - int[] val = new int[1]; - GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0); - fbConfigID = val[0]; - renderType = GLX.GLX_RGBA_TYPE; - GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0); - if ((val[0] & GLX.GLX_RGBA_BIT) == 0) { - if (DEBUG) { - System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts"); - } - } + X11GLXGraphicsConfiguration cfg = (X11GLXGraphicsConfiguration) component.getGraphicsConfiguration(); + fbConfigID = cfg.getFBConfigID(); } - protected static X11ExternalGLXDrawable create(GLDrawableFactory factory, AbstractGraphicsScreen aScreen) { - ((GLDrawableFactoryImpl) factory).lockToolkit(); + protected static X11ExternalGLXDrawable create(GLDrawableFactory factory, GLProfile glp) { + ((GLDrawableFactoryImpl)factory).lockToolkit(); try { - long display = GLX.glXGetCurrentDisplay(); - long context = GLX.glXGetCurrentContext(); - int[] val = new int[1]; - GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0); - int screen = val[0]; - long drawable = GLX.glXGetCurrentDrawable(); - if (drawable == 0) { - throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current"); - } - - if(screen!=aScreen.getIndex()) { - throw new GLException("Error: Passed AbstractGraphicsScreen's index is not current: "+aScreen+", GLX-screen "+screen); - } - if(display!=aScreen.getDevice().getHandle()) { - throw new GLException("Error: Passed AbstractGraphicsScreen's display is not current: "+aScreen+", GLX-display 0x"+Long.toHexString(display)); - } - - NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(aScreen, false)); - nw.setSurfaceHandle(drawable); - return new X11ExternalGLXDrawable(factory, nw); + long context = GLX.glXGetCurrentContext(); + if (context == 0) { + throw new GLException("Error: current context null"); + } + long display = GLX.glXGetCurrentDisplay(); + if (display == 0) { + throw new GLException("Error: current display null"); + } + long drawable = GLX.glXGetCurrentDrawable(); + if (drawable == 0) { + throw new GLException("Error: attempted to make an external GLDrawable without a drawable current"); + } + int[] val = new int[1]; + GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0); + X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]); + + GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0); + X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); + + int w, h; + GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0); + w=val[0]; + GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0); + h=val[0]; + + GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0); + if ((val[0] & GLX.GLX_RGBA_TYPE) == 0) { + if (DEBUG) { + System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")"); + } + } + NullWindow nw = new NullWindow(cfg); + nw.setSurfaceHandle(drawable); + nw.setSize(w, h); + return new X11ExternalGLXDrawable(factory, nw, GLX.GLX_RGBA_TYPE); } finally { - ((GLDrawableFactoryImpl) factory).unlockToolkit(); + ((GLDrawableFactoryImpl)factory).unlockToolkit(); } } @@ -110,11 +115,11 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { } public int getWidth() { - throw new GLException("Should not call this"); + return getNativeWindow().getWidth(); } public int getHeight() { - throw new GLException("Should not call this"); + return getNativeWindow().getHeight(); } class Context extends X11GLXContext { @@ -122,113 +127,8 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { super(drawable, shareWith); } - protected int makeCurrentImpl() throws GLException { - if (drawable.getNativeWindow().getSurfaceHandle() == 0) { - // parent drawable not properly initialized - // FIXME: signal error? - if (DEBUG) { - System.err.println("parent drawable not properly initialized"); - } - return CONTEXT_NOT_CURRENT; - } - - // Note that we have to completely override makeCurrentImpl - // because the underlying makeCurrent call differs from the norm - getFactoryImpl().lockToolkit(); - try { - boolean created = false; - if (context == 0) { - create(); - if (DEBUG) { - System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName()); - } - created = true; - } - - if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), - drawable.getNativeWindow().getSurfaceHandle(), - readDrawable, - context)) { - throw new GLException("Error making context current"); - } else { - if (DEBUG && VERBOSE) { - System.err.println(getThreadName() + ": glXMakeCurrent(display " + toHexString(drawable.getNativeWindow().getDisplayHandle()) + - ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + - ", context " + toHexString(context) + ") succeeded"); - } - } - - if (created) { - setGLFunctionAvailability(false); - return CONTEXT_CURRENT_NEW; - } - return CONTEXT_CURRENT; - } finally { - getFactoryImpl().unlockToolkit(); - } - } - - protected void releaseImpl() throws GLException { - getFactoryImpl().lockToolkit(); - try { - if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) { - throw new GLException("Error freeing OpenGL context"); - } - } finally { - getFactoryImpl().unlockToolkit(); - } - } - protected void create() { - long display = getNativeWindow().getDisplayHandle(); - int screen = getNativeWindow().getScreenIndex(); - // We already have the GLXFBConfig ID for the context. All we - // need to do is use it to choose the GLXFBConfig and then - // create a context with it. - int[] iattributes = new int[] { - GLX.GLX_FBCONFIG_ID, - fbConfigID, - 0, - 0 - }; - float[] fattributes = new float[0]; - int[] nelementsTmp = new int[1]; - PointerBuffer fbConfigs = GLX.glXChooseFBConfigCopied(display, screen, iattributes, 0, nelementsTmp, 0); - int nelements = nelementsTmp[0]; - if (nelements <= 0) { - throw new GLException("context creation error: couldn't find a suitable frame buffer configuration"); - } - if (nelements != 1) { - throw new GLException("context creation error: shouldn't get more than one GLXFBConfig"); - } - // Note that we currently don't allow selection of anything but - // the first GLXFBConfig in the returned list (there should be only one) - long fbConfig = fbConfigs.get(0); - // Create a gl context for the drawable - X11GLXContext other = (X11GLXContext) GLContextShareSet.getShareContext(this); - long share = 0; - if (other != null) { - share = other.getContext(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - } - // FIXME: how to determine "direct" bit? - context = GLX.glXCreateNewContext(display, fbConfig, renderType, share, true); - if (context == 0) { - String detail = " display=" + toHexString(display) + - " fbconfig=" + fbConfig + - " fbconfigID=" + toHexString(fbConfigID) + - " renderType=" + toHexString(renderType) + - " share=" + toHexString(share); - throw new GLException("context creation error: glXCreateNewContext() failed: " + detail); - } - GLContextShareSet.contextCreated(this); - - if (DEBUG) { - System.err.println("Created context " + toHexString(context) + - " for GLXDrawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle())); - } + createContext(true); } } } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java index 7029b81b0..57abcf588 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java @@ -117,8 +117,15 @@ public abstract class X11GLXContext extends GLContextImpl { /** * Creates and initializes an appropriate OpenGL context. Should only be * called by {@link create()}. + * Note: The direct parameter may be overwritten by the direct state of a shared context. */ - protected void createContext(boolean onscreen) { + protected void createContext(boolean direct) { + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + if(DEBUG) { + System.err.println("X11GLXContext.createContext got "+config); + } + long display = config.getScreen().getDevice().getHandle(); + X11GLXContext other = (X11GLXContext) GLContextShareSet.getShareContext(this); long share = 0; if (other != null) { @@ -126,14 +133,10 @@ public abstract class X11GLXContext extends GLContextImpl { if (share == 0) { throw new GLException("GLContextShareSet returned an invalid OpenGL context"); } + direct = GLX.glXIsDirect(display, share); } - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - if(DEBUG) { - System.err.println("X11GLXContext.createContext got "+config); - } GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities(); - long display = config.getScreen().getDevice().getHandle(); isVendorATI = GLXUtil.isVendorATI(display); if(config.getFBConfigID()<0) { @@ -141,7 +144,7 @@ public abstract class X11GLXContext extends GLContextImpl { if(glCaps.getGLProfile().isGL3()) { throw new GLException("Unable to create OpenGL 3.1 context"); } - context = GLX.glXCreateContext(display, config.getXVisualInfo(), share, onscreen); + context = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct); if (context == 0) { throw new GLException("Unable to create OpenGL context"); } @@ -160,7 +163,7 @@ public abstract class X11GLXContext extends GLContextImpl { // To use GLX_ARB_create_context, we have to make a temp context current, // so we are able to use GetProcAddress - long temp_context = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, onscreen); + long temp_context = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, direct); if (temp_context == 0) { throw new GLException("Unable to create temp OpenGL context"); } else { @@ -205,7 +208,7 @@ public abstract class X11GLXContext extends GLContextImpl { attribs[5] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /* | GLX.GLX_CONTEXT_DEBUG_BIT_ARB */; } - context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, onscreen, attribs, 0); + context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0); if(0==context) { if(glCaps.getGLProfile().isGL3()) { if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) { @@ -245,41 +248,46 @@ public abstract class X11GLXContext extends GLContextImpl { } protected int makeCurrentImpl() throws GLException { - if (drawable.getNativeWindow().getSurfaceHandle() == 0) { - if (DEBUG) { - System.err.println("drawable not properly initialized"); + getDrawableImpl().getFactoryImpl().lockToolkit(); + try { + if (drawable.getNativeWindow().getSurfaceHandle() == 0) { + if (DEBUG) { + System.err.println("drawable not properly initialized"); + } + return CONTEXT_NOT_CURRENT; } - return CONTEXT_NOT_CURRENT; - } - boolean created = false; - if (context == 0) { - create(); - if (DEBUG) { - System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName()); - } - created = true; - } - - if (GLX.glXGetCurrentContext() != context) { - if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), - drawable.getNativeWindow().getSurfaceHandle(), - drawable.getNativeWindow().getSurfaceHandle(), - context)) { - throw new GLException("Error making context current"); + boolean created = false; + if (context == 0) { + create(); + if (DEBUG) { + System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName()); + } + created = true; } - if (DEBUG && (VERBOSE || created)) { - System.err.println(getThreadName() + ": glXMakeCurrent(display " + - toHexString(drawable.getNativeWindow().getDisplayHandle()) + - ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + - ", context " + toHexString(context) + ") succeeded"); + + if (GLX.glXGetCurrentContext() != context) { + if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), + drawable.getNativeWindow().getSurfaceHandle(), + drawable.getNativeWindow().getSurfaceHandle(), + context)) { + throw new GLException("Error making context current"); + } + if (DEBUG && (VERBOSE || created)) { + System.err.println(getThreadName() + ": glXMakeCurrent(display " + + toHexString(drawable.getNativeWindow().getDisplayHandle()) + + ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + + ", context " + toHexString(context) + ") succeeded"); + } } - } - if (created) { - setGLFunctionAvailability(false); - return CONTEXT_CURRENT_NEW; + if (created) { + setGLFunctionAvailability(false); + return CONTEXT_CURRENT_NEW; + } + return CONTEXT_CURRENT; + } finally { + getDrawableImpl().getFactoryImpl().unlockToolkit(); } - return CONTEXT_CURRENT; } protected void releaseImpl() throws GLException { @@ -386,14 +394,23 @@ public abstract class X11GLXContext extends GLContextImpl { } + private int hasSwapIntervalSGI = 0; + public void setSwapInterval(int interval) { getDrawableImpl().getFactoryImpl().lockToolkit(); try { // FIXME: make the context current first? Currently assumes that // will not be necessary. Make the caller do this? GLXExt glXExt = getGLXExt(); - if (glXExt.isExtensionAvailable("GLX_SGI_swap_control")) { - glXExt.glXSwapIntervalSGI(interval); + if(0==hasSwapIntervalSGI) { + try { + hasSwapIntervalSGI = glXExt.isExtensionAvailable("GLX_SGI_swap_control")?1:-1; + } catch (Throwable t) { hasSwapIntervalSGI=1; } + } + if (hasSwapIntervalSGI>0) { + try { + glXExt.glXSwapIntervalSGI(interval); + } catch (Throwable t) { hasSwapIntervalSGI=-1; } } } finally { getDrawableImpl().getFactoryImpl().unlockToolkit(); diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java index a454cc429..738714ecb 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java @@ -67,6 +67,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { try { X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); config.updateGraphicsConfiguration(); + if (DEBUG) { System.err.println("!!! X11GLXDrawable.setRealized(true): "+config); } @@ -75,6 +76,29 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { } } + public void swapBuffers() throws GLException { + GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + if (caps.getDoubleBuffered()) { + boolean didLock = false; + try { + if ( !isSurfaceLocked() ) { + // Usually the surface shall be locked within [makeCurrent .. swap .. release] + if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { + return; + } + didLock=true; + } + + GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); + + } finally { + if(didLock) { + unlockSurface(); + } + } + } + } + //--------------------------------------------------------------------------- // Internals only below this point // 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 de211af79..acca5fe81 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 @@ -140,8 +140,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna } public GLContext createExternalGLContext() { - AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault(); - return new X11ExternalGLXContext(screen); + return X11ExternalGLXContext.create(this, null); } public boolean canCreateExternalGLDrawable() { @@ -149,8 +148,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna } public GLDrawable createExternalGLDrawable() { - AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault(); - return X11ExternalGLXDrawable.create(this, screen); + return X11ExternalGLXDrawable.create(this, null); } public void loadGLULibrary() { diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java index 7b59a8d56..4cd174bec 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java @@ -38,6 +38,7 @@ import javax.media.nativewindow.x11.*; import javax.media.opengl.*; import com.sun.opengl.impl.*; import com.sun.gluegen.runtime.NativeLibrary; +import com.sun.gluegen.runtime.PointerBuffer; import com.sun.nativewindow.impl.x11.*; public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable { @@ -57,6 +58,30 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem fbConfigID = fbcfgID; } + public static X11GLXGraphicsConfiguration create(GLProfile glp, X11GraphicsScreen x11Screen, int fbcfgID) { + long display = x11Screen.getDevice().getHandle(); + if(0==display) { + throw new GLException("Display null of "+x11Screen); + } + int screen = x11Screen.getIndex(); + long fbcfg = glXFBConfigID2FBConfig(display, screen, fbcfgID); + if(0==fbcfg) { + throw new GLException("FBConfig null of 0x"+Integer.toHexString(fbcfgID)); + } + if(null==glp) { + glp = GLProfile.getDefault(); + } + GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, GLXUtil.isMultisampleAvailable(display)); + if(null==caps) { + throw new GLException("GLCapabilities null of 0x"+Long.toHexString(fbcfg)); + } + XVisualInfo xvi = GLX.glXGetVisualFromFBConfigCopied(display, fbcfg); + if(null==xvi) { + throw new GLException("XVisualInfo null of 0x"+Long.toHexString(fbcfg)); + } + return new X11GLXGraphicsConfiguration(x11Screen, caps, caps, new DefaultGLCapabilitiesChooser(), xvi, fbcfg, fbcfgID); + } + public Object clone() { return super.clone(); } @@ -84,7 +109,6 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem public static int[] GLCapabilities2AttribList(GLCapabilities caps, boolean forFBAttr, boolean isMultisampleAvailable, - boolean usePBuffer, long display, int screen) { @@ -99,7 +123,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem if (forFBAttr) { res[idx++] = GLX.GLX_DRAWABLE_TYPE; - res[idx++] = usePBuffer?GLX.GLX_PBUFFER_BIT:GLX.GLX_WINDOW_BIT; + res[idx++] = caps.isOnscreen() ? ( GLX.GLX_WINDOW_BIT ) : ( caps.isPBuffer() ? GLX.GLX_PBUFFER_BIT : GLX.GLX_PIXMAP_BIT ) ; } if (forFBAttr) { @@ -169,7 +193,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res[idx++] = GLX.GLX_SAMPLES; res[idx++] = caps.getNumSamples(); } - if (usePBuffer) { + if (caps.isPBuffer()) { if (caps.getPbufferFloatingPointBuffers()) { String glXExtensions = GLX.glXQueryExtensionsString(display, screen); if (glXExtensions == null || @@ -184,111 +208,33 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return res; } - public static GLCapabilities AttribList2GLCapabilities(GLProfile glp, - int[] iattribs, - int niattribs, - int[] ivalues, - boolean usePBuffer) { - GLCapabilities caps = new GLCapabilities(glp); - - for (int i = 0; i < niattribs; i++) { - int attr = iattribs[i]; - switch (attr) { - case GLX.GLX_DOUBLEBUFFER: - caps.setDoubleBuffered(ivalues[i] != GL.GL_FALSE); - break; - - case GLX.GLX_STEREO: - caps.setStereo(ivalues[i] != GL.GL_FALSE); - break; - - case GLX.GLX_RED_SIZE: - caps.setRedBits(ivalues[i]); - break; - - case GLX.GLX_GREEN_SIZE: - caps.setGreenBits(ivalues[i]); - break; - - case GLX.GLX_BLUE_SIZE: - caps.setBlueBits(ivalues[i]); - break; - - case GLX.GLX_ALPHA_SIZE: - caps.setAlphaBits(ivalues[i]); - break; - - case GLX.GLX_DEPTH_SIZE: - caps.setDepthBits(ivalues[i]); - break; - - case GLX.GLX_STENCIL_SIZE: - caps.setStencilBits(ivalues[i]); - break; - - case GLX.GLX_ACCUM_RED_SIZE: - caps.setAccumRedBits(ivalues[i]); - break; - - case GLX.GLX_ACCUM_GREEN_SIZE: - caps.setAccumGreenBits(ivalues[i]); - break; - - case GLX.GLX_ACCUM_BLUE_SIZE: - caps.setAccumBlueBits(ivalues[i]); - break; - - case GLX.GLX_ACCUM_ALPHA_SIZE: - caps.setAccumAlphaBits(ivalues[i]); - break; - - case GLX.GLX_SAMPLE_BUFFERS: - caps.setSampleBuffers(ivalues[i] != GL.GL_FALSE); - break; - - case GLX.GLX_SAMPLES: - caps.setNumSamples(ivalues[i]); - break; - - case GLX.GLX_CONFIG_CAVEAT: - caps.setHardwareAccelerated(ivalues[i] != GLX.GLX_SLOW_CONFIG); - break; - - case GLX.GLX_TRANSPARENT_TYPE: - caps.setBackgroundOpaque(ivalues[i] == GLX.GLX_NONE); - break; - - case GLXExt.GLX_FLOAT_COMPONENTS_NV: - caps.setPbufferFloatingPointBuffers(ivalues[i] != GL.GL_FALSE); - break; - - case GLX.GLX_TRANSPARENT_RED_VALUE: - caps.setTransparentRedValue(ivalues[i]); - break; - - case GLX.GLX_TRANSPARENT_GREEN_VALUE: - caps.setTransparentGreenValue(ivalues[i]); - break; - - case GLX.GLX_TRANSPARENT_BLUE_VALUE: - caps.setTransparentBlueValue(ivalues[i]); - break; - - case GLX.GLX_TRANSPARENT_ALPHA_VALUE: - caps.setTransparentAlphaValue(ivalues[i]); - break; - - default: - break; - } - } + // FBConfig - return caps; + public static boolean GLXFBConfigValid(long display, long fbcfg) { + int[] tmp = new int[1]; + if(GLX.GLX_BAD_ATTRIBUTE == GLX.glXGetFBConfigAttrib(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0)) { + return false; + } + return true; } - // FBConfig + public static boolean GLXFBConfigDrawableTypeVerify(int val, boolean onscreen, boolean usePBuffer) { + boolean res; - public static GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg, boolean isMultisampleEnabled) { + if ( onscreen ) { + res = ( 0 != (val & GLX.GLX_WINDOW_BIT) ) ; + } else { + res = ( 0 != (val & GLX.GLX_PIXMAP_BIT) ) || usePBuffer ; + } + if ( usePBuffer ) { + res = res && ( 0 != (val & GLX.GLX_PBUFFER_BIT) ) ; + } + + return res; + } + + public static GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg, + boolean relaxed, boolean onscreen, boolean usePBuffer, boolean isMultisampleEnabled) { int[] tmp = new int[1]; int val; val = glXGetFBConfig(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0); @@ -296,6 +242,17 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem throw new GLException("Visual does not support RGBA"); } GLCapabilities res = new GLCapabilities(glp); + + val = glXGetFBConfig(display, fbcfg, GLX.GLX_DRAWABLE_TYPE, tmp, 0); + if(GLXFBConfigDrawableTypeVerify(val, onscreen, usePBuffer)) { + res.setOnscreen(onscreen); + res.setPBuffer(usePBuffer); + } else if(relaxed) { + res.setOnscreen( 0 != (val & GLX.GLX_WINDOW_BIT) ); + res.setPBuffer ( 0 != (val & GLX.GLX_PBUFFER_BIT) ); + } else { + return null; + } res.setDoubleBuffered(glXGetFBConfig(display, fbcfg, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0); res.setStereo (glXGetFBConfig(display, fbcfg, GLX.GLX_STEREO, tmp, 0) != 0); res.setHardwareAccelerated(glXGetFBConfig(display, fbcfg, GLX.GLX_CONFIG_CAVEAT, tmp, 0) != GLX.GLX_SLOW_CONFIG); @@ -352,6 +309,21 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return tmp[tmp_offset]; } + public static int glXFBConfig2FBConfigID(long display, long cfg) { + int[] tmpID = new int[1]; + return glXGetFBConfig(display, cfg, GLX.GLX_FBCONFIG_ID, tmpID, 0); + } + + public static long glXFBConfigID2FBConfig(long display, int screen, int id) { + int[] attribs = new int[] { GLX.GLX_FBCONFIG_ID, id, 0 }; + int[] count = { -1 }; + PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0); + if (fbcfgsL == null || fbcfgsL.limit()<1) { + return 0; + } + return fbcfgsL.get(0); + } + // Visual Info public static XVisualInfo XVisualID2XVisualInfo(long display, long visualID) { @@ -376,7 +348,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return res; } - public static GLCapabilities XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info, boolean isMultisampleEnabled) { + public static GLCapabilities XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info, boolean onscreen, boolean usePBuffer, boolean isMultisampleEnabled) { int[] tmp = new int[1]; int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0); if (val == 0) { @@ -387,6 +359,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem throw new GLException("Visual does not support RGBA"); } GLCapabilities res = new GLCapabilities(glp); + res.setOnscreen (onscreen); + res.setPBuffer (usePBuffer); res.setDoubleBuffered(glXGetConfig(display, info, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0); res.setStereo (glXGetConfig(display, info, GLX.GLX_STEREO, tmp, 0) != 0); // Note: use of hardware acceleration is determined by diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 0fcb9b3ff..9cb7eac08 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -58,10 +58,10 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { - return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, false); + return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, capabilities.isOnscreen(), false); } - protected static X11GLXGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean usePBuffer) { + protected static X11GLXGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) { if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } @@ -87,19 +87,18 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac long visID = X11Lib.DefaultVisualID(display, x11Screen.getIndex()); xvis = X11GLXGraphicsConfiguration.XVisualID2XVisualInfo(display, visID); - caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis, isMultisampleAvailable); + caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis, onscreen, usePBuffer, isMultisampleAvailable); - int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, usePBuffer, 0, 0); + int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, 0, 0); int[] count = { -1 }; PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0); if (fbcfgsL == null || fbcfgsL.limit()<1) { throw new Exception("Could not fetch FBConfig for "+caps); } fbcfg = fbcfgsL.get(0); - capsFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg, isMultisampleAvailable); + capsFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg, true, onscreen, usePBuffer, isMultisampleAvailable); - int[] tmpID = new int[1]; - fbid = X11GLXGraphicsConfiguration.glXGetFBConfig(display, fbcfg, GLX.GLX_FBCONFIG_ID, tmpID, 0); + fbid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg); xvis = GLX.glXGetVisualFromFBConfigCopied(display, fbcfg); if (xvis==null) { @@ -110,13 +109,13 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock(); } - return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid); + return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid); } protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, - boolean usePBuffer) { + boolean onscreen, boolean usePBuffer) { if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } @@ -139,12 +138,16 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac if (capabilities == null) { capabilities = new GLCapabilities(null); } - + capabilities.setOnscreen (onscreen); + ((GLCapabilities)capabilities).setPBuffer (usePBuffer); + if(!onscreen) { + ((GLCapabilities)capabilities).setDoubleBuffered(false); + } X11GLXGraphicsConfiguration res; res = chooseGraphicsConfigurationFBConfig((GLCapabilities) capabilities, (GLCapabilitiesChooser) chooser, - x11Screen, usePBuffer); + x11Screen); if(null==res) { if(usePBuffer) { throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig"); @@ -164,8 +167,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationFBConfig(GLCapabilities capabilities, GLCapabilitiesChooser chooser, - X11GraphicsScreen x11Screen, - boolean usePBuffer) { + X11GraphicsScreen x11Screen) { int recommendedIndex = -1; GLCapabilities[] caps = null; PointerBuffer fbcfgsL = null; @@ -173,6 +175,8 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac int retFBID=-1; XVisualInfo retXVisualInfo = null; GLProfile glProfile = capabilities.getGLProfile(); + boolean onscreen = capabilities.isOnscreen(); + boolean usePBuffer = capabilities.isPBuffer(); // Utilizing FBConfig // @@ -182,7 +186,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac AbstractGraphicsDevice absDevice = x11Screen.getDevice(); long display = absDevice.getHandle(); boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display); - int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, usePBuffer, 0, 0); + int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, 0, 0); int[] count = { -1 }; fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0); @@ -192,10 +196,17 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac } return null; } + if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) { + if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: 0x"+Long.toHexString(fbcfgsL.get(0))); + } + return null; + } recommendedIndex = 0; // 1st match is always recommended .. caps = new GLCapabilities[fbcfgsL.limit()]; for (int i = 0; i < fbcfgsL.limit(); i++) { - caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i), isMultisampleAvailable); + caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i), + false, onscreen, usePBuffer, isMultisampleAvailable); } if(null==chooser) { @@ -212,8 +223,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")"); } - int[] tmpID = new int[1]; - retFBID = X11GLXGraphicsConfiguration.glXGetFBConfig(display, fbcfgsL.get(chosen), GLX.GLX_FBCONFIG_ID, tmpID, 0); + retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen)); retXVisualInfo = GLX.glXGetVisualFromFBConfigCopied(display, fbcfgsL.get(chosen)); if (retXVisualInfo==null) { @@ -241,6 +251,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac // system's selection to the chooser as a hint GLProfile glProfile = capabilities.getGLProfile(); + boolean onscreen = capabilities.isOnscreen(); GLCapabilities[] caps = null; int recommendedIndex = -1; XVisualInfo retXVisualInfo = null; @@ -252,7 +263,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac AbstractGraphicsDevice absDevice = x11Screen.getDevice(); long display = absDevice.getHandle(); boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display); - int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, false, 0, 0); + int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, 0, 0); XVisualInfo[] infos = null; XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0); @@ -273,7 +284,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac } caps = new GLCapabilities[infos.length]; for (int i = 0; i < infos.length; i++) { - caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], isMultisampleAvailable); + caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable); // Attempt to find the visual chosen by glXChooseVisual if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) { recommendedIndex = i; diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXContext.java index c6d787f2b..7a38f0ce1 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXContext.java @@ -58,7 +58,8 @@ public class X11OffscreenGLXContext extends X11GLXContext { } public int getOffscreenContextReadBuffer() { - if (drawable.isDoubleBuffered()) { + GLCapabilities caps = (GLCapabilities)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + if (caps.getDoubleBuffered()) { return GL.GL_BACK; } return GL.GL_FRONT; @@ -70,15 +71,6 @@ public class X11OffscreenGLXContext extends X11GLXContext { return true; } - protected int makeCurrentImpl() throws GLException { - getDrawableImpl().getFactoryImpl().lockToolkit(); - try { - return super.makeCurrentImpl(); - } finally { - getDrawableImpl().getFactoryImpl().unlockToolkit(); - } - } - protected void create() { createContext(false); } 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 69ecc34d2..51938df5f 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 @@ -47,14 +47,13 @@ import com.sun.nativewindow.impl.x11.*; public class X11OffscreenGLXDrawable extends X11GLXDrawable { private long pixmap; - private boolean isDoubleBuffered; protected X11OffscreenGLXDrawable(GLDrawableFactory factory, AbstractGraphicsScreen screen, GLCapabilities caps, GLCapabilitiesChooser chooser, int width, int height) { - super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen, false)), true); + super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen, false, false)), true); ((NullWindow) getNativeWindow()).setSize(width, height); create(); } @@ -87,7 +86,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { throw new GLException("glXCreateGLXPixmap failed"); } nw.setSurfaceHandle(drawable); - isDoubleBuffered = (X11GLXGraphicsConfiguration.glXGetConfig(dpy, vis, GLX.GLX_DOUBLEBUFFER, new int[1], 0) != 0); if (DEBUG) { System.err.println("Created pixmap " + toHexString(pixmap) + ", GLXPixmap " + toHexString(drawable) + @@ -135,8 +133,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { getFactoryImpl().unlockToolkit(); } } - - public boolean isDoubleBuffered() { - return isDoubleBuffered; + public void swapBuffers() throws GLException { } } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java index d80a833f5..4a81448fd 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java @@ -61,23 +61,4 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { return component.getHeight(); } - public void swapBuffers() throws GLException { - boolean didLock = false; - try { - if ( !isSurfaceLocked() ) { - // Usually the surface shall be locked within [makeCurrent .. swap .. release] - if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { - return; - } - didLock=true; - } - - GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); - - } finally { - if(didLock) { - unlockSurface(); - } - } - } } 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 753e9d884..eecd92a53 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 @@ -51,7 +51,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { GLCapabilities caps, GLCapabilitiesChooser chooser, int width, int height) { - super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen, true)), true); + super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen, false, true)), true); if (width <= 0 || height <= 0) { throw new GLException("Width and height of pbuffer must be positive (were (" + width + ", " + height + "))"); @@ -147,4 +147,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { // Floating-point pbuffers currently require NVidia hardware on X11 return GLPbuffer.NV_FLOAT; } + + public void swapBuffers() throws GLException { + } } |