Top Inners Fields Constructors Methods
jogamp.opengl

public abstract Class GLContextImpl

extends GLContext
Class Inheritance
Known Direct Subclasses
jogamp.opengl.egl.EGLContext, jogamp.opengl.macosx.cgl.MacOSXCGLContext, jogamp.opengl.windows.wgl.WindowsWGLContext, jogamp.opengl.x11.glx.X11GLXContext
Imports
java.lang.reflect.Method, java.nio.IntBuffer, java.security.AccessController, .PrivilegedAction, java.util.HashMap, .IdentityHashMap, .Iterator, .Map, .Set, com.jogamp.common.ExceptionUtils, com.jogamp.common.os.DynamicLookupHelper, .Platform, com.jogamp.common.util.ReflectionUtil, .VersionNumber, .VersionNumberString, com.jogamp.common.util.locks.RecursiveLock, com.jogamp.gluegen.runtime.ProcAddressTable, com.jogamp.gluegen.runtime.opengl.GLNameResolver, .GLProcAddressResolver, com.jogamp.opengl.GLExtensions, .GLRendererQuirks, .GL, .GL2ES2, .GL2ES3, .GL2GL3, .GLCapabilitiesImmutable, .GLContext, .GLDebugListener, .GLDebugMessage, .GLDrawable, .GLDrawableFactory, .GLException, .GLPipelineFactory, .GLProfile, com.jogamp.nativewindow.AbstractGraphicsConfiguration, .AbstractGraphicsDevice, .NativeSurface, .NativeWindowFactory, .ProxySurface, com.jogamp.nativewindow.egl.EGLGraphicsDevice

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static interface

Field Summary

Modifier and TypeField and Description
private int
private final int[]
private final GLBufferObjectTracker
private final GLBufferStateTracker
private String
contextFQN

Context full qualified name: display_type + display_connection + major + minor + ctp.

private int
private int
protected GLDrawableImpl
drawable

  • [GLAutoDrawable.upstreamLock].lock()
  • drawable.surface.lock()
  • contextLock.lock()
protected GLDrawableImpl
protected ExtensionAvailabilityCache
protected GL
private GLDebugMessageHandler
private long
private boolean
private long
private ProcAddressTable
private String
private String
private final GLStateTracker
private String
private String
private boolean
isSurfaceless

If GL >= 3.0 (ES or desktop) and not having GLRendererQuirks#NoSurfacelessCtx, being evaluated if not surface-handle is null and not yet set at makeCurrent(..).

private Throwable
private static GLContextImpl.MappedGLVersionListener
protected static final Object
protected static final HashMap<String, ExtensionAvailabilityCache>
protected static final HashMap<String, ProcAddressTable>
protected static final HashMap<String, ProcAddressTable>
private boolean
private int
private int
Inherited from com.jogamp.opengl.GLContext:
CONTEXT_CURRENTCONTEXT_CURRENT_NEWCONTEXT_NOT_CURRENTcontextHandleCTX_IMPL_ACCEL_SOFTCTX_IMPL_CACHE_MASKCTX_IMPL_ES2_COMPATCTX_IMPL_ES31_COMPATCTX_IMPL_ES32_COMPATCTX_IMPL_ES3_COMPATCTX_IMPL_FBOCTX_IMPL_FP32_COMPAT_APICTX_IMPL_FULL_MASKCTX_IS_ARB_CREATEDCTX_OPTION_DEBUGCTX_OPTION_FORWARDCTX_PROFILE_COMPATCTX_PROFILE_CORECTX_PROFILE_ESctxGLSLVersionctxOptionsctxVendorVersionctxVersionctxVersionStringcurrentSwapGroupDEBUGDEBUG_GLDEBUG_TRACE_SWITCHdeviceVersionAvailabledrawableRetargetedES_VERSIONSFORCE_MIN_FBO_SUPPORTFORCE_NO_COLOR_RENDERBUFFERFORCE_NO_FBO_SUPPORTGL_VERSIONSglRendererQuirkslockPROFILE_ALIASINGTRACE_GLTRACE_SWITCHVersion1_0Version1_1Version1_10Version1_2Version1_20Version1_30Version1_4Version1_40Version1_5Version1_50Version3_0Version3_1Version3_2Version4_3Version8_0

Constructor Summary

AccessConstructor and Description
public
GLContextImpl(final GLDrawableImpl drawable, final GLContext shareWith)

Method Summary

Modifier and TypeMethod and Description
public final void
private static final void
addStickyQuirkAlways(final AbstractGraphicsDevice adevice, final GLRendererQuirks quirks, final int quirk, final boolean withinGLVersionsMapping)

private static final void
addStickyQuirkAtMapping(final AbstractGraphicsDevice adevice, final GLRendererQuirks quirks, final int quirk, final boolean withinGLVersionsMapping)

protected void
private final void
protected void
public final void
copy(final GLContext
the source OpenGL context from which to copy state
source
,
final int
a mask of symbolic names indicating which groups of state to copy
mask
)

Implements abstract com.jogamp.opengl.GLContext.copy.

Copies selected groups of OpenGL state variables from the supplied source context into this one.
protected abstract void
copyImpl(GLContext source, int mask)

protected final long
createContextARB(final long share, final boolean direct)

Platform independent part of using the ARB_create_context mechanism to create a context.

protected abstract long

Returns:

the valid and current context if successful, or null
createContextARBImpl
(long
the shared context or null
share
,
boolean
flag if direct is requested
direct
,
int
ARB_create_context related, see references below
ctxOptionFlags
,
int
major number
major
,
int
minor number
minor
)

Platform dependent but harmonized implementation of the ARB_create_context mechanism to create a context.

private final boolean
createContextARBMapVersionsAvailable(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile, final boolean hasMinorVersionSupport)

Note

Since context creation is temporary, caller need to issue resetStates(boolean), if creation was successful, i.e. returns true.

private final long
createContextARBVersions(final long share, final boolean direct, final int ctxOptionFlags, final int maxMajor, final int maxMinor, final int minMajor, final int minMinor, final int[] major, final int[] minor)

private final GL
createGL(final AbstractGraphicsDevice adevice, final int majorVersion, final int minorVersion, final int contextOption)

Create the GL instance for this context, requires valid getGLProcAddressTable() result!

protected abstract boolean

Returns:

true if successful. Method returns false if the context creation failed non fatally, hence it may be created at a later time. Otherwise method throws GLException.
createImpl
(long
the shared context handle or 0
sharedWithHandle
)

Platform dependent entry point for context creation.

private final Object
createInstance(final AbstractGraphicsDevice adevice, final int majorVersion, final int minorVersion, final int contextOption, final boolean glObject, final Object[] cstrArgs)

public final void
destroy()

Implements abstract com.jogamp.opengl.GLContext.destroy.

Destroys this OpenGL context and frees its associated resources.
protected abstract void
destroyContextARBImpl(long context)

Destroy the context created by createContextARBImpl.

protected abstract void
protected void
drawableUpdatedNotify()

Call this method to notify the OpenGL context that the drawable has changed (size or position).

public final void
enableGLDebugMessage(final boolean
If true enables, otherwise disables the GLDebugOutput feature.
enable
)

Implements abstract com.jogamp.opengl.GLContext.enableGLDebugMessage.

Enables or disables the GLDebugOutput feature of extension GLExtensions#ARB_debug_output or GLExtensions#AMD_debug_output, if available.
private final void
private void
finalizeInit(final GL gl)

Finalizes GL instance initialization after this context has been initialized.

public final int
getBoundFramebuffer(final int target)

Implements abstract com.jogamp.opengl.GLContext.getBoundFramebuffer.

Return the framebuffer name bound to this context, see GL#glBindFramebuffer(int, int).
public final GLBufferObjectTracker
public final GLBufferStateTracker
public final int
protected static String
getContextFQN(final AbstractGraphicsDevice device, final int major, final int minor, int ctxProfileBits)

protected final String
protected final String
protected final int
public final int
getDefaultDrawFramebuffer()

Implements abstract com.jogamp.opengl.GLContext.getDefaultDrawFramebuffer.

Return the default draw framebuffer name.
public int
public int
public final int
getDefaultReadBuffer()

Implements abstract com.jogamp.opengl.GLContext.getDefaultReadBuffer.

Returns the default color buffer within the current bound getDefaultReadFramebuffer(), i.e. GL_READ_FRAMEBUFFER​, which will be used as the source for pixel reading commands, like glReadPixels etc.

For offscreen framebuffer objects this is GL#GL_COLOR_ATTACHMENT0, otherwise this is GL#GL_FRONT for single buffer configurations and GL#GL_BACK for double buffer configurations.

public final int
getDefaultReadFramebuffer()

Implements abstract com.jogamp.opengl.GLContext.getDefaultReadFramebuffer.

Return the default read framebuffer name.
public final int
getDefaultVAO()

Implements abstract com.jogamp.opengl.GLContext.getDefaultVAO.

If this GLContext does not implement a default VAO, see hasNoDefaultVAO(), an own default VAO will be created and bound at context creation.
public final GLDrawableImpl
protected abstract Map<String, String>
protected abstract Map<String, String>
public final GL
getGL()

Implements abstract com.jogamp.opengl.GLContext.getGL.

Returns the GL pipeline object for this GLContext.
public final String
public final GLDrawable
getGLDrawable()

Implements abstract com.jogamp.opengl.GLContext.getGLDrawable.

Returns the write-drawable this context uses for framebuffer operations.
public final GLDynamicLookupHelper
getGLDynamicLookupHelper()

Returns the DynamicLookupHelper

public final GLDynamicLookupHelper
getGLDynamicLookupHelper(final int majorVersion, final int contextOptions)

public final int
getGLExtensionCount()

Implements abstract com.jogamp.opengl.GLContext.getGLExtensionCount.

Returns the number of OpenGL extensions
public final String
getGLExtensionsString()

Implements abstract com.jogamp.opengl.GLContext.getGLExtensionsString.

Returns a non-null (but possibly empty) string containing the space-separated list of available extensions.
private final void
getGLIntVersion(final int[] glIntMajor, final int[] glIntMinor)

Returns false if glGetIntegerv is inaccessible, otherwise queries major.minor version for given arrays.

public final ProcAddressTable
public final GLDrawable
getGLReadDrawable()

Implements abstract com.jogamp.opengl.GLContext.getGLReadDrawable.

Returns the read-Drawable this context uses for read framebuffer operations.
public final GLStateTracker
private static final VersionNumber
getGLVersionNumber(final int ctp, final String glVersionStr)

Returns null if version string is invalid, otherwise a valid instance.

public final int
getLockCount()

Returns the number of hold locks.

private final GLContextImpl
public final int
getPlatformExtensionCount()

Implements abstract com.jogamp.opengl.GLContext.getPlatformExtensionCount.

Returns the number of platform extensions
public final String
getPlatformExtensionsString()

Implements abstract com.jogamp.opengl.GLContext.getPlatformExtensionsString.

Returns a non-null (but possibly empty) string containing the space-separated list of available platform-dependent (e.g., WGL, GLX) extensions.
protected abstract StringBuilder
public abstract ProcAddressTable
getPlatformExtProcAddressTable()

Shall return the platform extension ProcAddressTable, ie for GLXExt, EGLExt, ..

public abstract Object
public final GL
getRootGL()

Implements abstract com.jogamp.opengl.GLContext.getRootGL.

Returns the implementing root GL instance of this GLContext's GL object, considering a wrapped pipelined hierarchy, see GLBase#getDownstreamGL().
public final int
getSwapInterval()

Overrides com.jogamp.opengl.GLContext.getSwapInterval.

Return the current swap interval.
private String
public final void
glDebugMessageControl(final int source, final int type, final int severity, final int count, final IntBuffer ids, final boolean enabled)

Implements abstract com.jogamp.opengl.GLContext.glDebugMessageControl.

Generic entry for GL2GL3#glDebugMessageControl(int, int, int, int, IntBuffer, boolean) and GL2GL3#glDebugMessageEnableAMD(int, int, int, IntBuffer, boolean) of the GLDebugOutput feature.
public final void
glDebugMessageControl(final int source, final int type, final int severity, final int count, final int[] ids, final int ids_offset, final boolean enabled)

Implements abstract com.jogamp.opengl.GLContext.glDebugMessageControl.

Generic entry for GL2GL3#glDebugMessageControl(int, int, int, int, int[], int, boolean) and GL2GL3#glDebugMessageEnableAMD(int, int, int, int[], int, boolean) of the GLDebugOutput feature.
public final void
glDebugMessageInsert(final int source, final int type, final int id, final int severity, final String buf)

Implements abstract com.jogamp.opengl.GLContext.glDebugMessageInsert.

Generic entry for GL2GL3#glDebugMessageInsert(int, int, int, int, int, String) and GL2GL3#glDebugMessageInsertAMD(int, int, int, int, String) of the GLDebugOutput feature.
private static native void
glGetIntegervInt(int pname, int[] params, int params_offset, long procAddress)

Internal bootstraping glGetIntegerv(..) for version

private static native String
glGetStringInt(int name, long procAddress)

Internal bootstraping glGetString(GL_RENDERER)

private static final boolean
hasFBOImpl(final int major, final int ctp, final ExtensionAvailabilityCache extCache)

public final boolean
hasWaiters()

Returns true if there are other threads waiting for this GLContext to makeCurrent(), otherwise false.

private final boolean
initGLRendererAndGLVersionStrings(final int majorVersion, final int contextOptions)

protected final boolean
private final boolean
public final boolean
isExtensionAvailable(final String
the name of the OpenGL extension (e.g., "GL_VERTEX_PROGRAM_ARB").
glExtensionName
)

Implements abstract com.jogamp.opengl.GLContext.isExtensionAvailable.

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.
public final boolean
public final boolean
isFunctionAvailable(final String
the name of the OpenGL function (e.g., use "glPolygonOffsetEXT" or "glPolygonOffset" to check if the com.jogamp.opengl.GL#glPolygonOffset(float, float) is available).
glFunctionName
)

Implements abstract com.jogamp.opengl.GLContext.isFunctionAvailable.

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.
public final boolean
public final boolean
public final boolean
isOwner(final Thread thread)

Returns true if the given thread is owner, otherwise false.

protected final boolean
public final int
makeCurrent()

Implements abstract com.jogamp.opengl.GLContext.makeCurrent.

Makes this GLContext current on the calling thread.
protected final int
makeCurrent(boolean forceDrawableAssociation)

protected abstract void
private final int
makeCurrentWithinLock(final int surfaceLockRes)

protected static GLContextImpl.MappedGLVersion

Returns:

the old mapped value
mapAvailableGLVersion
(final AbstractGraphicsDevice device, final int
Key Value either 1, 2, 3 or 4
reqMajor
,
final int profile, final VersionNumber
the resulting version number
resVersion
,
final int
the resulting context options
resCtp
,
final GLRendererQuirks resQuirks)

Called by jogamp.opengl.GLContextImpl#createContextARBMapVersionsAvailable(int, int) not intended to be used by implementations.

private final boolean
protected final String
mapToRealGLExtensionName(final String glExtensionName)

Maps the given "platform-independent" extension name to a real function name.

protected final String
mapToRealGLFunctionName(final String glFunctionName)

Maps the given "platform-independent" function name to a real function name.

public void
release()

Implements abstract com.jogamp.opengl.GLContext.release.

Releases control of this GLContext from the current thread.
private void
release(final boolean inDestruction)

protected abstract void
protected static void
private final void
removeCachedVersion(final int major, final int minor, int ctxProfileBits)

public final void
protected final void
resetProcAddressTable(final ProcAddressTable table, final GLDynamicLookupHelper dlh)

Helper routine which resets a ProcAddressTable generated by the GLEmitter by looking up anew all of its function pointers using the given GLDynamicLookupHelper.

protected void
resetStates(final boolean
true if called for class initialization, otherwise false (re-init or destruction).
isInit
)

Overrides com.jogamp.opengl.GLContext.resetStates.

public final void
setBoundFramebuffer(final int target, final int framebufferName)

Tracks GL#GL_FRAMEBUFFER, GL2GL3#GL_DRAW_FRAMEBUFFER and GL2GL3#GL_READ_FRAMEBUFFER to be returned via getBoundFramebuffer(int).

public final void
setContextCreationFlags(final int
Additional context creation flags, supported: GLContext#CTX_OPTION_DEBUG. Unsupported flags are masked out. Only affects this context state if not created yet via makeCurrent().
flags
)

Implements abstract com.jogamp.opengl.GLContext.setContextCreationFlags.

private final void
setContextVersion(final int major, final int minor, final int ctp, final VersionNumberString glVendorVersion, final boolean useGL)

If major > 0 || minor > 0 : Use passed values, determined at creation time Otherwise ..

protected final void
public GL
setGL(final GL gl)

Implements abstract com.jogamp.opengl.GLContext.setGL.

Sets the GL pipeline object for this GLContext.
public final void
setGLDebugSynchronous(final boolean synchronous)

Implements abstract com.jogamp.opengl.GLContext.setGLDebugSynchronous.

Enables or disables the synchronous debug behavior via glEnable/glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS), if extension is GLExtensions#ARB_debug_output.
public final GLDrawable
setGLDrawable(final GLDrawable
The read/write drawable for framebuffer operations, maybe null to remove association.
readWrite
,
final boolean
Only change the write-drawable, if setWriteOnly is true and if the read-drawable differs from the write-drawable. Otherwise set both drawables, read and write.
setWriteOnly
)

Implements abstract com.jogamp.opengl.GLContext.setGLDrawable.

Sets the read/write drawable for framebuffer operations, i.e. reassociation of the context's drawable.
protected final boolean

Returns:

returns true if successful, otherwise false.
If strictMatch is false method shall always return true or throw an exception. If false is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc.
setGLFunctionAvailability
(final boolean
force the setting, even if is already being set. This might be useful if you change the OpenGL implementation.
force
,
int
requested OpenGL major version
major
,
int
requested OpenGL minor version
minor
,
int
OpenGL context profile and option bits, see com.jogamp.opengl.GLContext#CTX_OPTION_ANY
ctxProfileBits
,
final boolean
if true the ctx must
  • be greater or equal than the requested major.minor version, and
  • match the ctxProfileBits
  • match ES major versions
, otherwise method aborts and returns false.
if false no version check is performed.
strictMatch
,
final boolean
if true GL version mapping is in process, i.e. querying avail versions. Otherwise normal user context creation.
withinGLVersionsMapping
)

Sets the OpenGL implementation class and the cache of which GL functions are available for calling through this context.

public final GLDrawable
setGLReadDrawable(final GLDrawable
the read-drawable for read framebuffer operations. If null is passed, the default write drawable will be set.
read
)

Implements abstract com.jogamp.opengl.GLContext.setGLReadDrawable.

Set the read-Drawable for read framebuffer operations.
protected static synchronized void
private final void
setRendererQuirks(final AbstractGraphicsDevice adevice, final GLDrawableFactoryImpl factory, final int reqMajor, final int reqMinor, final int reqCTP, final int major, final int minor, final int ctp, final VersionNumberString vendorVersion, final boolean withinGLVersionsMapping)

public final boolean
setSwapInterval(final int
see above
interval
)

Overrides com.jogamp.opengl.GLContext.setSwapInterval.

Set the swap interval of the current context and attached onscreen GLDrawable.
protected abstract Integer
setSwapIntervalImpl2(final int interval)

protected final boolean
setSwapIntervalNC(final int interval)

public static void
protected abstract void
updateGLXProcAddressTable(final String
provides a fully qualified key of the context including device and GL profile
contextFQN
,
final GLDynamicLookupHelper dlh)

Updates the platform's 'GLX' function cache

private final boolean
verifyInstance(final GLProfile glp, final String suffix, final Object instance)

private final boolean
verifyInstance(final AbstractGraphicsDevice adevice, final int majorVersion, final int minorVersion, final int contextOption, final String suffix, final Object instance)

Inherited from com.jogamp.opengl.GLContext:
appendattachObjectbindSwapBarrierbindSwapBarrierImplclipGLVersioncomposeBitsdecomposeBitsdecrementGLVersiondetachObjectdumpAvailableGLVersionsgetAttachedObjectgetAvailableContextPropertiesgetAvailableGLProfilegetAvailableGLVersiongetAvailableGLVersiongetAvailableGLVersionAsStringgetAvailableGLVersionsSetgetCreatedSharesgetCurrentgetCurrentGLgetDestroyedSharesgetDeviceVersionAvailableKeygetGLProfilegetGLProfilegetGLSLVersionNumbergetGLSLVersionStringgetGLVendorVersionNumbergetGLVersiongetGLVersiongetGLVersiongetGLVersiongetGLVersionNumbergetHandlegetMaxMajorgetMaxMinorgetMaxRenderbufferSamplesgetRendererQuirksgetRequestMajorAndCompatgetSharedMastergetStaticGLSLVersionNumbergetSwapGroupgetThreadNamehasBasicFBOSupporthasFP32CompatAPIhasFullFBOSupporthasGLSLhasNoDefaultVAOhasRendererQuirkisCPUDataSourcingAvailisCreatedisCreatedWithARBMethodisCurrentisFBOAvailableisGL2isGL2AvailableisGL2ES1isGL2ES2isGL2ES3isGL2GL3isGL3isGL3AvailableisGL3bcisGL3bcAvailableisGL3coreisGL3ES3isGL4isGL4AvailableisGL4bcisGL4bcAvailableisGL4coreisGL4ES3isGLCompatibilityProfileisGLcoreisGLCoreProfileisGLDebugEnabledisGLESisGLES1isGLES1AvailableisGLES2isGLES2AvailableisGLES2CompatibleisGLES3isGLES31CompatibleisGLES31CompatibleAvailableisGLES32CompatibleisGLES32CompatibleAvailableisGLES3AvailableisGLES3CompatibleisGLES3CompatibleAvailableisGLESProfileisGLForwardCompatibleisGLReadDrawableAvailableisGLVersionAvailableisHardwareRasterizerisHardwareRasterizerisNPOTTextureAvailableisSharedisTextureFormatBGRA8888AvailableisValidGLVersionjoinSwapGroupjoinSwapGroupImplmakeCurrentResultToStringmapAvailableGLVersionqueryMaxSwapGroupsqueryMaxSwapGroupsImplsetAvailableGLVersionsSetsetCurrentsetSwapIntervalImplshutdowntoHexStringtoHexStringtoStringvalidateCurrent