javax.media.opengl
Class GLJPanel
JPanel
javax.media.opengl.GLJPanel
- ComponentEvents, GLAutoDrawable, GLDrawable
public class GLJPanel
extends JPanel
A lightweight Swing component which provides OpenGL rendering
support. Provided for compatibility with Swing user interfaces
when adding a heavyweight doesn't work either because of
Z-ordering or LayoutManager problems.
The GLJPanel can be made transparent by creating it with a
GLCapabilities object with alpha bits specified and calling
setOpaque(boolean)
(false). Pixels with resulting OpenGL alpha values less
than 1.0 will be overlaid on any underlying Swing rendering.
Notes specific to the Reference Implementation: This component
attempts to use hardware-accelerated rendering via pbuffers and
falls back on to software rendering if problems occur.
Note that because this component attempts to use pbuffers for
rendering, and because pbuffers can not be resized, somewhat
surprising behavior may occur during resize operations; the
GLEventListener.init(GLAutoDrawable)
method may be called multiple times as the
pbuffer is resized to be able to cover the size of the GLJPanel.
This behavior is correct, as the textures and display lists for
the GLJPanel will have been lost during the resize operation. The
application should attempt to make its GLEventListener.init()
methods as side-effect-free as possible.
GLJPanel() - Creates a new GLJPanel component with a default set of OpenGL
capabilities and using the default OpenGL capabilities selection
mechanism.
|
GLJPanel(GLCapabilities capabilities) - Creates a new GLJPanel component with the requested set of
OpenGL capabilities, using the default OpenGL capabilities
selection mechanism.
|
GLJPanel(GLCapabilities capabilities, GLCapabilitiesChooser chooser, GLContext shareWith) - Creates a new GLJPanel component.
|
GLJPanel
public GLJPanel()
Creates a new GLJPanel component with a default set of OpenGL
capabilities and using the default OpenGL capabilities selection
mechanism.
GLJPanel
public GLJPanel(GLCapabilities capabilities)
Creates a new GLJPanel component with the requested set of
OpenGL capabilities, using the default OpenGL capabilities
selection mechanism.
GLJPanel
public GLJPanel(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
GLContext shareWith)
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; 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
context sharing.
addNotify
public void addNotify()
Overridden to track when this component is added to a container.
Subclasses which override this method must call
super.addNotify() in their addNotify() method in order to
function properly.
Overrides:
addNotify
java.awt.Component
paintComponent
protected void paintComponent(Graphics g)
Overridden to cause OpenGL rendering to be performed during
repaint cycles. Subclasses which override this method must call
super.paintComponent() in their paintComponent() method in order
to function properly.
Overrides:
paintComponent
javax.swing.JComponent
removeNotify
public void removeNotify()
Overridden to track when this component is removed from a
container. Subclasses which override this method must call
super.removeNotify() in their removeNotify() method in order to
function properly.
Overrides:
removeNotify
java.awt.Component
reshape
public void reshape(int x,
int y,
int width,
int height)
setOpaque
public void setOpaque(boolean opaque)
shouldPreserveColorBufferIfTranslucent
public boolean shouldPreserveColorBufferIfTranslucent()
For a translucent GLJPanel (one for which
setOpaque
(false) has been called), indicates whether the
application should preserve the OpenGL color buffer
(GL_COLOR_BUFFER_BIT) for correct rendering of the GLJPanel and
underlying widgets which may show through portions of the
GLJPanel with alpha values less than 1. Most Swing
implementations currently expect the GLJPanel to be completely
cleared (e.g., by
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT)
), but for certain optimized Swing
implementations which use OpenGL internally, it may be possible
to perform OpenGL rendering using the GLJPanel into the same
OpenGL drawable as the Swing implementation uses.
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.