com.sun.opengl.impl.x11
Class X11GLDrawableFactory

java.lang.Object
  extended by javax.media.opengl.GLDrawableFactory
      extended by com.sun.opengl.impl.GLDrawableFactoryImpl
          extended by com.sun.opengl.impl.x11.X11GLDrawableFactory

public class X11GLDrawableFactory
extends GLDrawableFactoryImpl


Constructor Summary
X11GLDrawableFactory()
           
 
Method Summary
static GLCapabilities attribList2GLCapabilities(int[] iattribs, int niattribs, int[] ivalues, boolean pbuffer)
           
 boolean canCreateContextOnJava2DSurface()
           
 boolean canCreateExternalGLDrawable()
          Returns true if it is possible to create an external GLDrawable object via GLDrawableFactory.createExternalGLDrawable().
 boolean canCreateGLPbuffer()
          Returns true if it is possible to create a GLPbuffer.
 AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, GLCapabilitiesChooser chooser, AbstractGraphicsDevice absDevice)
           Selects a graphics configuration on the specified graphics device compatible with the supplied GLCapabilities.
 GLContext createContextOnJava2DSurface(java.awt.Graphics g, GLContext shareWith)
           
 GLContext createExternalGLContext()
           Creates a GLContext object representing an existing OpenGL context in an external (third-party) OpenGL-based library.
 GLDrawable createExternalGLDrawable()
           Creates a GLDrawable object representing an existing OpenGL drawable in an external (third-party) OpenGL-based library.
 GLPbuffer createGLPbuffer(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int initialWidth, int initialHeight, GLContext shareWith)
          Creates a GLPbuffer with the given capabilites and dimensions.
 GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, GLCapabilitiesChooser chooser)
          Creates a (typically software-accelerated) offscreen GLDrawable used to implement the fallback rendering path of the GLJPanel.
 long dynamicLookupFunction(java.lang.String glFuncName)
          Dynamically looks up the given function.
static long getDisplayConnection()
           
protected  java.nio.Buffer getGammaRamp()
          Gets the current gamma ramp.
protected  int getGammaRampLength()
          Returns the length of the computed gamma ramp for this OS and hardware.
 GLDrawable getGLDrawable(java.lang.Object target, GLCapabilities capabilities, GLCapabilitiesChooser chooser)
          Returns a GLDrawable that wraps a platform-specific window system object, such as an AWT or LCDUI Canvas.
static X11GLDrawableFactory getX11Factory()
           
static int[] glCapabilities2AttribList(GLCapabilities caps, boolean isMultisampleAvailable, boolean pbuffer, long display, int screen)
           
static int glXGetConfig(long display, XVisualInfo info, int attrib, int[] tmp, int tmp_offset)
           
static boolean isMultisampleAvailable()
           
static boolean isVendorATI()
          Workaround for apparent issue with ATI's proprietary drivers where direct contexts still send GLX tokens for GL calls
protected  boolean isXineramaEnabled()
           
 void loadGLULibrary()
           
 void lockAWTForJava2D()
          Locks the AWT for the purposes of Java2D/JOGL integration.
 void lockToolkit()
           
protected  void resetGammaRamp(java.nio.Buffer originalGammaRamp)
          Resets the gamma ramp, potentially using the specified Buffer as data to restore the original values.
protected  boolean setGammaRamp(float[] ramp)
          Sets the gamma ramp for the main screen.
 void unlockAWTForJava2D()
          Unlocks the AWT for the purposes of Java2D/JOGL integration.
 void unlockToolkit()
           
static GLCapabilities xvi2GLCapabilities(long display, XVisualInfo info)
           
 
Methods inherited from class com.sun.opengl.impl.GLDrawableFactoryImpl
getFactoryImpl, resetDisplayGamma, setDisplayGamma
 
Methods inherited from class javax.media.opengl.GLDrawableFactory
getFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

X11GLDrawableFactory

public X11GLDrawableFactory()
Method Detail

chooseGraphicsConfiguration

public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
                                                                 GLCapabilitiesChooser chooser,
                                                                 AbstractGraphicsDevice absDevice)
Description copied from class: GLDrawableFactory

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 may return null on platforms on which the OpenGL pixel format selection process is performed later.

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 AWTGraphicsDevice objects and returns AWTGraphicsConfiguration objects.

Specified by:
chooseGraphicsConfiguration in class GLDrawableFactory
See Also:
Canvas.Canvas(java.awt.GraphicsConfiguration)

getGLDrawable

public GLDrawable getGLDrawable(java.lang.Object target,
                                GLCapabilities capabilities,
                                GLCapabilitiesChooser chooser)
Description copied from class: GLDrawableFactory
Returns a GLDrawable that wraps a platform-specific window system object, such as an AWT or LCDUI Canvas. On platforms which support it, selects a pixel format compatible with the supplied GLCapabilities, or if the passed GLCapabilities object is null, uses a default set of capabilities. On these platforms, uses either the supplied GLCapabilitiesChooser object, or if the passed GLCapabilitiesChooser object is null, uses a DefaultGLCapabilitiesChooser instance.

Specified by:
getGLDrawable in class GLDrawableFactory

createOffscreenDrawable

public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
                                              GLCapabilitiesChooser chooser)
Description copied from class: GLDrawableFactoryImpl
Creates a (typically software-accelerated) offscreen GLDrawable used to implement the fallback rendering path of the GLJPanel.

Specified by:
createOffscreenDrawable in class GLDrawableFactoryImpl

canCreateGLPbuffer

public boolean canCreateGLPbuffer()
Description copied from class: GLDrawableFactory
Returns true if it is possible to create a GLPbuffer. Some older graphics cards do not have this capability.

Specified by:
canCreateGLPbuffer in class GLDrawableFactory

createGLPbuffer

public GLPbuffer createGLPbuffer(GLCapabilities capabilities,
                                 GLCapabilitiesChooser chooser,
                                 int initialWidth,
                                 int initialHeight,
                                 GLContext shareWith)
Description copied from class: GLDrawableFactory
Creates a GLPbuffer with the given capabilites and dimensions.

See the note in the overview documentation on context sharing.

Specified by:
createGLPbuffer in class GLDrawableFactory

createExternalGLContext

public GLContext createExternalGLContext()
Description copied from class: GLDrawableFactory

Creates a GLContext object representing an existing OpenGL context in an external (third-party) OpenGL-based library. This GLContext object may be used to draw into this preexisting context using its GL and GLU objects. New contexts created through GLDrawables may share textures and display lists with this external context.

The underlying OpenGL context must be current on the current thread at the time this method is called. The user is responsible for the maintenance of the underlying OpenGL context; calls to makeCurrent and release on the returned GLContext object have no effect. If the underlying OpenGL context is destroyed, the destroy method should be called on the GLContext. A new GLContext object should be created for each newly-created underlying OpenGL context.

Specified by:
createExternalGLContext in class GLDrawableFactory

canCreateExternalGLDrawable

public boolean canCreateExternalGLDrawable()
Description copied from class: GLDrawableFactory
Returns true if it is possible to create an external GLDrawable object via GLDrawableFactory.createExternalGLDrawable().

Specified by:
canCreateExternalGLDrawable in class GLDrawableFactory

createExternalGLDrawable

public GLDrawable createExternalGLDrawable()
Description copied from class: GLDrawableFactory

Creates a GLDrawable object representing an existing OpenGL drawable in an external (third-party) OpenGL-based library. This GLDrawable object may be used to create new, fully-functional GLContexts on the OpenGL drawable. This is useful when interoperating with a third-party OpenGL-based library and it is essential to not perturb the state of the library's existing context, even to the point of not sharing textures or display lists with that context.

An underlying OpenGL context must be current on the desired drawable and the current thread at the time this method is called. The user is responsible for the maintenance of the underlying drawable. If one or more contexts are created on the drawable using GLDrawable.createContext(javax.media.opengl.GLContext), and the drawable is deleted by the third-party library, the user is responsible for calling GLContext.destroy() on these contexts.

Calls to setSize, getWidth and getHeight are illegal on the returned GLDrawable. If these operations are required by the user, they must be performed by the third-party library.

It is legal to create both an external GLContext and GLDrawable representing the same third-party OpenGL entities. This can be used, for example, to query current state information using the external GLContext and then create and set up new GLContexts using the external GLDrawable.

This functionality may not be available on all platforms and GLDrawableFactory.canCreateExternalGLDrawable() should be called first to see if it is present. For example, on X11 platforms, this API requires the presence of GLX 1.3 or later.

Specified by:
createExternalGLDrawable in class GLDrawableFactory

loadGLULibrary

public void loadGLULibrary()
Specified by:
loadGLULibrary in class GLDrawableFactoryImpl

dynamicLookupFunction

public long dynamicLookupFunction(java.lang.String glFuncName)
Description copied from class: GLDrawableFactoryImpl
Dynamically looks up the given function.

Specified by:
dynamicLookupFunction in class GLDrawableFactoryImpl

xvi2GLCapabilities

public static GLCapabilities xvi2GLCapabilities(long display,
                                                XVisualInfo info)

glCapabilities2AttribList

public static int[] glCapabilities2AttribList(GLCapabilities caps,
                                              boolean isMultisampleAvailable,
                                              boolean pbuffer,
                                              long display,
                                              int screen)

attribList2GLCapabilities

public static GLCapabilities attribList2GLCapabilities(int[] iattribs,
                                                       int niattribs,
                                                       int[] ivalues,
                                                       boolean pbuffer)

lockToolkit

public void lockToolkit()

unlockToolkit

public void unlockToolkit()

lockAWTForJava2D

public void lockAWTForJava2D()
Description copied from class: GLDrawableFactoryImpl
Locks the AWT for the purposes of Java2D/JOGL integration. This is not necessary on some platforms.

Specified by:
lockAWTForJava2D in class GLDrawableFactoryImpl

unlockAWTForJava2D

public void unlockAWTForJava2D()
Description copied from class: GLDrawableFactoryImpl
Unlocks the AWT for the purposes of Java2D/JOGL integration. This is not necessary on some platforms.

Specified by:
unlockAWTForJava2D in class GLDrawableFactoryImpl

getDisplayConnection

public static long getDisplayConnection()

isMultisampleAvailable

public static boolean isMultisampleAvailable()

glXGetConfig

public static int glXGetConfig(long display,
                               XVisualInfo info,
                               int attrib,
                               int[] tmp,
                               int tmp_offset)

getX11Factory

public static X11GLDrawableFactory getX11Factory()

isVendorATI

public static boolean isVendorATI()
Workaround for apparent issue with ATI's proprietary drivers where direct contexts still send GLX tokens for GL calls


canCreateContextOnJava2DSurface

public boolean canCreateContextOnJava2DSurface()
Specified by:
canCreateContextOnJava2DSurface in class GLDrawableFactoryImpl

createContextOnJava2DSurface

public GLContext createContextOnJava2DSurface(java.awt.Graphics g,
                                              GLContext shareWith)
                                       throws GLException
Specified by:
createContextOnJava2DSurface in class GLDrawableFactoryImpl
Throws:
GLException

isXineramaEnabled

protected boolean isXineramaEnabled()

getGammaRampLength

protected int getGammaRampLength()
Description copied from class: GLDrawableFactoryImpl
Returns the length of the computed gamma ramp for this OS and hardware. Returns 0 if gamma changes are not supported.

Overrides:
getGammaRampLength in class GLDrawableFactoryImpl

setGammaRamp

protected boolean setGammaRamp(float[] ramp)
Description copied from class: GLDrawableFactoryImpl
Sets the gamma ramp for the main screen. Returns false if gamma ramp changes were not supported.

Overrides:
setGammaRamp in class GLDrawableFactoryImpl

getGammaRamp

protected java.nio.Buffer getGammaRamp()
Description copied from class: GLDrawableFactoryImpl
Gets the current gamma ramp. This is basically an opaque value used only on some platforms to reset the gamma ramp to its original settings.

Overrides:
getGammaRamp in class GLDrawableFactoryImpl

resetGammaRamp

protected void resetGammaRamp(java.nio.Buffer originalGammaRamp)
Description copied from class: GLDrawableFactoryImpl
Resets the gamma ramp, potentially using the specified Buffer as data to restore the original values.

Overrides:
resetGammaRamp in class GLDrawableFactoryImpl


Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.