diff options
Diffstat (limited to 'src/jogl/classes/com/sun/opengl')
6 files changed, 50 insertions, 13 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java index 0d540647a..4597a5078 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java @@ -54,6 +54,45 @@ import java.lang.reflect.*; public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected static final boolean DEBUG = Debug.debug("GLDrawableFactory"); + //--------------------------------------------------------------------------- + // Dispatching GLDrawable construction in respect to the NativeWindow Capabilities + // + public GLDrawable createGLDrawable(NativeWindow target) { + if (target == null) { + throw new IllegalArgumentException("Null target"); + } + AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + target = NativeWindowFactory.getNativeWindow(target, config); + GLCapabilities caps = (GLCapabilities) target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + GLDrawable result = null; + if(caps.isOnscreen()) { + if(caps.isPBuffer()) { + throw new IllegalArgumentException("Onscreen target can't be PBuffer: "+caps); + } + result = createOnscreenDrawable(target); + } else { + if(caps.isPBuffer() && canCreateGLPbuffer()) { + // PBUFFER + result = createGLPbuffer(caps, + null /* GLCapabilitiesChooser */, + target.getWidth(), + target.getHeight(), + null /* shareContext */ ) ; + + } + if(null==result) { + result = createOffscreenDrawable(caps, + null /* GLCapabilitiesChooser */, + target.getWidth(), + target.getHeight()); + } + } + if(DEBUG) { + System.out.println("GLDrawableFactoryImpl.createGLDrawable: "+result); + } + return result; + } + /** Creates a (typically software-accelerated) offscreen GLDrawable used to implement the fallback rendering path of the GLJPanel. */ @@ -62,6 +101,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { int width, int height); + /** Creates a (typically hw-accelerated) onscreen GLDrawable. */ + public abstract GLDrawableImpl createOnscreenDrawable(NativeWindow target); + protected GLDrawableFactoryImpl() { super(); } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java index aabc6f263..4265ee8fb 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java @@ -127,7 +127,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { eglConfig.updateGraphicsConfiguration(); } } else { - throw new GLException("EGLGraphicsConfiguration doesn't carry a EGLGraphicsDevice: "+aConfig); + throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig); } } else { // create a new EGL config .. diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java index 7af45d683..cf466ef2c 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -61,8 +61,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { super(); } - public GLDrawable createGLDrawable(NativeWindow target) { - target = NativeWindowFactory.getNativeWindow(target, null); + public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { + if (target == null) { + throw new IllegalArgumentException("Null target"); + } return new EGLOnscreenDrawable(this, target); } @@ -81,9 +83,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final int initialWidth, final int initialHeight, final GLContext shareWith) { - if (!canCreateGLPbuffer()) { - throw new GLException("Pbuffer support not available with this EGL implementation"); - } EGLPbufferDrawable pbufferDrawable = new EGLPbufferDrawable(this, capabilities, chooser, initialWidth, initialHeight); 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 7bcc4ca14..024b69629 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 @@ -62,12 +62,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D } catch (Throwable t) { } } - public GLDrawable createGLDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { if (target == null) { throw new IllegalArgumentException("Null target"); } - NativeWindowFactory factory = NativeWindowFactory.getFactory(target.getClass()); - target = NativeWindowFactory.getNativeWindow(target, null); return new MacOSXOnscreenCGLDrawable(this, target); } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 4d965e52b..4e02dfe92 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -71,11 +71,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements loadOpenGL32Library(); } - public GLDrawable createGLDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { if (target == null) { throw new IllegalArgumentException("Null target"); } - target = NativeWindowFactory.getNativeWindow(target, null); return new WindowsOnscreenWGLDrawable(this, target); } 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 acca5fe81..762ed5cac 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 @@ -65,11 +65,10 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna } catch (Throwable t) { } } - public GLDrawable createGLDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { if (target == null) { throw new IllegalArgumentException("Null target"); } - target = NativeWindowFactory.getNativeWindow(target, null); return new X11OnscreenGLXDrawable(this, target); } |