diff options
author | Sven Gothel <[email protected]> | 2010-12-03 21:32:16 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-12-03 21:32:16 +0100 |
commit | 4b9ad2508ff31a03d3bc4482d812a6cbc0c5c33b (patch) | |
tree | 28212ee090a08c3fae1943a26e6ac4633ecc5090 /src/jogl/classes/com/jogamp/opengl/impl/x11 | |
parent | de9211df2c1654db889bb5d5c43297ed7d6499ba (diff) |
Cleanup GLDrawableFactory API and platform Implementations
- Finish API change using the AbstractGraphicsDevice, which denotes the target device
for the desired NativeSurface / GLDrawable.
The AbstractGraphicsDevice argument may be null to reflect the platform's default device.
Clarified API documentation.
This move is necessary to make the API coherent.
- createOffscreenDrawable(..) may create a Pbuffer drawable if caps and supported.
This unifies the functionality with createGLDrawable(..).
Further more, a Pbuffer drawable is an offscreen as well.
- added createOffscreenSurface(..) following the same behavior as createOffscreenDrawable(..),
this is a convenient native offscreen surface factory entry.
- removed createGLPbufferDrawable(..), use createOffscreenDrawable(..),
since it is redundant!
Implementation Details:
- EGLDrawableFactory holds a shared native EGLGraphicsDevice,
being used by the offscreen EGL drawable (no more multiple creation).
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/x11')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java | 73 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java | 50 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PixmapGLXContext.java (renamed from src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java) | 4 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PixmapGLXDrawable.java (renamed from src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java) | 6 |
4 files changed, 42 insertions, 91 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java index c8b656e9f..3abbcee57 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -207,7 +207,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { private final SharedResource createSharedResource(String connection) { X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.createDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT); sharedDevice.setCloseDisplay(true); - X11Util.lockDefaultToolkit(sharedDevice.getHandle()); // OK + sharedDevice.lock(); try { String glXVendorName = GLXUtil.getVendorName(sharedDevice.getHandle()); X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); @@ -245,7 +245,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } return new SharedResource(sharedDevice, sharedScreen, sharedDrawable, sharedContext, glXVersion, glXVendorName); } finally { - X11Util.unlockDefaultToolkit(sharedDevice.getHandle()); // OK + sharedDevice.unlock(); } } @@ -343,23 +343,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } } - protected final SharedResource getOrCreateShared(AbstractGraphicsDevice device) { + private SharedResource getOrCreateShared(AbstractGraphicsDevice device) { String connection = device.getConnection(); - boolean deviceTried = getDeviceTried(connection); SharedResource sr; synchronized(sharedMap) { sr = (SharedResource) sharedMap.get(connection); } - if (DEBUG) { - System.err.println("getOrCreateShared() "+connection+": has shared "+(null!=sr)+", already tried "+deviceTried); - } - - if(null==sr && !deviceTried) { + if(null==sr && !getDeviceTried(connection)) { + addDeviceTried(connection); if (DEBUG) { System.err.println("getOrCreateShared() "+connection+": trying"); } - addDeviceTried(connection); sharedResourcesRunner.initializeAndWait(connection); synchronized(sharedMap) { sr = (SharedResource) sharedMap.get(connection); @@ -380,6 +375,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return null; } + protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) { + SharedResource sr = getOrCreateShared(device); + if(null!=sr) { + return sr.getDevice(); + } + return null; + } + protected final long getOrCreateSharedDpy(AbstractGraphicsDevice device) { SharedResource sr = getOrCreateShared(device); if(null!=sr) { @@ -439,35 +442,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new X11OffscreenGLXDrawable(this, target); - } - - public final boolean glXVersionGreaterEqualOneThree(AbstractGraphicsDevice device) { - VersionNumber glXVersion = getGLXVersion(device); - return ( null != glXVersion ) ? glXVersion.compareTo(versionOneThree) >= 0 : false ; - } - - public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { - if(null == device) { - SharedResource sr = getOrCreateShared(defaultDevice); - if(null!=sr) { - device = sr.getDevice(); - } - } - return glXVersionGreaterEqualOneThree(device); - } - - protected final GLDrawableImpl createGLPbufferDrawableImpl(final NativeSurface target) { - if (target == null) { - throw new IllegalArgumentException("Null target"); + AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + if(!caps.isPBuffer()) { + return new X11PixmapGLXDrawable(this, target); } + // PBuffer GLDrawable Creation GLDrawableImpl pbufferDrawable; - - AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration(); AbstractGraphicsDevice device = config.getScreen().getDevice(); - /** + /** * Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277, * we need to have a context current on the same Display to create a PBuffer. * The dummy context shall also use the same Display, @@ -489,11 +474,27 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return pbufferDrawable; } + public final boolean glXVersionGreaterEqualOneThree(AbstractGraphicsDevice device) { + VersionNumber glXVersion = getGLXVersion(device); + return ( null != glXVersion ) ? glXVersion.compareTo(versionOneThree) >= 0 : false ; + } - protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, + public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { + if(null == device) { + SharedResource sr = getOrCreateShared(defaultDevice); + if(null!=sr) { + device = sr.getDevice(); + } + } + return glXVersionGreaterEqualOneThree(device); + } + + protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height) { X11GraphicsScreen screen = null; - SharedResource sr = getOrCreateShared(defaultDevice); + SharedResource sr = getOrCreateShared(device); if(null!=sr) { screen = sr.getScreen(); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java index fcd2e4266..327ecd0be 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -88,56 +88,6 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac (GLCapabilitiesChooser)chooser, (X11GraphicsScreen)absScreen); } - /** - static X11GLXGraphicsConfiguration createDefaultGraphicsConfigurationFBConfig(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) { - if (absScreen == null) { - throw new IllegalArgumentException("AbstractGraphicsScreen is null"); - } - if (!(absScreen instanceof X11GraphicsScreen)) { - throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here"); - } - X11GraphicsScreen x11Screen = (X11GraphicsScreen)absScreen; - - GLProfile glProfile = GLProfile.getDefault(); - GLCapabilities availableCaps=null; - XVisualInfo xvis=null; - long fbcfg = 0; - int fbid = -1; - - // Utilizing FBConfig - // - GLCapabilities capsFB = null; - long display = x11Screen.getDevice().getHandle(); - - try { - int screen = x11Screen.getIndex(); - boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display); - - long visID = X11Util.DefaultVisualID(display, x11Screen.getIndex()); - xvis = X11GLXGraphicsConfiguration.XVisualID2XVisualInfo(display, visID); - availableCaps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis, onscreen, usePBuffer, isMultisampleAvailable); - - int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(availableCaps, true, isMultisampleAvailable, display, screen); - int[] count = { -1 }; - PointerBuffer fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0); - if (fbcfgsL == null || fbcfgsL.limit()<1) { - throw new Exception("Could not fetch FBConfig for "+availableCaps); - } - fbcfg = fbcfgsL.get(0); - capsFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg, true, onscreen, usePBuffer, isMultisampleAvailable); - - fbid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg); - - xvis = GLX.glXGetVisualFromFBConfig(display, fbcfg); - if (xvis==null) { - throw new GLException("Error: Choosen FBConfig has no visual"); - } - } catch (Throwable t) { - } - - return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:availableCaps, availableCaps, null, xvis, fbcfg, fbid); - } */ - static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser, diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PixmapGLXContext.java index 5ae641278..b7b4da75d 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PixmapGLXContext.java @@ -42,9 +42,9 @@ package com.jogamp.opengl.impl.x11.glx; import javax.media.opengl.*; -public class X11OffscreenGLXContext extends X11GLXContext { +public class X11PixmapGLXContext extends X11GLXContext { - public X11OffscreenGLXContext(X11OffscreenGLXDrawable drawable, + public X11PixmapGLXContext(X11PixmapGLXDrawable drawable, GLContext shareWith) { super(drawable, shareWith); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PixmapGLXDrawable.java index f46bdbb75..0343ffb02 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PixmapGLXDrawable.java @@ -44,10 +44,10 @@ import javax.media.nativewindow.*; import javax.media.opengl.*; import com.jogamp.nativewindow.impl.x11.*; -public class X11OffscreenGLXDrawable extends X11GLXDrawable { +public class X11PixmapGLXDrawable extends X11GLXDrawable { private long pixmap; - protected X11OffscreenGLXDrawable(GLDrawableFactory factory, NativeSurface target) { + protected X11PixmapGLXDrawable(GLDrawableFactory factory, NativeSurface target) { super(factory, target, true); create(); } @@ -61,7 +61,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { } public GLContext createContext(GLContext shareWith) { - return new X11OffscreenGLXContext(this, shareWith); + return new X11PixmapGLXContext(this, shareWith); } private void create() { |