aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media/opengl/GLCanvas.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/javax/media/opengl/GLCanvas.java')
-rw-r--r--src/classes/javax/media/opengl/GLCanvas.java54
1 files changed, 39 insertions, 15 deletions
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();
+ }
}