com.sun.opengl.impl

Class Java2D


public class Java2D
extends Object

Defines integration with the Java2D OpenGL pipeline. This integration is only supported in 1.6 and is highly experimental.

Field Summary

static int
FBOBJECT
static int
FLIP_BACKBUFFER
static int
PBUFFER
static int
TEXTURE
static int
UNDEFINED
static int
WINDOW

Method Summary

static GLContext
filterShareContext(GLContext shareContext)
Returns either the given GLContext or a substitute one with which clients should share textures and display lists.
static Rectangle
getOGLScissorBox(Graphics g)
Returns the OpenGL scissor region associated with the given Graphics object, taking into account all clipping regions, etc.
static Object
getOGLSurfaceIdentifier(Graphics g)
Returns an opaque "surface identifier" associated with the given Graphics object.
static int
getOGLSurfaceType(Graphics g)
Returns the underlying surface type for the given Graphics object.
static Rectangle
getOGLViewport(Graphics g, int componentWidth, int componentHeight)
Returns the OpenGL viewport associated with the given Graphics object, assuming that the Graphics object is associated with a component of the specified width and height.
static GLContext
getShareContext(GraphicsConfiguration gc)
Returns the GLContext associated with the Java2D "share context", with which all contexts created by JOGL must share textures and display lists when the FBO option is enabled for the Java2D/OpenGL pipeline.
static void
invokeWithOGLContextCurrent(Graphics g, Runnable r)
Makes current the OpenGL context associated with the passed Graphics object and runs the given Runnable on the Queue Flushing Thread in one atomic action.
static boolean
invokeWithOGLSharedContextCurrent(GraphicsConfiguration g, Runnable r)
Makes current the "shared" OpenGL context associated with the given GraphicsConfiguration object, allowing JOGL to share server-side OpenGL objects like textures and display lists with this context when necessary.
static boolean
isFBOEnabled()
static boolean
isOGLPipelineActive()
static boolean
isQueueFlusherThread()

Field Details

FBOBJECT

public static final int FBOBJECT

FLIP_BACKBUFFER

public static final int FLIP_BACKBUFFER

PBUFFER

public static final int PBUFFER

TEXTURE

public static final int TEXTURE

UNDEFINED

public static final int UNDEFINED

WINDOW

public static final int WINDOW

Method Details

filterShareContext

public static GLContext filterShareContext(GLContext shareContext)
Returns either the given GLContext or a substitute one with which clients should share textures and display lists. Needed when the Java2D/OpenGL pipeline is active and FBOs are being used for rendering. FIXME: may need to alter the API in the future to indicate which GraphicsDevice the source context is associated with.

getOGLScissorBox

public static Rectangle getOGLScissorBox(Graphics g)
Returns the OpenGL scissor region associated with the given Graphics object, taking into account all clipping regions, etc. To avoid destroying Java2D's previous rendering results, this method should be called and the resulting rectangle's bounds passed to a call to glScissor(). Should only be called from the Queue Flusher Thread.

getOGLSurfaceIdentifier

public static Object getOGLSurfaceIdentifier(Graphics g)
Returns an opaque "surface identifier" associated with the given Graphics object. If this changes from invocation to invocation, the underlying OpenGL drawable for the Graphics object has changed and a new external GLDrawable and GLContext should be created (and the old ones destroyed). Should only be called from the Queue Flusher Thread.

getOGLSurfaceType

public static int getOGLSurfaceType(Graphics g)
Returns the underlying surface type for the given Graphics object. This indicates, in particular, whether Java2D is currently rendering into a pbuffer or FBO.

getOGLViewport

public static Rectangle getOGLViewport(Graphics g,
                                       int componentWidth,
                                       int componentHeight)
Returns the OpenGL viewport associated with the given Graphics object, assuming that the Graphics object is associated with a component of the specified width and height. The user should call glViewport() with the returned rectangle's bounds in order to get correct rendering results. Should only be called from the Queue Flusher Thread.

getShareContext

public static GLContext getShareContext(GraphicsConfiguration gc)
Returns the GLContext associated with the Java2D "share context", with which all contexts created by JOGL must share textures and display lists when the FBO option is enabled for the Java2D/OpenGL pipeline.

invokeWithOGLContextCurrent

public static void invokeWithOGLContextCurrent(Graphics g,
                                               Runnable r)
            throws GLException
Makes current the OpenGL context associated with the passed Graphics object and runs the given Runnable on the Queue Flushing Thread in one atomic action.

invokeWithOGLSharedContextCurrent

public static boolean invokeWithOGLSharedContextCurrent(GraphicsConfiguration g,
                                                        Runnable r)
            throws GLException
Makes current the "shared" OpenGL context associated with the given GraphicsConfiguration object, allowing JOGL to share server-side OpenGL objects like textures and display lists with this context when necessary. This is needed when Java2D's FBO support is enabled, because in order to render into that FBO, JOGL must share textures and display lists with it. Returns false if the passed GraphicsConfiguration was not an OpenGL GraphicsConfiguration.

isFBOEnabled

public static boolean isFBOEnabled()

isOGLPipelineActive

public static boolean isOGLPipelineActive()

isQueueFlusherThread

public static boolean isQueueFlusherThread()

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