Top Description Inners Fields Constructors Methods
org.lwjgl.opengl

public final Class GL

extends Object
Class Inheritance
Imports
org.lwjgl.*, org.lwjgl.system.*, org.lwjgl.system.macosx.*, org.lwjgl.system.windows.*, javax.annotation.*, java.nio.*, java.util.*, java.util.function.*

This class must be used before any OpenGL function is called. It has the following responsibilities:

Library lifecycle

The OpenGL library is loaded automatically when this class is initialized. Set the Configuration#OPENGL_EXPLICIT_INIT option to override this behavior. Manual loading/unloading can be achieved with the create and destroy functions. The name of the library loaded can be overridden with the Configuration#OPENGL_LIBRARY_NAME option. The maximum OpenGL version loaded can be set with the Configuration#OPENGL_MAXVERSION option. This can be useful to ensure that no functionality above a specific version is used during development.

GLCapabilities creation

Instances of GLCapabilities can be created with the createCapabilities method. An OpenGL context must be current in the current thread before it is called. Calling this method is expensive, so the GLCapabilities instance should be associated with the OpenGL context and reused as necessary.

Thread-local state

Before a function for a given OpenGL context can be called, the corresponding GLCapabilities instance must be passed to the setCapabilities method. The user is also responsible for clearing the current GLCapabilities instance when the context is destroyed or made current in another thread.

Note that the createCapabilities method implicitly calls setCapabilities with the newly created instance.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
GL.ICD

Function pointer provider.

private static class
GL.ICDStatic

Write-once ICD.

Field Summary

Modifier and TypeField and Description
private static GLXCapabilities
private static GLXCapabilities
private static final ThreadLocal<GLCapabilities>
private static WGLCapabilities
private static FunctionProvider
private static GL.ICD
private static final APIUtil.APIVersion

Constructor Summary

AccessConstructor and Description
private
GL()

Method Summary

Modifier and TypeMethod and Description
private static GLCapabilities
public static void
create()

Loads the OpenGL native library, using the default library name.

public static void
create(String
the native library name
libName
)

Loads the OpenGL native library, using the specified library name.

private static void
public static void
create(FunctionProvider
the provider of OpenGL function addresses
functionProvider
)

Initializes OpenGL with the specified FunctionProvider.

public static GLCapabilities

Returns:

the GLCapabilities instance
createCapabilities
()

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

public static GLCapabilities

Returns:

the GLCapabilities instance
createCapabilities
(IntFunction<PointerBuffer>
a function that allocates a PointerBuffer given a size. The buffer must be filled with zeroes. If null, LWJGL will allocate a GC-managed buffer internally.
bufferFactory
)

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

public static GLCapabilities

Returns:

the GLCapabilities instance
createCapabilities
(boolean
if true, LWJGL will create forward compatible capabilities
forwardCompatible
)

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

public static GLCapabilities

Returns:

the GLCapabilities instance
createCapabilities
(boolean
if true, LWJGL will create forward compatible capabilities
forwardCompatible
,
IntFunction<PointerBuffer>
a function that allocates a PointerBuffer given a size. If null, LWJGL will allocate a GC-managed buffer internally.
bufferFactory
)

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

public static GLXCapabilities
createCapabilitiesGLX(long
the X connection handle (DISPLAY)
display
)

Creates a GLXCapabilities instance for the default screen of the specified X connection.

public static GLXCapabilities
createCapabilitiesGLX(long
the X connection handle (DISPLAY)
display
,
int
the screen index
screen
)

Creates a GLXCapabilities instance for the specified screen of the specified X connection.

public static WGLCapabilities
createCapabilitiesWGL()

Creates a WGLCapabilities instance for the context that is current in the current thread.

private static WGLCapabilities
createCapabilitiesWGL(long
the device context handle (HDC)
hdc
)

Creates a WGLCapabilities instance for the specified device context.

private static WGLCapabilities
createCapabilitiesWGLDummy()

Creates a dummy context and retrieves the WGL capabilities.

public static void
destroy()

Unloads the OpenGL native library.

public static GLCapabilities
getCapabilities()

Returns the GLCapabilities of the OpenGL context that is current in the current thread.

public static GLXCapabilities
getCapabilitiesGLX()

Returns the GLX capabilities.

pack-priv static GLXCapabilities
getCapabilitiesGLXClient()

Returns the GLX client capabilities.

public static WGLCapabilities
getCapabilitiesWGL()

Returns the WGL capabilities.

public static FunctionProvider
getFunctionProvider()

Returns the FunctionProvider for the OpenGL native library.

pack-priv static GLCapabilities
private static GLXCapabilities
initCapabilitiesGLX(boolean client)

pack-priv static void
initialize()

Ensures that the lwjgl_opengl shared library has been loaded.

public static void
setCapabilities(GLCapabilities caps)

Sets the GLCapabilities of the OpenGL context that is current in the current thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

capabilitiesGLXback to summary
private static GLXCapabilities capabilitiesGLX
Annotations
@Nullable
capabilitiesGLXClientback to summary
private static GLXCapabilities capabilitiesGLXClient
Annotations
@Nullable
capabilitiesTLSback to summary
private static final ThreadLocal<GLCapabilities> capabilitiesTLS
capabilitiesWGLback to summary
private static WGLCapabilities capabilitiesWGL
Annotations
@Nullable
functionProviderback to summary
private static FunctionProvider functionProvider
Annotations
@Nullable
icdback to summary
private static GL.ICD icd
MAX_VERSIONback to summary
private static final APIUtil.APIVersion MAX_VERSION
Annotations
@Nullable

Constructor Detail

GLback to summary
private GL()

Method Detail

checkCapabilitiesback to summary
private static GLCapabilities checkCapabilities(GLCapabilities caps)
createback to summary
public static void create()

Loads the OpenGL native library, using the default library name.

createback to summary
public static void create(String libName)

Loads the OpenGL native library, using the specified library name.

Parameters
libName:String

the native library name

createback to summary
private static void create(SharedLibrary OPENGL)
createback to summary
public static void create(FunctionProvider functionProvider)

Initializes OpenGL with the specified FunctionProvider. This method can be used to implement custom OpenGL library loading.

Parameters
functionProvider:FunctionProvider

the provider of OpenGL function addresses

createCapabilitiesback to summary
public static GLCapabilities createCapabilities()

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

Depending on the current context, the instance returned may or may not contain the deprecated functionality removed since OpenGL version 3.1.

This method calls setCapabilities(GLCapabilities) with the new instance before returning.

Returns:GLCapabilities

the GLCapabilities instance

createCapabilitiesback to summary
public static GLCapabilities createCapabilities(IntFunction<PointerBuffer> bufferFactory)

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

Depending on the current context, the instance returned may or may not contain the deprecated functionality removed since OpenGL version 3.1.

This method calls setCapabilities(GLCapabilities) with the new instance before returning.

Parameters
bufferFactory:IntFunction<PointerBuffer>

a function that allocates a PointerBuffer given a size. The buffer must be filled with zeroes. If null, LWJGL will allocate a GC-managed buffer internally.

Returns:GLCapabilities

the GLCapabilities instance

createCapabilitiesback to summary
public static GLCapabilities createCapabilities(boolean forwardCompatible)

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

Depending on the current context, the instance returned may or may not contain the deprecated functionality removed since OpenGL version 3.1. The forwardCompatible flag will force LWJGL to not load the deprecated functions, even if the current context exposes them.

This method calls setCapabilities(GLCapabilities) with the new instance before returning.

Parameters
forwardCompatible:boolean

if true, LWJGL will create forward compatible capabilities

Returns:GLCapabilities

the GLCapabilities instance

createCapabilitiesback to summary
public static GLCapabilities createCapabilities(boolean forwardCompatible, IntFunction<PointerBuffer> bufferFactory)

Creates a new GLCapabilities instance for the OpenGL context that is current in the current thread.

Depending on the current context, the instance returned may or may not contain the deprecated functionality removed since OpenGL version 3.1. The forwardCompatible flag will force LWJGL to not load the deprecated functions, even if the current context exposes them.

This method calls setCapabilities(GLCapabilities) with the new instance before returning.

Parameters
forwardCompatible:boolean

if true, LWJGL will create forward compatible capabilities

bufferFactory:IntFunction<PointerBuffer>

a function that allocates a PointerBuffer given a size. If null, LWJGL will allocate a GC-managed buffer internally.

Returns:GLCapabilities

the GLCapabilities instance

Annotations
@SuppressWarnings:AssignmentToMethodParameter
createCapabilitiesGLXback to summary
public static GLXCapabilities createCapabilitiesGLX(long display)

Creates a GLXCapabilities instance for the default screen of the specified X connection.

This method may only be used on Linux.

Parameters
display:long

the X connection handle (DISPLAY)

createCapabilitiesGLXback to summary
public static GLXCapabilities createCapabilitiesGLX(long display, int screen)

Creates a GLXCapabilities instance for the specified screen of the specified X connection.

This method may only be used on Linux.

Parameters
display:long

the X connection handle (DISPLAY)

screen:int

the screen index

createCapabilitiesWGLback to summary
public static WGLCapabilities createCapabilitiesWGL()

Creates a WGLCapabilities instance for the context that is current in the current thread.

This method may only be used on Windows.

createCapabilitiesWGLback to summary
private static WGLCapabilities createCapabilitiesWGL(long hdc)

Creates a WGLCapabilities instance for the specified device context.

Parameters
hdc:long

the device context handle (HDC)

createCapabilitiesWGLDummyback to summary
private static WGLCapabilities createCapabilitiesWGLDummy()

Creates a dummy context and retrieves the WGL capabilities.

destroyback to summary
public static void destroy()

Unloads the OpenGL native library.

getCapabilitiesback to summary
public static GLCapabilities getCapabilities()

Returns the GLCapabilities of the OpenGL context that is current in the current thread.

Exceptions
IllegalStateException:
if setCapabilities has never been called in the current thread or was last called with a null value
getCapabilitiesGLXback to summary
public static GLXCapabilities getCapabilitiesGLX()

Returns the GLX capabilities.

This method may only be used on Linux.

getCapabilitiesGLXClientback to summary
pack-priv static GLXCapabilities getCapabilitiesGLXClient()

Returns the GLX client capabilities.

getCapabilitiesWGLback to summary
public static WGLCapabilities getCapabilitiesWGL()

Returns the WGL capabilities.

This method may only be used on Windows.

getFunctionProviderback to summary
public static FunctionProvider getFunctionProvider()

Returns the FunctionProvider for the OpenGL native library.

Annotations
@Nullable
getICDback to summary
pack-priv static GLCapabilities getICD()
initCapabilitiesGLXback to summary
private static GLXCapabilities initCapabilitiesGLX(boolean client)
initializeback to summary
pack-priv static void initialize()

Ensures that the lwjgl_opengl shared library has been loaded.

setCapabilitiesback to summary
public static void setCapabilities(GLCapabilities caps)

Sets the GLCapabilities of the OpenGL context that is current in the current thread.

This GLCapabilities instance will be used by any OpenGL call in the current thread, until setCapabilities is called again with a different value.

org.lwjgl.opengl back to summary

private Interface GL.ICD

Known Direct Implementers
org.lwjgl.opengl.GL.ICDStatic

Function pointer provider.

Method Summary

Modifier and TypeMethod and Description
public GLCapabilities
get()

public default void

Method Detail

getback to summary
public GLCapabilities get()
Annotations
@Nullable
setback to summary
public default void set(GLCapabilities caps)
org.lwjgl.opengl back to summary

private Class GL.ICDStatic

extends Object
implements ICD
Class Inheritance
All Implemented Interfaces
org.lwjgl.opengl.GL.ICD

Write-once ICD.

This is the default implementation that skips the thread-local lookup. When a new GLCapabilities is set, we compare it to the write-once capabilities. If different function pointers are found, we fall back to the expensive lookup.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static GLCapabilities

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public GLCapabilities
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tempCapsback to summary
private static GLCapabilities tempCaps
Annotations
@Nullable

Constructor Detail

ICDStaticback to summary
private ICDStatic()

Method Detail

getback to summary
public GLCapabilities get()

Implements org.lwjgl.opengl.GL.ICD.get.

Annotations
@Override
setback to summary
public void set(GLCapabilities caps)

Overrides default org.lwjgl.opengl.GL.ICD.set.

Annotations
@SuppressWarnings:AssignmentToStaticFieldFromInstanceMethod
@Override
org.lwjgl.opengl back to summary

private final Class GL.ICDStatic.WriteOnce

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final GLCapabilities

Constructor Summary

AccessConstructor and Description
private

Field Detail

capsback to summary
pack-priv static final GLCapabilities caps

Constructor Detail

WriteOnceback to summary
private WriteOnce()