Top Description Fields Constructors Methods
org.lwjgl.opengl

public final Class ContextAttribs

extends Object
Class Inheritance
Imports
org.lwjgl.BufferUtils, .LWJGLUtil, java.nio.IntBuffer, java.util.LinkedHashMap, .Map.Entry

This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context extension.

The attributes supported are described in the following extensions:

Use of this class is optional. If an OpenGL context is created without passing an instance of this class (or ARB_create_context is not supported), the old context creation code will be used. Support for debug and forward compatible mobes is not guaranteed by the OpenGL implementation. Developers may encounter debug contexts being the same as non-debug contexts or forward compatible contexts having support for deprecated functionality.

If the CONTEXT_FORWARD_COMPATIBLE_BIT_ARB flag is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification), even if the driver exposes the corresponding entry points.

This extension is not supported on MacOS X. However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an instance of this class must be passed to LWJGL. The only valid configuration is ContextAttribs(3, 2, CONTEXT_CORE_PROFILE_BIT_ARB), anything else will be ignored.

Author
spasi

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private int
private int
private int
private int
public static final int
private int
private int
public static final int
private int

Constructor Summary

AccessConstructor and Description
public
ContextAttribs()

Creates the default ContextAttribs instance.

public
ContextAttribs(int majorVersion, int minorVersion)

Creates a ContextAttribs instance for the given OpenGL version.

public
ContextAttribs(int
the major OpenGL version
majorVersion
,
int
the minor OpenGL version
minorVersion
,
int profileMask)

Creates a new ContextAttribs instance with the given attributes.

public
ContextAttribs(int
the major OpenGL version
majorVersion
,
int
the minor OpenGL version
minorVersion
,
int profileMask, int contextFlags)

Creates a new ContextAttribs instance with the given attributes.

private

Method Summary

Modifier and TypeMethod and Description
pack-priv IntBuffer
public int
getContextFlags()

Returns the CONTEXT_FLAGS_ARB value.

public int
public int
public int
public int
public int
public int
private boolean
hasFlag(int flag)

private boolean
hasMask(int mask)

public boolean
isContextResetIsolation()

Returns true if the CONTEXT_RESET_ISOLATION_BIT_ARB has been set.

public boolean
isDebug()

Returns true if the CONTEXT_DEBUG_BIT_ARB has been set.

public boolean
isForwardCompatible()

Returns true if the CONTEXT_FORWARD_COMPATIBLE_BIT_ARB has been set.

public boolean
public boolean
public boolean
isProfileCore()

Returns true if the CONTEXT_CORE_PROFILE_BIT_ARB has been set.

public boolean
isProfileES()

Returns true if the CONTEXT_ES2_PROFILE_BIT_EXT has been set.

public boolean
isRobustAccess()

Returns true if the CONTEXT_ROBUST_ACCESS_BIT_ARB has been set.

private ContextAttribs
toggleFlag(int flag, boolean value)

private ContextAttribs
toggleMask(int mask, boolean value)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public ContextAttribs

Returns:

the new ContextAttribs
withContextReleaseBehavior
(int behavior)

Returns a ContextAttribs instance with CONTEXT_RELEASE_BEHABIOR_ARB set to the given behavior.

public ContextAttribs
withContextResetIsolation(boolean contextResetIsolation)

Returns a new ContextAttribs instance with the CONTEXT_RESET_ISOLATION_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

public ContextAttribs
withDebug(boolean debug)

Returns a new ContextAttribs instance with the CONTEXT_DEBUG_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

public ContextAttribs
withForwardCompatible(boolean forwardCompatible)

Returns a new ContextAttribs instance with the CONTEXT_FORWARD_COMPATIBLE_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

public ContextAttribs
withLayer(int layerPlane)

Returns a new ContextAttribs instance with CONTEXT_LAYER_PLANE_ARB set to the given value.

public ContextAttribs

Returns:

the new ContextAttribs
withLoseContextOnReset
(boolean
the context reset notification strategy
loseContextOnReset
)

Deprecated use withResetNotificationStrategy instead
Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB set to LOSE_CONTEXT_ON_RESET_ARB if the parameter is true or to NO_RESET_NOTIFICATION_ARB if the parameter is false.
public ContextAttribs
withProfileCompatibility(boolean profileCompatibility)

Returns a new ContextAttribs instance with the CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB bit in CONTEXT_PROFILE_MASK_ARB set to the given value.

public ContextAttribs
withProfileCore(boolean profileCore)

Returns a new ContextAttribs instance with the CONTEXT_CORE_PROFILE_BIT_ARB bit in CONTEXT_PROFILE_MASK_ARB set to the given value.

public ContextAttribs
withProfileES(boolean profileES)

Returns a new ContextAttribs instance with the CONTEXT_ES2_PROFILE_BIT_EXT bit in CONTEXT_PROFILE_MASK_ARB set to the given value.

public ContextAttribs

Returns:

the new ContextAttribs
withResetNotificationStrategy
(int
the context reset notification strategy. One of:
NO_RESET_NOTIFICATION_ARB, LOSE_CONTEXT_ON_RESET_ARB
strategy
)

Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB set to the given strategy.

public ContextAttribs
withRobustAccess(boolean robustAccess)

Returns a new ContextAttribs instance with the CONTEXT_ROBUST_ACCESS_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CONTEXT_COMPATIBILITY_PROFILE_BIT_ARBback to summary
public static final int CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
CONTEXT_CORE_PROFILE_BIT_ARBback to summary
public static final int CONTEXT_CORE_PROFILE_BIT_ARB
CONTEXT_DEBUG_BIT_ARBback to summary
public static final int CONTEXT_DEBUG_BIT_ARB
CONTEXT_ES2_PROFILE_BIT_EXTback to summary
public static final int CONTEXT_ES2_PROFILE_BIT_EXT
CONTEXT_FLAGS_ARBback to summary
public static final int CONTEXT_FLAGS_ARB
CONTEXT_FORWARD_COMPATIBLE_BIT_ARBback to summary
public static final int CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
CONTEXT_LAYER_PLANE_ARBback to summary
public static final int CONTEXT_LAYER_PLANE_ARB
CONTEXT_MAJOR_VERSION_ARBback to summary
public static final int CONTEXT_MAJOR_VERSION_ARB
CONTEXT_MINOR_VERSION_ARBback to summary
public static final int CONTEXT_MINOR_VERSION_ARB
CONTEXT_PROFILE_MASK_ARBback to summary
public static final int CONTEXT_PROFILE_MASK_ARB
CONTEXT_RELEASE_BEHABIOR_ARBback to summary
public static final int CONTEXT_RELEASE_BEHABIOR_ARB
CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARBback to summary
public static final int CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB
CONTEXT_RELEASE_BEHAVIOR_NONE_ARBback to summary
public static final int CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
CONTEXT_RESET_ISOLATION_BIT_ARBback to summary
public static final int CONTEXT_RESET_ISOLATION_BIT_ARB
CONTEXT_RESET_NOTIFICATION_STRATEGY_ARBback to summary
public static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
CONTEXT_ROBUST_ACCESS_BIT_ARBback to summary
public static final int CONTEXT_ROBUST_ACCESS_BIT_ARB
contextFlagsback to summary
private int contextFlags
contextReleaseBehaviorback to summary
private int contextReleaseBehavior
contextResetNotificationStrategyback to summary
private int contextResetNotificationStrategy
layerPlaneback to summary
private int layerPlane
LOSE_CONTEXT_ON_RESET_ARBback to summary
public static final int LOSE_CONTEXT_ON_RESET_ARB
majorVersionback to summary
private int majorVersion
minorVersionback to summary
private int minorVersion
NO_RESET_NOTIFICATION_ARBback to summary
public static final int NO_RESET_NOTIFICATION_ARB
profileMaskback to summary
private int profileMask

Constructor Detail

ContextAttribsback to summary
public ContextAttribs()

Creates the default ContextAttribs instance. No special attributes will be used when creating the OpenGL context.

ContextAttribsback to summary
public ContextAttribs(int majorVersion, int minorVersion)

Creates a ContextAttribs instance for the given OpenGL version.

ContextAttribsback to summary
public ContextAttribs(int majorVersion, int minorVersion, int profileMask)

Creates a new ContextAttribs instance with the given attributes.

Parameters
majorVersion:int

the major OpenGL version

minorVersion:int

the minor OpenGL version

profileMask:int

the context profile mask. One of:
CONTEXT_CORE_PROFILE_BIT_ARB, CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, CONTEXT_ES2_PROFILE_BIT_EXT

ContextAttribsback to summary
public ContextAttribs(int majorVersion, int minorVersion, int profileMask, int contextFlags)

Creates a new ContextAttribs instance with the given attributes.

Parameters
majorVersion:int

the major OpenGL version

minorVersion:int

the minor OpenGL version

profileMask:int

the context profile mask. One of:
CONTEXT_CORE_PROFILE_BIT_ARB, CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, CONTEXT_ES2_PROFILE_BIT_EXT

contextFlags:int

the context flags, a bitfield value. One or more of:
CONTEXT_DEBUG_BIT_ARB, CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, CONTEXT_ROBUST_ACCESS_BIT_ARB, CONTEXT_RESET_ISOLATION_BIT_ARB

ContextAttribsback to summary
private ContextAttribs(ContextAttribs other)

Method Detail

getAttribListback to summary
pack-priv IntBuffer getAttribList()
getContextFlagsback to summary
public int getContextFlags()

Returns the CONTEXT_FLAGS_ARB value.

getContextReleaseBehaviorback to summary
public int getContextReleaseBehavior()

Returns the CONTEXT_RELEASE_BEHABIOR_ARB value.

getContextResetNotificationStrategyback to summary
public int getContextResetNotificationStrategy()

Returns the CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB value.

getLayerPlaneback to summary
public int getLayerPlane()

Returns the CONTEXT_LAYER_PLANE_ARB value.

getMajorVersionback to summary
public int getMajorVersion()

Returns the CONTEXT_MAJOR_VERSION_ARB value.

getMinorVersionback to summary
public int getMinorVersion()

Returns the CONTEXT_MINOR_VERSION_ARB value.

getProfileMaskback to summary
public int getProfileMask()

Returns the CONTEXT_PROFILE_MASK_ARB value.

hasFlagback to summary
private boolean hasFlag(int flag)
hasMaskback to summary
private boolean hasMask(int mask)
isContextResetIsolationback to summary
public boolean isContextResetIsolation()

Returns true if the CONTEXT_RESET_ISOLATION_BIT_ARB has been set.

isDebugback to summary
public boolean isDebug()

Returns true if the CONTEXT_DEBUG_BIT_ARB has been set.

isForwardCompatibleback to summary
public boolean isForwardCompatible()

Returns true if the CONTEXT_FORWARD_COMPATIBLE_BIT_ARB has been set.

isLoseContextOnResetback to summary
public boolean isLoseContextOnReset()

Deprecated

use getContextResetNotificationStrategy instead

Returns true if the CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB has been set to LOSE_CONTEXT_ON_RESET_ARB.

isProfileCompatibilityback to summary
public boolean isProfileCompatibility()

Returns true if the CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB has been set.

isProfileCoreback to summary
public boolean isProfileCore()

Returns true if the CONTEXT_CORE_PROFILE_BIT_ARB has been set.

isProfileESback to summary
public boolean isProfileES()

Returns true if the CONTEXT_ES2_PROFILE_BIT_EXT has been set.

isRobustAccessback to summary
public boolean isRobustAccess()

Returns true if the CONTEXT_ROBUST_ACCESS_BIT_ARB has been set.

toggleFlagback to summary
private ContextAttribs toggleFlag(int flag, boolean value)
toggleMaskback to summary
private ContextAttribs toggleMask(int mask, boolean value)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

withContextReleaseBehaviorback to summary
public ContextAttribs withContextReleaseBehavior(int behavior)

Returns a ContextAttribs instance with CONTEXT_RELEASE_BEHABIOR_ARB set to the given behavior. The default context release behavior is CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB.

Parameters
behavior:int

the context release behavior. One of:
CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB, CONTEXT_RELEASE_BEHAVIOR_NONE_ARB

Returns:ContextAttribs

the new ContextAttribs

withContextResetIsolationback to summary
public ContextAttribs withContextResetIsolation(boolean contextResetIsolation)

Returns a new ContextAttribs instance with the CONTEXT_RESET_ISOLATION_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

withDebugback to summary
public ContextAttribs withDebug(boolean debug)

Returns a new ContextAttribs instance with the CONTEXT_DEBUG_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

withForwardCompatibleback to summary
public ContextAttribs withForwardCompatible(boolean forwardCompatible)

Returns a new ContextAttribs instance with the CONTEXT_FORWARD_COMPATIBLE_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.

withLayerback to summary
public ContextAttribs withLayer(int layerPlane)

Returns a new ContextAttribs instance with CONTEXT_LAYER_PLANE_ARB set to the given value.

withLoseContextOnResetback to summary
public ContextAttribs withLoseContextOnReset(boolean loseContextOnReset)

Deprecated

use withResetNotificationStrategy instead

Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB set to LOSE_CONTEXT_ON_RESET_ARB if the parameter is true or to NO_RESET_NOTIFICATION_ARB if the parameter is false.

Parameters
loseContextOnReset:boolean

the context reset notification strategy

Returns:ContextAttribs

the new ContextAttribs

withProfileCompatibilityback to summary
public ContextAttribs withProfileCompatibility(boolean profileCompatibility)

Returns a new ContextAttribs instance with the CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB bit in CONTEXT_PROFILE_MASK_ARB set to the given value. If profileCompatibility is true, all other bits in the mask are cleared.

withProfileCoreback to summary
public ContextAttribs withProfileCore(boolean profileCore)

Returns a new ContextAttribs instance with the CONTEXT_CORE_PROFILE_BIT_ARB bit in CONTEXT_PROFILE_MASK_ARB set to the given value. If profileCore is true, all other bits in the mask are cleared.

withProfileESback to summary
public ContextAttribs withProfileES(boolean profileES)

Returns a new ContextAttribs instance with the CONTEXT_ES2_PROFILE_BIT_EXT bit in CONTEXT_PROFILE_MASK_ARB set to the given value. If profileES is true, all other bits in the mask are cleared.

withResetNotificationStrategyback to summary
public ContextAttribs withResetNotificationStrategy(int strategy)

Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB set to the given strategy. The default context reset notification strategy is NO_RESET_NOTIFICATION_ARB.

Parameters
strategy:int

the context reset notification strategy. One of:
NO_RESET_NOTIFICATION_ARB, LOSE_CONTEXT_ON_RESET_ARB

Returns:ContextAttribs

the new ContextAttribs

withRobustAccessback to summary
public ContextAttribs withRobustAccess(boolean robustAccess)

Returns a new ContextAttribs instance with the CONTEXT_ROBUST_ACCESS_BIT_ARB bit in CONTEXT_FLAGS_ARB set to the given value.