diff options
author | Kenneth Russel <[email protected]> | 2009-03-19 00:32:21 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2009-03-19 00:32:21 +0000 |
commit | c4cd0db6b9865c97245921d2824bcc4c1541e615 (patch) | |
tree | 6f9df4a383767992fa9ec36d820630bfabedf75a /src/jogl/classes/javax/media/opengl/awt | |
parent | 23d13ee00ebdf7052299fc65af6f50e43d673e67 (diff) |
Movement of Capabilities class and chooseCapabilities functionality
into NativeWindowFactory introduced an undesirable dependence between
the windowing toolkit, which can be replaced via NativeWindowFactory,
and the library which implements the selection algorithm, for example
OpenGL. This would prevent, for example, an easy SWT port of JOGL.
To fix this, refactored chooseCapabilities into new
GraphicsConfigurationFactory, the default implementation of which is
currently a no-op on X11 platforms, and which is provided by JOGL in a
toolkit-agnostic manner via GLX. Refactored OpenGL portions of
Capabilities class back into GLCapabilities. Reintroduced
GLCapabilitiesChooser interface for compatibility and to avoid having
to import javax.media.nativewindow classes in most user code.
Fixed problem in GLProfile where failures to load native libraries
were being squelched. Reorganized build to have all outputs under
build/ directory.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1884 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 31 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 42 |
2 files changed, 37 insertions, 36 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 8ef797c97..232299594 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -84,8 +84,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { private boolean sendReshape = false; private GraphicsConfiguration chosen; - private NWCapabilities glCaps; - private NWCapabilitiesChooser glCapChooser; + private GLCapabilities glCaps; + private GLCapabilitiesChooser glCapChooser; static { // Default to the GL2 profile, which is the default on the desktop @@ -104,15 +104,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { /** 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(NWCapabilities capabilities) { + public GLCanvas(GLCapabilities capabilities) { this(capabilities, null, null, null); } - /** Creates a new GLCanvas component. The passed NWCapabilities + /** 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 NWCapabilitiesChooser + default set of capabilities is used. The GLCapabilitiesChooser specifies the algorithm for selecting one of the available - NWCapabilities for the component; a DefaultGLCapabilitesChooser + 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 @@ -123,8 +123,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local GraphicsEnvironment if null is passed for this argument. */ - public GLCanvas(NWCapabilities capabilities, - NWCapabilitiesChooser chooser, + public GLCanvas(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, GLContext shareWith, GraphicsDevice device) { // The platform-specific GLDrawableFactory will only provide a @@ -466,11 +466,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { maybeDoSingleThreadedWorkaround(swapBuffersOnEventDispatchThreadAction, swapBuffersAction); } - public NWCapabilities getChosenNWCapabilities() { + public GLCapabilities getChosenGLCapabilities() { if (drawable == null) return null; - return drawable.getChosenNWCapabilities(); + return drawable.getChosenGLCapabilities(); } public NativeWindow getNativeWindow() { @@ -609,18 +609,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { } } - private static GraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities, - NWCapabilitiesChooser chooser, + private static GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, GraphicsDevice device) { // Make GLCanvas behave better in NetBeans GUI builder if (Beans.isDesignTime()) { return null; } + AWTGraphicsDevice awtDevice = new AWTGraphicsDevice(device); AWTGraphicsConfiguration config = (AWTGraphicsConfiguration) - NativeWindowFactory.getFactory(Component.class).chooseGraphicsConfiguration(capabilities, - chooser, - new AWTGraphicsDevice(device)); + GraphicsConfigurationFactory.getFactory(awtDevice).chooseGraphicsConfiguration(capabilities, + chooser, + awtDevice); if (config == null) { return null; } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 9ea7d59dd..86668373d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -64,7 +64,7 @@ import com.sun.opengl.impl.awt.*; Z-ordering or LayoutManager problems. <P> The GLJPanel can be made transparent by creating it with a - NWCapabilities object with alpha bits specified and calling {@link + GLCapabilities object with alpha bits specified and calling {@link #setOpaque}(false). Pixels with resulting OpenGL alpha values less than 1.0 will be overlaid on any underlying Swing rendering. <P> @@ -91,8 +91,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { private volatile boolean isInitialized; // Data used for either pbuffers or pixmap-based offscreen surfaces - private NWCapabilities offscreenCaps; - private NWCapabilitiesChooser chooser; + private GLCapabilities offscreenCaps; + private GLCapabilitiesChooser chooser; private GLContext shareWith; // Width of the actual GLJPanel private int panelWidth = 0; @@ -159,33 +159,33 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { /** Creates a new GLJPanel component with the requested set of OpenGL capabilities, using the default OpenGL capabilities selection mechanism. */ - public GLJPanel(NWCapabilities capabilities) { + public GLJPanel(GLCapabilities capabilities) { this(capabilities, null, null); } - /** Creates a new GLJPanel component. The passed NWCapabilities + /** 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 NWCapabilitiesChooser + default set of capabilities is used. The GLCapabilitiesChooser specifies the algorithm for selecting one of the available - NWCapabilities for the component; a DefaultGLCapabilitesChooser + 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. See the note in the overview documentation on <a href="../../../overview-summary.html#SHARING">context sharing</a>. */ - public GLJPanel(NWCapabilities capabilities, NWCapabilitiesChooser chooser, GLContext shareWith) { + public GLJPanel(GLCapabilities capabilities, GLCapabilitiesChooser chooser, GLContext shareWith) { super(); // Works around problems on many vendors' cards; we don't need a // back buffer for the offscreen surface anyway if (capabilities != null) { - offscreenCaps = (NWCapabilities) capabilities.clone(); + offscreenCaps = (GLCapabilities) capabilities.clone(); } else { - offscreenCaps = new NWCapabilities(); + offscreenCaps = new GLCapabilities(); } offscreenCaps.setDoubleBuffered(false); - this.chooser = ((chooser != null) ? chooser : new DefaultNWCapabilitiesChooser()); + this.chooser = ((chooser != null) ? chooser : new DefaultGLCapabilitiesChooser()); this.shareWith = shareWith; } @@ -404,8 +404,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { return oglPipelineEnabled; } - public NWCapabilities getChosenNWCapabilities() { - return backend.getChosenNWCapabilities(); + public GLCapabilities getChosenGLCapabilities() { + return backend.getChosenGLCapabilities(); } public NativeWindow getNativeWindow() { @@ -620,8 +620,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { // Called to get the current backend's GLDrawable public GLDrawable getDrawable(); - // Called to fetch the "real" chosen NWCapabilities for the backend - public NWCapabilities getChosenNWCapabilities(); + // Called to fetch the "real" chosen GLCapabilities for the backend + public GLCapabilities getChosenGLCapabilities(); // Called to handle a reshape event. When this is called, the // OpenGL context associated with the backend is not current, to @@ -861,11 +861,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { return offscreenDrawable; } - public NWCapabilities getChosenNWCapabilities() { + public GLCapabilities getChosenGLCapabilities() { if (offscreenDrawable == null) { return null; } - return offscreenDrawable.getChosenNWCapabilities(); + return offscreenDrawable.getChosenGLCapabilities(); } public void handleReshape() { @@ -952,11 +952,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { return pbuffer; } - public NWCapabilities getChosenNWCapabilities() { + public GLCapabilities getChosenGLCapabilities() { if (pbuffer == null) { return null; } - return pbuffer.getChosenNWCapabilities(); + return pbuffer.getChosenGLCapabilities(); } public void handleReshape() { @@ -1123,9 +1123,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { return joglDrawable; } - public NWCapabilities getChosenNWCapabilities() { + public GLCapabilities getChosenGLCapabilities() { // FIXME: should do better than this; is it possible to using only platform-independent code? - return new NWCapabilities(); + return new GLCapabilities(); } public void handleReshape() { |