com.sun.opengl.impl

Class GLContextImpl

Known Direct Subclasses:
X11GLContext

public abstract class GLContextImpl
extends GLContext

Field Summary

protected static boolean
DEBUG
protected static boolean
NO_FREE
protected static boolean
VERBOSE
protected FunctionAvailabilityCache
functionAvailability
protected GL
gl
protected GLContextLock
lock
protected boolean
optimizationEnabled

Fields inherited from class javax.media.opengl.GLContext

CONTEXT_CURRENT, CONTEXT_CURRENT_NEW, CONTEXT_NOT_CURRENT

Constructor Summary

GLContextImpl(GLContext shareWith)
GLContextImpl(GLContext shareWith, boolean dontShareWithJava2D)

Method Summary

abstract void
bindPbufferToTexture()
Pbuffer support; given that this is a GLContext associated with a pbuffer, binds this pbuffer to its texture target.
protected GL
createGL()
Create the GL for this context.
void
destroy()
Destroys this OpenGL context and frees its associated resources.
protected abstract void
destroyImpl()
GLObjectTracker
getDeletedObjectTracker()
int
getFloatingPointMode()
Indicates which floating-point pbuffer implementation is in use.
GL
getGL()
Returns the GL pipeline object for this GLContext.
GLProcAddressTable
getGLProcAddressTable()
GLObjectTracker
getObjectTracker()
abstract int
getOffscreenContextPixelDataType()
Only called for offscreen contexts; needed by glReadPixels
abstract String
getPlatformExtensionsString()
Returns a non-null (but possibly empty) string containing the space-separated list of available platform-dependent (e.g., WGL, GLX) extensions.
abstract Object
getPlatformGLExtensions()
protected static String
getThreadName()
abstract ByteBuffer
glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3)
boolean
hasWaiters()
abstract boolean
isCreated()
Indicates whether the underlying OpenGL context has been created.
boolean
isExtensionAvailable(String glExtensionName)
Returns true if the specified OpenGL extension can be successfully called using this GL context given the current host (OpenGL client) and display (OpenGL server) configuration.
protected boolean
isFunctionAvailable(String glFunctionName)
Returns true if the specified OpenGL core- or extension-function can be successfully called using this GL context given the current host (OpenGL client) and display (OpenGL server) configuration.
boolean
isOptimizable()
boolean
isSynchronized()
Returns true if 'makeCurrent' will exhibit synchronized behavior.
int
makeCurrent()
Makes this GLContext current on the calling thread.
protected abstract int
makeCurrentImpl()
protected abstract String
mapToRealGLExtensionName(String glExtensionName)
Maps the given "platform-independent" extension name to a real function name.
protected abstract String
mapToRealGLFunctionName(String glFunctionName)
Maps the given "platform-independent" function name to a real function name.
abstract boolean
offscreenImageNeedsVerticalFlip()
On some platforms the mismatch between OpenGL's coordinate system (origin at bottom left) and the window system's coordinate system (origin at top left) necessitates a vertical flip of pixels read from offscreen contexts.
void
release()
Releases control of this GLContext from the current thread.
protected abstract void
releaseImpl()
abstract void
releasePbufferFromTexture()
Pbuffer support; given that this is a GLContext associated with a pbuffer, releases this pbuffer from its texture target.
protected void
resetGLFunctionAvailability()
Resets the cache of which GL functions are available for calling through this context.
protected void
resetProcAddressTable(Object table)
Helper routine which resets a ProcAddressTable generated by the GLEmitter by looking up anew all of its function pointers.
void
setDeletedObjectTracker(GLObjectTracker deletedObjectTracker)
void
setGL(GL gl)
Sets the GL pipeline object for this GLContext.
void
setObjectTracker(GLObjectTracker tracker)
void
setSwapInterval(int interval)
void
setSynchronized(boolean isSynchronized)
Determines whether 'makeCurrent' will exhibit synchronized behavior.
static String
toHexString(long hex)
protected void
update()

Methods inherited from class javax.media.opengl.GLContext

destroy, getCurrent, getGL, getGLDrawable, isSynchronized, makeCurrent, release, setCurrent, setGL, setSynchronized

Field Details

DEBUG

protected static final boolean DEBUG

NO_FREE

protected static final boolean NO_FREE

VERBOSE

protected static final boolean VERBOSE

functionAvailability

protected FunctionAvailabilityCache functionAvailability

gl

protected GL gl

lock

protected GLContextLock lock

optimizationEnabled

protected boolean optimizationEnabled

Constructor Details

GLContextImpl

public GLContextImpl(GLContext shareWith)

GLContextImpl

public GLContextImpl(GLContext shareWith,
                     boolean dontShareWithJava2D)

Method Details

bindPbufferToTexture

public abstract void bindPbufferToTexture()
Pbuffer support; given that this is a GLContext associated with a pbuffer, binds this pbuffer to its texture target.

createGL

protected GL createGL()
Create the GL for this context.

destroy

public void destroy()
Destroys this OpenGL context and frees its associated resources. The context should have been released before this method is called.
Overrides:
destroy in interface GLContext

destroyImpl

protected abstract void destroyImpl()
            throws GLException

getDeletedObjectTracker

public GLObjectTracker getDeletedObjectTracker()

getFloatingPointMode

public int getFloatingPointMode()
            throws GLException
Indicates which floating-point pbuffer implementation is in use. Returns one of GLPbuffer.APPLE_FLOAT, GLPbuffer.ATI_FLOAT, or GLPbuffer.NV_FLOAT.

getGL

public GL getGL()
Returns the GL pipeline object for this GLContext.
Overrides:
getGL in interface GLContext

getGLProcAddressTable

public GLProcAddressTable getGLProcAddressTable()

getObjectTracker

public GLObjectTracker getObjectTracker()

getOffscreenContextPixelDataType

public abstract int getOffscreenContextPixelDataType()
Only called for offscreen contexts; needed by glReadPixels

getPlatformExtensionsString

public abstract String getPlatformExtensionsString()
Returns a non-null (but possibly empty) string containing the space-separated list of available platform-dependent (e.g., WGL, GLX) extensions. Can only be called while this context is current.

getPlatformGLExtensions

public abstract Object getPlatformGLExtensions()

getThreadName

protected static String getThreadName()

glAllocateMemoryNV

public abstract ByteBuffer glAllocateMemoryNV(int arg0,
                                              float arg1,
                                              float arg2,
                                              float arg3)

hasWaiters

public boolean hasWaiters()

isCreated

public abstract boolean isCreated()
Indicates whether the underlying OpenGL context has been created. This is used to manage sharing of display lists and textures between contexts.

isExtensionAvailable

public boolean isExtensionAvailable(String glExtensionName)
Parameters:
glExtensionName - the name of the OpenGL extension (e.g., "GL_VERTEX_PROGRAM_ARB").

isFunctionAvailable

protected boolean isFunctionAvailable(String glFunctionName)
Parameters:
glFunctionName - the name of the OpenGL function (e.g., use "glPolygonOffsetEXT" to check if the javax.media.opengl.GL.glPolygonOffsetEXT(float,float) is available).

isOptimizable

public boolean isOptimizable()

isSynchronized

public boolean isSynchronized()
Returns true if 'makeCurrent' will exhibit synchronized behavior.
Overrides:
isSynchronized in interface GLContext

makeCurrent

public int makeCurrent()
            throws GLException
Makes this GLContext current on the calling thread. There are two return values that indicate success and one that indicates failure. A return value of CONTEXT_CURRENT_NEW indicates that that context has been made current, and that this is the first time this context has been made current, or that the state of the underlying context or drawable may have changed since the last time this context was made current. In this case, the application may wish to initialize the state. A return value of CONTEXT_CURRENT indicates that the context has been made currrent, with its previous state restored. If the context could not be made current (for example, because the underlying drawable has not ben realized on the display) , a value of CONTEXT_NOT_CURRENT is returned. If the context is in use by another thread at the time of the call, then if isSynchronized() is true the call will block. If isSynchronized() is false, an exception will be thrown and the context will remain current on the other thread.
Overrides:
makeCurrent in interface GLContext
Returns:
CONTEXT_CURRENT if the context was successfully made current
Throws:
GLException - if synchronization is disabled and the context is current on another thread, or because the context could not be created or made current due to non-recoverable, window system-specific errors.

makeCurrentImpl

protected abstract int makeCurrentImpl()
            throws GLException

mapToRealGLExtensionName

protected abstract String mapToRealGLExtensionName(String glExtensionName)
Maps the given "platform-independent" extension name to a real function name. Currently this is only used to map "GL_ARB_pbuffer" and "GL_ARB_pixel_format" to "WGL_ARB_pbuffer" and "WGL_ARB_pixel_format" (not yet mapped to X11).

mapToRealGLFunctionName

protected abstract String mapToRealGLFunctionName(String glFunctionName)
Maps the given "platform-independent" function name to a real function name. Currently this is only used to map "glAllocateMemoryNV" and associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV.

offscreenImageNeedsVerticalFlip

public abstract boolean offscreenImageNeedsVerticalFlip()
On some platforms the mismatch between OpenGL's coordinate system (origin at bottom left) and the window system's coordinate system (origin at top left) necessitates a vertical flip of pixels read from offscreen contexts.

release

public void release()
            throws GLException
Releases control of this GLContext from the current thread.
Overrides:
release in interface GLContext
Throws:
GLException - if the context had not previously been made current on the current thread

releaseImpl

protected abstract void releaseImpl()
            throws GLException

releasePbufferFromTexture

public abstract void releasePbufferFromTexture()
Pbuffer support; given that this is a GLContext associated with a pbuffer, releases this pbuffer from its texture target.

resetGLFunctionAvailability

protected void resetGLFunctionAvailability()

resetProcAddressTable

protected void resetProcAddressTable(Object table)
Helper routine which resets a ProcAddressTable generated by the GLEmitter by looking up anew all of its function pointers.

setDeletedObjectTracker

public void setDeletedObjectTracker(GLObjectTracker deletedObjectTracker)

setGL

public void setGL(GL gl)
Sets the GL pipeline object for this GLContext.
Overrides:
setGL in interface GLContext

setObjectTracker

public void setObjectTracker(GLObjectTracker tracker)

setSwapInterval

public void setSwapInterval(int interval)

setSynchronized

public void setSynchronized(boolean isSynchronized)
Determines whether 'makeCurrent' will exhibit synchronized behavior.
Overrides:
setSynchronized in interface GLContext

toHexString

public static String toHexString(long hex)

update

protected void update()
            throws GLException

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