summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-26 05:38:24 +0200
committerSven Gothel <[email protected]>2013-04-26 05:38:24 +0200
commit36dc4f5ab6957a4078842c488afb51df2fdc0630 (patch)
tree5e5629f085f7d244faf1c1e5e15cfe935e87e1b4 /src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
parent75b3d37a3b15c071b49609921244bcb62d329fa9 (diff)
Simplify GLDrawableFactory's SharedResource Query Methods; Move WindowsWGLDrawableFactory Quirks to GLRendererQuirks (NeedCurrCtx4ARBPixFmtQueries, NeedCurrCtx4ARBCreateContext); Bug 706: Confine NeedCurrCtx4ARBCreateContext to [Windows, ATI, driver < 12.102.3); Avoid possible NPE @ GLContext.getGLVendorVersionNumber()
- Simplify GLDrawableFactory's SharedResource Query Methods - Moving common methods to GLDrawableFactory/GLDrawableFactoryImpl while reusing common methods to SharedResourceRunner.Resource. - All factories SharedResources impl. SharedResourceRunner.Resource. - Move WindowsWGLDrawableFactory Quirks to GLRendererQuirks (NeedCurrCtx4ARBPixFmtQueries, NeedCurrCtx4ARBCreateContext) - For better maintenance, move the mentioned quirks from the windows factory to our common place, being detected within GLContextImpl after each context creation. - Bug 706: Confine NeedCurrCtx4ARBCreateContext to [Windows, ATI, driver < 12.102.3) - Before we added this quirk if [Windows, ATI], however, we have hopes that the new drivers will suffice for all as tested successful on my test machine (AMD Radeon HD 6300M Series, amd_catalyst_13.5_mobility_beta2). - Avoid possible NPE @ GLContext.getGLVendorVersionNumber() - GLContext.getGLVendorVersionNumber() never returns 'null' but a zero version instance instead! - Add API doc. - Use mixed case names in GLContextImpl.setRendererQuirks(..).
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java61
1 files changed, 45 insertions, 16 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 26b1975ba..06e856d41 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -80,30 +80,61 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
super();
}
- @Override
- public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) {
- final GLContext ctx = getOrCreateSharedContextImpl(device);
- if(null != ctx) {
- return ctx.getRendererQuirks();
+ /**
+ * Returns the shared resource mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
+ * either a pre-existing or newly created, or <code>null</code> if creation failed or not supported.<br>
+ * Creation of the shared resource is tried only once.
+ *
+ * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+ */
+ protected final SharedResourceRunner.Resource getOrCreateSharedResource(AbstractGraphicsDevice device) {
+ try {
+ device = validateDevice(device);
+ if( null != device) {
+ return getOrCreateSharedResourceImpl( device );
+ }
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("Catched Exception on thread "+getThreadName());
+ gle.printStackTrace();
+ }
}
return null;
}
-
+ protected abstract SharedResourceRunner.Resource getOrCreateSharedResourceImpl(AbstractGraphicsDevice device);
+
/**
* Returns the shared context mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
- * either a pre-existing or newly created, or <code>null</code> if creation failed or not supported.<br>
+ * either a pre-existing or newly created, or <code>null</code> if creation failed or <b>not supported</b>.<br>
* Creation of the shared context is tried only once.
*
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
*/
public final GLContext getOrCreateSharedContext(AbstractGraphicsDevice device) {
- device = validateDevice(device);
- if(null!=device) {
- return getOrCreateSharedContextImpl(device);
+ final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device );
+ if(null!=sr) {
+ return sr.getContext();
+ }
+ return null;
+ }
+
+ @Override
+ protected final boolean createSharedResourceImpl(AbstractGraphicsDevice device) {
+ final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device );
+ if(null!=sr) {
+ return sr.isValid();
+ }
+ return false;
+ }
+
+ @Override
+ public final GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) {
+ final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device );
+ if(null!=sr) {
+ return sr.getRendererQuirks();
}
return null;
}
- protected abstract GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device);
/**
* Returns the shared device mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
@@ -113,15 +144,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be <code>null</code> for the platform's default device.
*/
protected final AbstractGraphicsDevice getOrCreateSharedDevice(AbstractGraphicsDevice device) {
- device = validateDevice(device);
- if( null != device) {
- return getOrCreateSharedDeviceImpl(device);
+ final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device );
+ if(null!=sr) {
+ return sr.getDevice();
}
return null;
}
- protected abstract AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device);
-
/**
* Returns the GLDynamicLookupHelper
* @param profile if EGL/ES, profile <code>1</code> refers to ES1 and <code>2</code> to ES2,