Class Configuration<T>
- java.lang.Object
-
- org.lwjgl.system.Configuration<T>
-
public class Configuration<T> extends java.lang.Object
This class can be used to programmatically set the LWJGL runtime configuration. It is an alternative to using system properties.Care must be taken when setting static options. Such options are only read once or cached in
static final
fields. They must be configured through this class before touching any other LWJGL class.
-
-
Field Summary
Fields Modifier and Type Field and Description static Configuration<java.lang.Boolean>
DEBUG
Set to true to enable LWJGL's debug mode.static Configuration<java.lang.Boolean>
DEBUG_FUNCTIONS
When enabled, capabilities classes will print an error message when they fail to retrieve a function pointer.static Configuration<java.lang.Boolean>
DEBUG_MEMORY_ALLOCATOR
Set to true to enable LWJGL's debug mode for theMemoryUtil
explicit memory management API (memAlloc
/memFree
/etc).static Configuration<java.lang.Boolean>
DEBUG_STACK
Set to true to enable LWJGL's debug mode for theMemoryStack
.static Configuration<java.lang.Object>
DEBUG_STREAM
Can be set to override the defaultAPIUtil.DEBUG_STREAM
.static Configuration<java.lang.Boolean>
DISABLE_CHECKS
Set to true to disable LWJGL's basic checks.static Configuration<java.lang.Boolean>
EGL_EXPLICIT_INIT
By default, LWJGL will automatically initialize the EGL library, when it is first accessed.static Configuration<java.lang.String>
EGL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the EGL library (org.lwjgl.egl.libname).static Configuration<java.lang.Boolean>
GLFW_CHECK_THREAD0
By default, LWJGL will check if certain GLFW functions are called on the first thread of the process and fail if that is not the case.static Configuration<java.lang.String>
GLFW_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the GLFW library (org.lwjgl.glfw.libname).static Configuration<java.lang.String>
JEMALLOC_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the jemalloc library (org.lwjgl.system.jemalloc.libname).static Configuration<java.lang.String>
LIBRARY_NAME
Can be used to override the LWJGL library name.static Configuration<java.lang.String>
LIBRARY_PATH
Takes priority overjava.library.path
.static Configuration<java.lang.Object>
MEMORY_ALLOCATOR
static Configuration<java.lang.String>
OPENAL_CAPABILITIES_STATE
Similar toConfiguration.OPENGL_CAPABILITIES_STATE
for the OpenAL library (org.lwjgl.openal.capabilities).static Configuration<java.lang.Boolean>
OPENAL_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenAL library (org.lwjgl.openal.explicitInit).static Configuration<java.lang.String>
OPENAL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenAL library (org.lwjgl.openal.libname).static Configuration<java.lang.Boolean>
OPENCL_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenCL library (org.lwjgl.opencl.explicitInit).static Configuration<java.lang.String>
OPENCL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenCL library (org.lwjgl.opencl.libname).static Configuration<java.lang.String>
OPENGL_CAPABILITIES_STATE
Specifies the mechanism by whichGLCapabilities
instances are stored and retrieved.static Configuration<java.lang.Boolean>
OPENGL_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenGL library (org.lwjgl.opengl.explicitInit).static Configuration<java.lang.String>
OPENGL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenGL library (org.lwjgl.opengl.libname).static Configuration<java.lang.Object>
OPENGL_MAXVERSION
Can be used to limit the maximum available OpenGL version.static Configuration<java.lang.String>
OPENGLES_CAPABILITIES_STATE
Similar toConfiguration.OPENGL_CAPABILITIES_STATE
for the OpenGL ES library (org.lwjgl.opengles.capabilities).static Configuration<java.lang.Boolean>
OPENGLES_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenGL ES library (org.lwjgl.opengles.explicitInit).static Configuration<java.lang.String>
OPENGLES_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenGL ES library (org.lwjgl.opengles.libname).static Configuration<java.lang.Object>
OPENGLES_MAXVERSION
Similar toConfiguration.OPENGL_MAXVERSION
for the OpenGL ES library (org.lwjgl.opengles.maxVersion).static Configuration<java.lang.String>
SHARED_LIBRARY_EXTRACT_DIRECTORY
Changes the temporary directory name created by LWJGL when extracting shared libraries from JAR files.static Configuration<java.lang.String>
SHARED_LIBRARY_EXTRACT_PATH
Changes the path where LWJGL extracts shared libraries from JAR files.static Configuration<java.lang.Integer>
STACK_SIZE
Sets the stack size, in kilobytes, that will be used in the defaultMemoryStack
constructor.static Configuration<java.lang.String>
THREAD_LOCAL_SPACE
Sets the implementation used internally by LWJGL for thread-local data.static Configuration<java.lang.Boolean>
VULKAN_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the Vulkan library (org.lwjgl.vulkan.explicitInit).static Configuration<java.lang.String>
VULKAN_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the Vulkan library (org.lwjgl.vulkan.libname).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description T
get()
Returns the option value.T
get(T defaultValue)
Returns the option value.java.lang.String
getProperty()
void
set(T value)
Sets the option value.static void
setDebugStreamConsumer(java.util.function.Consumer<java.lang.String> consumer)
Configures theConfiguration.DEBUG_STREAM
to forward all messages to the specified consumer.static void
setDebugStreamConsumer(java.util.function.Consumer<java.lang.String> consumer, java.nio.charset.Charset charset)
Configures theConfiguration.DEBUG_STREAM
to forward all messages to the specified consumer.
-
-
-
Field Detail
-
LIBRARY_PATH
public static final Configuration<java.lang.String> LIBRARY_PATH
Takes priority overjava.library.path
. It may contain one or more directory paths, separated byFile.pathSeparator
.Property: org.lwjgl.librarypath
Usage: Dynamic
-
SHARED_LIBRARY_EXTRACT_DIRECTORY
public static final Configuration<java.lang.String> SHARED_LIBRARY_EXTRACT_DIRECTORY
Changes the temporary directory name created by LWJGL when extracting shared libraries from JAR files. If this option is not set, it defaults tolwjgl<user name>
.Property: org.lwjgl.system.SharedLibraryExtractDirectory
Usage: Dynamic
-
SHARED_LIBRARY_EXTRACT_PATH
public static final Configuration<java.lang.String> SHARED_LIBRARY_EXTRACT_PATH
Changes the path where LWJGL extracts shared libraries from JAR files. If this option is not set, LWJGL will try the following paths and the first successful will be used:System.getProperty("java.io.tmpdir")
/extractDir/crc/System.getProperty("user.home")
/.extractDir/crc/- .extractDir/crc/
File.createTempFile(crc)
extractDir = Configuration.SHARED_LIBRARY_EXTRACT_DIRECTORY crc = CRC of the lwjgl shared library
Property: org.lwjgl.system.SharedLibraryExtractPath
Usage: Dynamic
-
LIBRARY_NAME
public static final Configuration<java.lang.String> LIBRARY_NAME
Can be used to override the LWJGL library name. It can be an absolute path.Property: org.lwjgl.libname
Usage: Dynamic
-
MEMORY_ALLOCATOR
public static final Configuration<java.lang.Object> MEMORY_ALLOCATOR
Sets the allocator used for theMemoryUtil
explicit memory management API (memAlloc
/memFree
/etc). Supported values:- jemalloc - The allocator provided by the jemalloc library
- system - The default system memory allocator
- <classpath> - A class that implements the
MemoryUtil.MemoryAllocator
interface. It will be instantiated using reflection.
When set programmatically, it can also be a
MemoryUtil.MemoryAllocator
instance.Property: org.lwjgl.system.allocator
Type: String or aMemoryUtil.MemoryAllocator
instance
Usage: Static
-
STACK_SIZE
public static final Configuration<java.lang.Integer> STACK_SIZE
Sets the stack size, in kilobytes, that will be used in the defaultMemoryStack
constructor. This value is also used for the LWJGL-managed, thread-local,MemoryStack
instances.If this option is not set, it defaults to 32.
Property: org.lwjgl.system.stackSize
Usage: Static
-
THREAD_LOCAL_SPACE
public static final Configuration<java.lang.String> THREAD_LOCAL_SPACE
Sets the implementation used internally by LWJGL for thread-local data. Supported values:- unsafe - A thread-local implementation that uses
Unsafe
to store per-thread data directly inThread
instances. This is the default. - ThreadLocal - Uses
ThreadLocal
.
Property: org.lwjgl.system.tls
Usage: Static - unsafe - A thread-local implementation that uses
-
DISABLE_CHECKS
public static final Configuration<java.lang.Boolean> DISABLE_CHECKS
Set to true to disable LWJGL's basic checks. These are trivial checks that LWJGL performs to avoid JVM crashes, very useful during development. Their performance impact is usually minimal, but may they be disabled for release builds.Property: org.lwjgl.util.NoChecks
Usage: Static
-
DEBUG
public static final Configuration<java.lang.Boolean> DEBUG
Set to true to enable LWJGL's debug mode. Information messages will be printed to theAPIUtil.DEBUG_STREAM
and extra runtime checks will be performed (some potentially expensive, performance-wise).Property: org.lwjgl.util.Debug
Usage: Static
-
DEBUG_STREAM
public static final Configuration<java.lang.Object> DEBUG_STREAM
Can be set to override the defaultAPIUtil.DEBUG_STREAM
. It must be the name of a class that implements theSupplier<PrintStream>
interface. The class will be instantiated using reflection and the result ofget
will become theConfiguration.DEBUG_STREAM
used by LWJGL.When set programmatically, it can also be a
PrintStream
instance. TheConfiguration.setDebugStreamConsumer(java.util.function.Consumer<java.lang.String>)
can be used to forward debug messages to any consumer.Property: org.lwjgl.util.DebugStream
Type: String or aPrintStream
instance
Usage: Static
-
DEBUG_MEMORY_ALLOCATOR
public static final Configuration<java.lang.Boolean> DEBUG_MEMORY_ALLOCATOR
Set to true to enable LWJGL's debug mode for theMemoryUtil
explicit memory management API (memAlloc
/memFree
/etc). All memory allocations through that API will be tracked and leaks will be reported on JVM exit. ThememReport
methods can also be used.When this option is enabled, a stacktrace is generated on every allocation, which may negatively impact performance. If this becomes a serious issue, the JVM option
-XX:MaxJavaStackTraceDepth=d
(whered >= 6
) can be used to reduce the overhead.Property: org.lwjgl.util.DebugAllocator
Usage: Static
-
DEBUG_STACK
public static final Configuration<java.lang.Boolean> DEBUG_STACK
Set to true to enable LWJGL's debug mode for theMemoryStack
. When using the stack, each frame should be popped in the same method that pushed it. If this symmetry is broken, this mode will report it immediately.When this option is enabled, a stacktrace is generated on every push or pop to the stack, which may negatively impact performance. If this becomes a serious issue, the JVM option
-XX:MaxJavaStackTraceDepth=d
(whered >= 5
) can be used to reduce the overhead.Property: org.lwjgl.util.DebugStack
Usage: Static
-
DEBUG_FUNCTIONS
public static final Configuration<java.lang.Boolean> DEBUG_FUNCTIONS
When enabled, capabilities classes will print an error message when they fail to retrieve a function pointer.Function pointers in such classes are retrieved unconditionally, so this option may generate a lot of output and many false negatives.
This option requires
Configuration.DEBUG
to be enabled.Property: org.lwjgl.util.DebugFunctions
Usage: Static
-
EGL_EXPLICIT_INIT
public static final Configuration<java.lang.Boolean> EGL_EXPLICIT_INIT
By default, LWJGL will automatically initialize the EGL library, when it is first accessed. Set this property to disable this behavior.Property: org.lwjgl.egl.explicitInit
Usage: Static
-
EGL_LIBRARY_NAME
public static final Configuration<java.lang.String> EGL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the EGL library (org.lwjgl.egl.libname).
-
GLFW_LIBRARY_NAME
public static final Configuration<java.lang.String> GLFW_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the GLFW library (org.lwjgl.glfw.libname).
-
GLFW_CHECK_THREAD0
public static final Configuration<java.lang.Boolean> GLFW_CHECK_THREAD0
By default, LWJGL will check if certain GLFW functions are called on the first thread of the process and fail if that is not the case. Set this property to false to disable this behavior.Property: org.lwjgl.glfw.checkThread0
Usage: Static
-
JEMALLOC_LIBRARY_NAME
public static final Configuration<java.lang.String> JEMALLOC_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the jemalloc library (org.lwjgl.system.jemalloc.libname).
-
OPENAL_EXPLICIT_INIT
public static final Configuration<java.lang.Boolean> OPENAL_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenAL library (org.lwjgl.openal.explicitInit).
-
OPENAL_LIBRARY_NAME
public static final Configuration<java.lang.String> OPENAL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenAL library (org.lwjgl.openal.libname).
-
OPENAL_CAPABILITIES_STATE
public static final Configuration<java.lang.String> OPENAL_CAPABILITIES_STATE
Similar toConfiguration.OPENGL_CAPABILITIES_STATE
for the OpenAL library (org.lwjgl.openal.capabilities).
-
OPENCL_EXPLICIT_INIT
public static final Configuration<java.lang.Boolean> OPENCL_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenCL library (org.lwjgl.opencl.explicitInit).
-
OPENCL_LIBRARY_NAME
public static final Configuration<java.lang.String> OPENCL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenCL library (org.lwjgl.opencl.libname).
-
OPENGL_EXPLICIT_INIT
public static final Configuration<java.lang.Boolean> OPENGL_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenGL library (org.lwjgl.opengl.explicitInit).
-
OPENGL_LIBRARY_NAME
public static final Configuration<java.lang.String> OPENGL_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenGL library (org.lwjgl.opengl.libname).
-
OPENGL_MAXVERSION
public static final Configuration<java.lang.Object> OPENGL_MAXVERSION
Can be used to limit the maximum available OpenGL version. This can be useful to ensure that an application has not accidentally used features only available in a higher OpenGL version.When set programmatically, it can also be an
APIUtil.APIVersion
instance.Property: org.lwjgl.opengl.maxVersion
Type: String (M.n) or anAPIUtil.APIVersion
instance
Usage: Static
-
OPENGL_CAPABILITIES_STATE
public static final Configuration<java.lang.String> OPENGL_CAPABILITIES_STATE
Specifies the mechanism by whichGLCapabilities
instances are stored and retrieved.LWJGL supports multiple OpenGL contexts and each context may have different capabilities or even different function pointers. This is normally implemented using a
ThreadLocal
, which stores the currentGLCapabilities
for each thread. Due to the JVM's current inability to ideally optimize code that uses JNI methods, this results in a thread-local lookup for each OpenGL method call. To mitigate the performance impact, this option can be set to use an alternative implementation. Supported values:- ThreadLocal - Uses the thread-local implementation specified by
Configuration.THREAD_LOCAL_SPACE
. This is the default. - static - If it is known that an application will only create one context, or that any contexts created will use the same device and same
context creation flags, this option removes all overhead from OpenGL function pointer lookups.
When this option is set to true, the
GLCapabilities
instance set before the first OpenGL function is called, will be used for all subsequent OpenGL function calls. Once set, it cannot be changed and any calls toGL.setCapabilities
will be ignored.
Property: org.lwjgl.opengl.capabilities
Usage: Static - ThreadLocal - Uses the thread-local implementation specified by
-
OPENGLES_EXPLICIT_INIT
public static final Configuration<java.lang.Boolean> OPENGLES_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the OpenGL ES library (org.lwjgl.opengles.explicitInit).
-
OPENGLES_LIBRARY_NAME
public static final Configuration<java.lang.String> OPENGLES_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the OpenGL ES library (org.lwjgl.opengles.libname).
-
OPENGLES_MAXVERSION
public static final Configuration<java.lang.Object> OPENGLES_MAXVERSION
Similar toConfiguration.OPENGL_MAXVERSION
for the OpenGL ES library (org.lwjgl.opengles.maxVersion).
-
OPENGLES_CAPABILITIES_STATE
public static final Configuration<java.lang.String> OPENGLES_CAPABILITIES_STATE
Similar toConfiguration.OPENGL_CAPABILITIES_STATE
for the OpenGL ES library (org.lwjgl.opengles.capabilities).
-
VULKAN_EXPLICIT_INIT
public static final Configuration<java.lang.Boolean> VULKAN_EXPLICIT_INIT
Similar toConfiguration.EGL_EXPLICIT_INIT
for the Vulkan library (org.lwjgl.vulkan.explicitInit).
-
VULKAN_LIBRARY_NAME
public static final Configuration<java.lang.String> VULKAN_LIBRARY_NAME
Similar toConfiguration.LIBRARY_NAME
for the Vulkan library (org.lwjgl.vulkan.libname).
-
-
Method Detail
-
getProperty
public java.lang.String getProperty()
-
set
public void set(T value)
Sets the option value.- Parameters:
value
- the value to set
-
get
public T get()
Returns the option value.If the option value has not been set, null will be returned.
-
get
public T get(T defaultValue)
Returns the option value.If the option value has not been set, the specified default value will be returned.
- Parameters:
defaultValue
- the default value
-
setDebugStreamConsumer
public static void setDebugStreamConsumer(java.util.function.Consumer<java.lang.String> consumer)
Configures theConfiguration.DEBUG_STREAM
to forward all messages to the specified consumer.- Parameters:
consumer
- the debug message consumer
-
setDebugStreamConsumer
public static void setDebugStreamConsumer(java.util.function.Consumer<java.lang.String> consumer, java.nio.charset.Charset charset)
Configures theConfiguration.DEBUG_STREAM
to forward all messages to the specified consumer.- Parameters:
consumer
- the debug message consumercharset
- the message charset
-
-