From c3f4b1c7ccdd682f772fb0bdb67e3dd292ba9c06 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Wed, 9 Nov 2005 23:40:33 +0000 Subject: Made public API changes discussed with expert group to make core JOGL API more toolkit-agnostic: 1. Decoupled instantiation of GLCanvas and GLJPanel objects from the GLDrawableFactory. GLCanvas and GLJPanel's constructors are now public and the associated factory methods have been removed from the GLDrawableFactory. 2. Changed the signature of GLDrawableFactory. chooseGraphicsConfiguration() to accept and return marker AbstractGraphicsDevice and AbstractGraphicsConfiguration interfaces, respectively. Defined new AWTGraphicsDevice and AWTGraphicsConfiguration wrapper classes simply wrapping the associated objects. An SWT port could define similar wrapper classes for its data types. 3. Allowed overriding of the specific GLDrawableFactory subclass instantiated through GLDrawableFactory.getFactory() by setting the system property "opengl.factory.class.name". For example, an SWT port might swap itself in by specifying the following system property on the command line: -Dopengl.factory.class.name=com.ibm.swt.opengl.SWTGLDrawableFactory Tested on Solaris/SPARC. Also fixed breakage on Solaris/SPARC due to recent split of jogl native library into jogl and jogl_awt pieces. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@431 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../impl/macosx/MacOSXGLDrawableFactory.java | 8 +- .../impl/windows/WindowsGLDrawableFactory.java | 8 +- .../sun/opengl/impl/x11/X11GLDrawableFactory.java | 19 +++- .../media/opengl/AWTGraphicsConfiguration.java | 57 ++++++++++++ .../javax/media/opengl/AWTGraphicsDevice.java | 57 ++++++++++++ .../opengl/AbstractGraphicsConfiguration.java | 46 ++++++++++ .../javax/media/opengl/AbstractGraphicsDevice.java | 46 ++++++++++ src/classes/javax/media/opengl/GLCanvas.java | 54 ++++++++--- .../javax/media/opengl/GLDrawableFactory.java | 101 +++++++-------------- src/classes/javax/media/opengl/GLJPanel.java | 32 +++++-- src/native/jogl/InternalBufferUtils.c | 9 ++ src/native/jogl/JAWT_DrawingSurfaceInfo.c | 9 -- 12 files changed, 332 insertions(+), 114 deletions(-) create mode 100644 src/classes/javax/media/opengl/AWTGraphicsConfiguration.java create mode 100644 src/classes/javax/media/opengl/AWTGraphicsDevice.java create mode 100644 src/classes/javax/media/opengl/AbstractGraphicsConfiguration.java create mode 100644 src/classes/javax/media/opengl/AbstractGraphicsDevice.java diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java index 9b351798c..22f550456 100644 --- a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java @@ -41,8 +41,6 @@ package com.sun.opengl.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; @@ -54,9 +52,9 @@ public class MacOSXGLDrawableFactory extends GLDrawableFactoryImpl { NativeLibLoader.loadCore(); } - public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GraphicsDevice device) { + public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + AbstractGraphicsDevice device) { return null; } diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java index ac56d9469..4649ba8d0 100644 --- a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java @@ -40,8 +40,6 @@ package com.sun.opengl.impl.windows; import java.awt.Component; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; import java.awt.Rectangle; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -64,9 +62,9 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl { NativeLibLoader.loadCore(); } - public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GraphicsDevice device) { + public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + AbstractGraphicsDevice device) { return null; } diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java index 133431824..64b4d437c 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java @@ -78,17 +78,26 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { private static final int MAX_ATTRIBS = 128; - public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GraphicsDevice device) { + public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + AbstractGraphicsDevice absDevice) { if (capabilities == null) { capabilities = new GLCapabilities(); } if (chooser == null) { chooser = new DefaultGLCapabilitiesChooser(); } - if (device == null) { + GraphicsDevice device = null; + if (absDevice != null && + !(absDevice instanceof AWTGraphicsDevice)) { + throw new GLException("This GLDrawableFactory accepts only AWTGraphicsDevice objects"); + } + + if ((absDevice == null) || + (((AWTGraphicsDevice) absDevice).getGraphicsDevice() == null)) { device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + } else { + device = ((AWTGraphicsDevice) absDevice).getGraphicsDevice(); } int screen = X11SunJDKReflection.graphicsDeviceGetScreen(device); @@ -142,7 +151,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { GraphicsConfiguration config = configs[i]; if (config != null) { if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) { - return config; + return new AWTGraphicsConfiguration(config); } } } diff --git a/src/classes/javax/media/opengl/AWTGraphicsConfiguration.java b/src/classes/javax/media/opengl/AWTGraphicsConfiguration.java new file mode 100644 index 000000000..25647fc62 --- /dev/null +++ b/src/classes/javax/media/opengl/AWTGraphicsConfiguration.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package javax.media.opengl; + +import java.awt.GraphicsConfiguration; + +/** A wrapper for an AWT GraphicsConfiguration allowing it to be + handled in a toolkit-independent manner. */ + +public class AWTGraphicsConfiguration implements AbstractGraphicsConfiguration { + private GraphicsConfiguration config; + + public AWTGraphicsConfiguration(GraphicsConfiguration config) { + this.config = config; + } + + public GraphicsConfiguration getGraphicsConfiguration() { + return config; + } +} diff --git a/src/classes/javax/media/opengl/AWTGraphicsDevice.java b/src/classes/javax/media/opengl/AWTGraphicsDevice.java new file mode 100644 index 000000000..98c7ef2bf --- /dev/null +++ b/src/classes/javax/media/opengl/AWTGraphicsDevice.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package javax.media.opengl; + +import java.awt.GraphicsDevice; + +/** A wrapper for an AWT GraphicsDevice allowing it to be + handled in a toolkit-independent manner. */ + +public class AWTGraphicsDevice implements AbstractGraphicsDevice { + private GraphicsDevice device; + + public AWTGraphicsDevice(GraphicsDevice device) { + this.device = device; + } + + public GraphicsDevice getGraphicsDevice() { + return device; + } +} diff --git a/src/classes/javax/media/opengl/AbstractGraphicsConfiguration.java b/src/classes/javax/media/opengl/AbstractGraphicsConfiguration.java new file mode 100644 index 000000000..18149fb68 --- /dev/null +++ b/src/classes/javax/media/opengl/AbstractGraphicsConfiguration.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package javax.media.opengl; + +/** A marker interface describing a graphics configuration, visual, or + pixel format in a toolkit-independent manner. */ + +public interface AbstractGraphicsConfiguration { +} diff --git a/src/classes/javax/media/opengl/AbstractGraphicsDevice.java b/src/classes/javax/media/opengl/AbstractGraphicsDevice.java new file mode 100644 index 000000000..52ad9b796 --- /dev/null +++ b/src/classes/javax/media/opengl/AbstractGraphicsDevice.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package javax.media.opengl; + +/** A marker interface describing a graphics device in a + toolkit-independent manner. */ + +public interface AbstractGraphicsDevice { +} diff --git a/src/classes/javax/media/opengl/GLCanvas.java b/src/classes/javax/media/opengl/GLCanvas.java index 9151dbd37..fe2cd869b 100644 --- a/src/classes/javax/media/opengl/GLCanvas.java +++ b/src/classes/javax/media/opengl/GLCanvas.java @@ -70,22 +70,36 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private boolean autoSwapBufferMode = true; private boolean sendReshape = false; - /** Creates a new GLCanvas component. The passed GLCapabilities must - be non-null and specifies the OpenGL capabilities for the - component. The GLCapabilitiesChooser must be non-null and + /** Creates a new GLCanvas component with a default set of OpenGL + capabilities, using the default OpenGL capabilities selection + mechanism, on the default screen device. */ + public GLCanvas() { + this(null); + } + + /** Creates a new GLCanvas component with the requested set of + OpenGL capabilities, using the default OpenGL capabilities + selection mechanism, on the default screen device. */ + public GLCanvas(GLCapabilities capabilities) { + this(capabilities, null, null, null); + } + + /** Creates a new GLCanvas component. The passed GLCapabilities + specifies the OpenGL capabilities for the component; if null, a + default set of capabilities is used. The GLCapabilitiesChooser specifies the algorithm for selecting one of the available - GLCapabilities for the component; the GLDrawableFactory uses a - DefaultGLCapabilitesChooser if the user does not provide - one. The passed GLContext may be null and specifies an OpenGL - context with which to share textures, display lists and other - OpenGL state. The passed GraphicsDevice must be non-null and - indicates the screen on which to create the GLCanvas; the + GLCapabilities for the component; a DefaultGLCapabilitesChooser + is used if null is passed for this argument. The passed + GLContext specifies an OpenGL context with which to share + textures, display lists and other OpenGL state, and may be null + if sharing is not desired. The passed GraphicsDevice indicates + the screen on which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local - GraphicsEnvironment if the user does not provide one. */ - protected GLCanvas(GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GLContext shareWith, - GraphicsDevice device) { + GraphicsEnvironment if null is passed for this argument. */ + public GLCanvas(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLContext shareWith, + GraphicsDevice device) { // The platform-specific GLDrawableFactory will only provide a // non-null GraphicsConfiguration on platforms where this is // necessary (currently only X11, as Windows allows the pixel @@ -95,7 +109,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { // least in the Sun AWT implementation) that this will result in // equivalent behavior to calling the no-arg super() constructor // for Canvas. - super(GLDrawableFactory.getFactory().chooseGraphicsConfiguration(capabilities, chooser, device)); + super(unwrap((AWTGraphicsConfiguration) + GLDrawableFactory.getFactory().chooseGraphicsConfiguration(capabilities, + chooser, + new AWTGraphicsDevice(device)))); drawable = GLDrawableFactory.getFactory().getGLDrawable(this, capabilities, chooser); context = (GLContextImpl) drawable.createContext(shareWith); context.setSynchronized(true); @@ -305,4 +322,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } } + + private static GraphicsConfiguration unwrap(AWTGraphicsConfiguration config) { + if (config == null) { + return null; + } + return config.getGraphicsConfiguration(); + } } diff --git a/src/classes/javax/media/opengl/GLDrawableFactory.java b/src/classes/javax/media/opengl/GLDrawableFactory.java index c45bb16e0..42cf8a724 100644 --- a/src/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/classes/javax/media/opengl/GLDrawableFactory.java @@ -39,8 +39,7 @@ package javax.media.opengl; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; +import java.security.*; import com.sun.opengl.impl.*; /**

Provides a virtual machine- and operating system-independent @@ -67,6 +66,11 @@ import com.sun.opengl.impl.*; GLJPanel} if the capabilities can not be met. Pbuffers are always created immediately and their creation will fail with a {@link GLException} if errors occur.

+ +

The concrete GLDrawableFactory subclass instantiated by {@link + #getFactory getFactory} can be changed by setting the system + property opengl.factory.class.name to the + fully-qualified name of the desired class.

*/ public abstract class GLDrawableFactory { @@ -78,6 +82,12 @@ public abstract class GLDrawableFactory { public static GLDrawableFactory getFactory() { if (factory == null) { try { + String factoryClassName = + (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("opengl.factory.class.name"); + } + }); String osName = System.getProperty("os.name"); String osNameLowerCase = osName.toLowerCase(); Class factoryClass = null; @@ -88,7 +98,9 @@ public abstract class GLDrawableFactory { // sources, which we currently don't have to do) we break the only // static dependencies with platform-specific code here using reflection. - if (osNameLowerCase.startsWith("wind")) { + if (factoryClassName != null) { + factoryClass = Class.forName(factoryClassName); + } else if (osNameLowerCase.startsWith("wind")) { factoryClass = Class.forName("com.sun.opengl.impl.windows.WindowsGLDrawableFactory"); } else if (osNameLowerCase.startsWith("mac os x")) { factoryClass = Class.forName("com.sun.opengl.impl.macosx.MacOSXGLDrawableFactory"); @@ -102,11 +114,7 @@ public abstract class GLDrawableFactory { } factory = (GLDrawableFactory) factoryClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new GLException(e); - } catch (InstantiationException e) { - throw new GLException(e); - } catch (IllegalAccessException e) { + } catch (Exception e) { throw new GLException(e); } } @@ -115,22 +123,28 @@ public abstract class GLDrawableFactory { } /** - * Selects an AWT GraphicsConfiguration on the specified - * GraphicsDevice compatible with the supplied GLCapabilities. This - * method is intended to be used by applications which do not use - * the supplied GLCanvas class but instead wrap their own Canvas - * with a GLDrawable. Some platforms (specifically X11) require the - * GraphicsConfiguration to be specified when the platform-specific - * window system object, such as a Canvas, is created. This method - * returns null on platforms on which the OpenGL pixel format - * selection process is performed later. + *

Selects a graphics configuration on the specified graphics + * device compatible with the supplied GLCapabilities. This method + * is intended to be used by applications which do not use the + * supplied GLCanvas class but instead wrap their own Canvas or + * other window toolkit-specific object with a GLDrawable. Some + * platforms (specifically X11) require the graphics configuration + * to be specified when the window toolkit object is created. This + * method returns null on platforms on which the OpenGL pixel format + * selection process is performed later.

* - * @see java.awt.Canvas#Canvas(java.awt.GraphicsConfiguration) - */ - public abstract GraphicsConfiguration + *

The concrete data type of the passed graphics device and + * returned graphics configuration must be specified in the + * documentation binding this particular API to the underlying + * window toolkit. The Reference Implementation accepts {@link + * AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link + * AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. + * + * @see java.awt.Canvas#Canvas(java.awt.GraphicsConfiguration) */ + public abstract AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, GLCapabilitiesChooser chooser, - GraphicsDevice device); + AbstractGraphicsDevice device); /** * Returns a GLDrawable that wraps a platform-specific window system @@ -155,51 +169,6 @@ public abstract class GLDrawableFactory { //---------------------------------------------------------------------- // Methods to create high-level objects - /** Creates a {@link GLCanvas} on the default graphics device with - the specified capabilities using the default capabilities - selection algorithm. */ - public GLCanvas createGLCanvas(GLCapabilities capabilities) { - return createGLCanvas(capabilities, null, null, null); - } - - /** Creates a {@link GLCanvas} on the specified graphics device with - the specified capabilities using the supplied capabilities - selection algorithm. A null chooser is equivalent to using the - {@link DefaultGLCapabilitiesChooser}. The canvas will share - textures and display lists with the specified {@link GLContext}; - the context must either be null or have been fabricated by - classes in this package. A null context indicates no sharing. A - null GraphicsDevice is equivalent to using that returned from - GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(). */ - public GLCanvas createGLCanvas(GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GLContext shareWith, - GraphicsDevice device) { - return new GLCanvas(capabilities, - chooser, - shareWith, - device); - } - - /** Creates a {@link GLJPanel} with the specified capabilities using - the default capabilities selection algorithm. */ - public GLJPanel createGLJPanel(GLCapabilities capabilities) { - return createGLJPanel(capabilities, null, null); - } - - /** Creates a {@link GLJPanel} with the specified capabilities using - the supplied capabilities selection algorithm. A null chooser is - equivalent to using the {@link DefaultGLCapabilitiesChooser}. - The panel will share textures and display lists with the - specified {@link GLContext}; the context must either be null or - have been fabricated by classes in this package. A null context - indicates no sharing. */ - public GLJPanel createGLJPanel(GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GLContext shareWith) { - return new GLJPanel(capabilities, chooser, shareWith); - } - /** * Returns true if it is possible to create a GLPbuffer. Some older * graphics cards do not have this capability. diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java index d2d14c7b7..5460bc0cd 100644 --- a/src/classes/javax/media/opengl/GLJPanel.java +++ b/src/classes/javax/media/opengl/GLJPanel.java @@ -166,16 +166,30 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { private int viewportX; private int viewportY; - /** Creates a new GLJPanel component. The passed GLCapabilities must - be non-null and specifies the OpenGL capabilities for the - component. The GLCapabilitiesChooser must be non-null and + /** Creates a new GLJPanel component with a default set of OpenGL + capabilities and using the default OpenGL capabilities selection + mechanism. */ + public GLJPanel() { + this(null); + } + + /** Creates a new GLJPanel component with the requested set of + OpenGL capabilities, using the default OpenGL capabilities + selection mechanism. */ + public GLJPanel(GLCapabilities capabilities) { + this(capabilities, null, null); + } + + /** Creates a new GLJPanel component. The passed GLCapabilities + specifies the OpenGL capabilities for the component; if null, a + default set of capabilities is used. The GLCapabilitiesChooser specifies the algorithm for selecting one of the available - GLCapabilities for the component; the GLDrawableFactory uses a - DefaultGLCapabilitiesChooser if the user does not provide - one. The passed GLContext may be null and specifies an OpenGL - context with which to share textures, display lists and other - OpenGL state. */ - protected GLJPanel(GLCapabilities capabilities, GLCapabilitiesChooser chooser, GLContext shareWith) { + GLCapabilities for the component; a DefaultGLCapabilitesChooser + is used if null is passed for this argument. The passed + GLContext specifies an OpenGL context with which to share + textures, display lists and other OpenGL state, and may be null + if sharing is not desired. */ + public GLJPanel(GLCapabilities capabilities, GLCapabilitiesChooser chooser, GLContext shareWith) { super(); // Works around problems on many vendors' cards; we don't need a diff --git a/src/native/jogl/InternalBufferUtils.c b/src/native/jogl/InternalBufferUtils.c index 083f51b42..aced365b7 100644 --- a/src/native/jogl/InternalBufferUtils.c +++ b/src/native/jogl/InternalBufferUtils.c @@ -52,3 +52,12 @@ JNIEXPORT jobject JNICALL Java_com_sun_opengl_impl_InternalBufferUtils_newDirectByteBuffer(JNIEnv* env, jclass unused, jlong address, jint capacity) { return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) address, capacity); } + +#ifdef __sun +#include +/* Sun's GLX implementation doesn't have glXGetProcAddressARB (or + glXGetProcAddress) so we implement it here */ +void (*glXGetProcAddressARB(const char *procname))() { + return (void (*)()) dlsym(RTLD_DEFAULT, procname); +} +#endif /* __ sun */ diff --git a/src/native/jogl/JAWT_DrawingSurfaceInfo.c b/src/native/jogl/JAWT_DrawingSurfaceInfo.c index 6eeaf053b..ae5c3f935 100644 --- a/src/native/jogl/JAWT_DrawingSurfaceInfo.c +++ b/src/native/jogl/JAWT_DrawingSurfaceInfo.c @@ -92,12 +92,3 @@ Java_com_sun_opengl_impl_JAWT_1DrawingSurfaceInfo_platformInfo0(JNIEnv* env, job } return (*env)->CallStaticObjectMethod(env, platformDSIClass, factoryMethod, dirbuf); } - -#ifdef __sun -#include -/* Sun's GLX implementation doesn't have glXGetProcAddressARB (or - glXGetProcAddress) so we implement it here */ -void (*glXGetProcAddressARB(const char *procname))() { - return (void (*)()) dlsym(RTLD_DEFAULT, procname); -} -#endif /* __ sun */ -- cgit v1.2.3