-
-
Notifications
You must be signed in to change notification settings - Fork 631
/
Configuration.java
723 lines (612 loc) · 35.4 KB
/
Configuration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl.system;
import org.lwjgl.system.MemoryUtil.*;
import javax.annotation.*;
import java.io.*;
import java.util.function.*;
/**
* This class can be used to programmatically set the LWJGL runtime configuration. It is an alternative to using system properties.
*
* <p>Care must be taken when setting <em>static</em> options. Such options are only read once or cached in {@code static final} fields. They must be
* configured through this class before touching any other LWJGL class.</p>
*/
public class Configuration<T> {
/**
* Takes priority over {@code java.library.path}.
*
* <p>It may contain one or more directory paths, separated by {@link File#pathSeparator}.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.librarypath</b><br>
* Usage: Dynamic<br>
*/
public static final Configuration<String> LIBRARY_PATH = new Configuration<>("org.lwjgl.librarypath", StateInit.STRING);
/**
* Sets the mapping algorithm used to resolve the <b>name</b> of bundled shared libraries.
*
* <p>Supported values:</p>
* <ul>
* <li><em>default</em> - Maps {@code <libname>} to {@code <libname>}.</li>
* <li><em>legacy</em> - Maps {@code <libname>} to {@code is64bit(arch) ? <libname> : <libname>32}.</li>
* <li><em><classpath></em> - A class that implements the {@link Function Function<String, String>} interface. It will be instantiated using reflection.</li>
* </ul>
*
* <p>When set programmatically, it can also be a {@link Function Function<String, String>} instance.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.bundledLibrary.nameMapper</b><br>
* Type: String or a {@link Function Function<String, String>} instance<br>
* Usage: Static</p>
*/
public static final Configuration<Object> BUNDLED_LIBRARY_NAME_MAPPER =
new Configuration<>("org.lwjgl.system.bundledLibrary.nameMapper", StateInit.STRING);
/**
* Sets the mapping algorithm used to resolve bundled shared libraries in the <b>classpath/modulepath</b>.
*
* <p>Supported values:</p>
* <ul>
* <li><em>default</em> - Maps {@code <libpath>} to {@code <arch>/<libpath>}.</li>
* <li><em>legacy</em> - Maps {@code <libpath>} to {@code <libpath>}.</li>
* <li><em><classpath></em> - A class that implements the {@link Function Function<String, String>} interface. It will be instantiated using reflection.</li>
* </ul>
*
* <p>When set programmatically, it can also be a {@link Function Function<String, String>} instance.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.bundledLibrary.nameMapper</b><br>
* Type: String or a {@link Function Function<String, String>} instance<br>
* Usage: Static</p>
*/
public static final Configuration<Object> BUNDLED_LIBRARY_PATH_MAPPER =
new Configuration<>("org.lwjgl.system.bundledLibrary.pathMapper", StateInit.STRING);
/**
* Changes the temporary directory name created by LWJGL when extracting shared libraries from JAR files.
*
* <p>If this option is not set, it defaults to <code>lwjgl_<user name></code>.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.SharedLibraryExtractDirectory</b><br>
* Usage: Dynamic<br>
*/
public static final Configuration<String> SHARED_LIBRARY_EXTRACT_DIRECTORY = new Configuration<>(
"org.lwjgl.system.SharedLibraryExtractDirectory",
StateInit.STRING
);
/**
* Changes the path where LWJGL extracts shared libraries from JAR files.
*
* <p>If this option is not set, LWJGL will try the following paths and the first successful will be used:</p>
* <ul>
* <li>{@code System.getProperty("java.io.tmpdir")}/extractDir/version/arch/</li>
* <li><working directory>/.extractDir/version/arch/</li>
* <li>{@code System.getProperty("user.home")}/.extractDir/version/arch/</li>
* <li>{@code Files.createTempDirectory("lwjgl", "")}</li>
* </ul>
*
* where:
*
* <pre><code>
* extractDir = Configuration.SHARED_LIBRARY_EXTRACT_DIRECTORY
* version = Version.getVersion().replace(' ', '-')
* </code></pre>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.SharedLibraryExtractPath</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<String> SHARED_LIBRARY_EXTRACT_PATH = new Configuration<>(
"org.lwjgl.system.SharedLibraryExtractPath",
StateInit.STRING
);
/**
* When enabled, shared libraries found as regular files (not inside a JAR file) in the classpath will first be copied to the
* {@link #SHARED_LIBRARY_EXTRACT_PATH}, then loaded from there.
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.SharedLibraryExtractForce</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<Boolean> SHARED_LIBRARY_EXTRACT_FORCE = new Configuration<>(
"org.lwjgl.system.SharedLibraryExtractForce",
StateInit.BOOLEAN
);
/**
* EXPERIMENTAL: Emulates {@link System#loadLibrary} behavior in {@link Library#loadNative(Class, String, String, boolean) Library.loadNative}.
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.EmulateSystemLoadLibrary</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<Boolean> EMULATE_SYSTEM_LOADLIBRARY = new Configuration<>(
"org.lwjgl.system.EmulateSystemLoadLibrary",
StateInit.BOOLEAN
);
/**
* Can be used to override the LWJGL library name.
*
* <p>It can be an absolute path.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.libname</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<String> LIBRARY_NAME = new Configuration<>("org.lwjgl.libname", StateInit.STRING);
/**
* Sets the allocator used for the {@link MemoryUtil} explicit memory management API
* ({@link MemoryUtil#memAlloc memAlloc}/{@link MemoryUtil#memFree memFree}/etc).
*
* <p>Supported values:</p>
* <ul>
* <li><em>jemalloc</em> - The allocator provided by the jemalloc library.</li>
* <li><em>rpmalloc</em> - The allocator provided by the rpmalloc library.<br>
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><p>LWJGL calls {@code rpmalloc_initialize} once, when the allocator is
* created. It never calls {@code rpmalloc_finalize}. The user is responsible for calling {@code rpmalloc_thread_initialize} and
* {@code rpmalloc_thread_finalize} when appropriate.</p></div></li>
* <li><em>system</em> - The default system memory allocator</li>
* <li><em><classpath></em> - A class that implements the {@link MemoryAllocator MemoryAllocator} interface. It will be instantiated using reflection.</li>
* </ul>
*
* <p>When set programmatically, it can also be a {@link MemoryAllocator MemoryAllocator} instance.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.allocator</b><br>
* Type: String or a {@link MemoryAllocator} instance<br>
* Usage: Static</p>
*/
public static final Configuration<Object> MEMORY_ALLOCATOR = new Configuration<>("org.lwjgl.system.allocator", StateInit.STRING);
/**
* Sets the stack size, in kilobytes, that will be used in the default {@link MemoryStack} constructor.
*
* <p>This value is also used for the LWJGL-managed, thread-local, {@link MemoryStack} instances. If this option is not set, it defaults to 64.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.stackSize</b><br>
* Usage: Static</p>
*/
public static final Configuration<Integer> STACK_SIZE = new Configuration<>("org.lwjgl.system.stackSize", StateInit.INT);
/**
* Sets the size of arrays cached in thread-local storage to minimize allocations while decoding text.
*
* <p>The memory cost for the cache is up to two arrays per thread that does text decoding. When the text length is up to this value, a cached array will
* be used. When the text length is longer than this value, a new array buffer will be allocated.</p>
*
* <p>If this option is not set, it defaults to 8192. Setting the value to 0 will disable the array cache.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.arrayTLCSize</b><br>
* Usage: Static</p>
*/
public static final Configuration<Integer> ARRAY_TLC_SIZE = new Configuration<>("org.lwjgl.system.arrayTLCSize", StateInit.INT);
/**
* Overrides the number of functions in the {@code JNINativeInterface_} struct.
*
* <p>This is only necessary when LWJGL runs on a JVM with a newer, unsupported JNI version, that has introduced new JNI functions. The function count
* must be accurate in order to use the OpenGL, OpenGL ES, or OpenAL bindings.</p>
*
* <p>The currently known values are:</p>
* <ul>
* <li>229 for Java 8</li>
* <li>230 for Java 9 to Java 18</li>
* <li>231 for Java 19 or higher</li>
* </ul>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.system.JNINativeInterfaceSize</b><br>
* Usage: Static</p>
*/
public static final Configuration<Integer> JNI_NATIVE_INTERFACE_FUNCTION_COUNT = new Configuration<>("org.lwjgl.system.JNINativeInterfaceSize", StateInit.INT);
/**
* Set to true to disable LWJGL's basic checks.
*
* <p>These are trivial checks that LWJGL performs to avoid JVM crashes, very useful during development. Their performance impact is usually minimal, but
* they may be disabled for release builds.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.NoChecks</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DISABLE_CHECKS = new Configuration<>("org.lwjgl.util.NoChecks", StateInit.BOOLEAN);
/**
* Set to true to disable LWJGL's function lookup checks.
*
* <p>These checks ensure that required functions are not missing from dynamically loaded shared libraries. This setting is useful when a trusted
* incompatible library must be loaded.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.NoFunctionChecks</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<Boolean> DISABLE_FUNCTION_CHECKS = new Configuration<>("org.lwjgl.util.NoFunctionChecks", StateInit.BOOLEAN);
/**
* Set to true to enable LWJGL's debug mode.
*
* <p>Information messages will be printed to the {@link APIUtil#DEBUG_STREAM} and extra runtime checks will be performed (some potentially expensive,
* performance-wise).</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.Debug</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DEBUG = new Configuration<>("org.lwjgl.util.Debug", StateInit.BOOLEAN);
/**
* When enabled, {@code SharedLibraryLoader} exceptions will be printed to the {@link #DEBUG_STREAM}.
*
* <p>This option requires {@link #DEBUG} to be enabled.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugLoader</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DEBUG_LOADER = new Configuration<>("org.lwjgl.util.DebugLoader", StateInit.BOOLEAN);
/**
* Can be set to override the default {@link APIUtil#DEBUG_STREAM}.
*
* <p>It must be the name of a class that implements the {@link Supplier Supplier<PrintStream>} interface. The class will be instantiated using
* reflection and the result of {@link Supplier#get get} will become the {@code #DEBUG_STREAM} used by LWJGL.</p>
*
* <p>When set programmatically, it can also be a {@link PrintStream} instance.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugStream</b><br>
* Type: String or a {@link PrintStream} instance<br>
* Usage: Static</p>
*/
public static final Configuration<Object> DEBUG_STREAM = new Configuration<>("org.lwjgl.util.DebugStream", StateInit.STRING);
/**
* Set to true to enable LWJGL's debug mode for the {@link MemoryUtil} explicit memory management API
* ({@link MemoryUtil#memAlloc memAlloc}/{@link MemoryUtil#memFree memFree}/etc).
*
* <p>All memory allocations through that API will be tracked and leaks will be reported on JVM exit. The {@code memReport} methods can also be used.</p>
*
* <p>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 {@code -XX:MaxJavaStackTraceDepth=d} (where {@code d >= 6}) can be used to reduce the overhead.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugAllocator</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DEBUG_MEMORY_ALLOCATOR = new Configuration<>("org.lwjgl.util.DebugAllocator", StateInit.BOOLEAN);
/**
* Set to false to disable tracking of internal memory allocations, in native shared libraries that have been set up to use the LWJGL memory allocator.
*
* <p>If this option is not set, it defaults to true.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugAllocator.internal</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DEBUG_MEMORY_ALLOCATOR_INTERNAL = new Configuration<>("org.lwjgl.util.DebugAllocator.internal", StateInit.BOOLEAN);
/**
* Set to true to skip stacktrace generation on each tracked allocation.
*
* <p>When enabled, this option dramatically reduces the performance overhead of memory leak detection. After a leak is detected, disable this option and
* rerun the application to get the offending allocation's stacktrace.</p>
*
* <p>This option can also be dynamically toggled on and off, to limit the performance impact in specific portions of the application that are prime
* suspects for memory leaks.</p>
*
* <p>When reporting memory allocation aggregates, with
* {@link MemoryUtil#memReport(MemoryAllocationReport, MemoryAllocationReport.Aggregate, boolean) memReport} and the options
* {@link MemoryAllocationReport.Aggregate#GROUP_BY_METHOD GROUP_BY_METHOD} or
* {@link MemoryAllocationReport.Aggregate#GROUP_BY_STACKTRACE GROUP_BY_STACKTRACE}, memory allocations without an associated stacktrace will not be
* included.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugAllocator.fast</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<Boolean> DEBUG_MEMORY_ALLOCATOR_FAST = new Configuration<>("org.lwjgl.util.DebugAllocator.fast", StateInit.BOOLEAN);
/**
* Set to true to enable LWJGL's debug mode for the {@link MemoryStack}.
*
* <p>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.</p>
*
* <p>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 {@code -XX:MaxJavaStackTraceDepth=d} (where {@code d >= 5}) can be used to reduce the overhead.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugStack</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DEBUG_STACK = new Configuration<>("org.lwjgl.util.DebugStack", StateInit.BOOLEAN);
/**
* When enabled, a warning message will be output to {@link #DEBUG_STREAM} when LWJGL fails to retrieve a function pointer.
*
* <p>This option may generate a lot of output and false negatives for functions in unused classes.</p>
*
* <p>This option requires {@link #DEBUG} to be enabled.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.util.DebugFunctions</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> DEBUG_FUNCTIONS = new Configuration<>("org.lwjgl.util.DebugFunctions", StateInit.BOOLEAN);
// -- ASSIMP
/** Similar to {@link #LIBRARY_NAME} for the AssImp library (<b>org.lwjgl.assimp.libname</b>). */
public static final Configuration<String> ASSIMP_LIBRARY_NAME = new Configuration<>("org.lwjgl.assimp.libname", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the Draco library (<b>org.lwjgl.assimp.draco.libname</b>). */
public static final Configuration<String> ASSIMP_DRACO_LIBRARY_NAME = new Configuration<>("org.lwjgl.assimp.draco.libname", StateInit.STRING);
// -- BGFX
/** Similar to {@link #LIBRARY_NAME} for the BGFX library (<b>org.lwjgl.bgfx.libname</b>). */
public static final Configuration<String> BGFX_LIBRARY_NAME = new Configuration<>("org.lwjgl.bgfx.libname", StateInit.STRING);
// -- CUDA
/** Similar to {@link #LIBRARY_NAME} for the CUDA Driver library – nvcuda (<b>org.lwjgl.cuda.libname</b>). */
public static final Configuration<String> CUDA_LIBRARY_NAME = new Configuration<>("org.lwjgl.cuda.libname", StateInit.STRING);
/**
* This option can be used to force a specific CUDA Toolkit version.
*
* <p>By default, when LWJGL detects multiple CUDA Toolkits, it will use the toolkit with the greatest version.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.cuda.toolkit.version</b><br>
* Usage: Static</p>
*/
public static final Configuration<String> CUDA_TOOLKIT_VERSION = new Configuration<>("org.lwjgl.cuda.toolkit.version", StateInit.STRING);
/**
* This option can be used to load toolkit libraries from a non-standard installation folder.
*
* <p>By default, LWJGL will try to detect CUDA Toolkits in the default installation folder.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.cuda.toolkit.path</b><br>
* Usage: Static</p>
*/
public static final Configuration<String> CUDA_TOOLKIT_PATH = new Configuration<>("org.lwjgl.cuda.toolkit.path", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the CUDA NVRTC library (<b>org.lwjgl.cuda.nvrtc.libname</b>). */
public static final Configuration<String> CUDA_NVRTC_LIBRARY_NAME = new Configuration<>("org.lwjgl.cuda.nvrtc.libname", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the CUDA NVRTC Builtins library (<b>org.lwjgl.cuda.nvrtc-builtins.libname</b>). */
public static final Configuration<String> CUDA_NVRTC_BUILTINS_LIBRARY_NAME = new Configuration<>("org.lwjgl.cuda.nvrtc-builtins.libname", StateInit.STRING);
/**
* To enable per-thread synchronization, set this option to {@code true} before initializing the CUDA driver.
*
* <p>By default, CUDA uses the legacy default stream. To check if the CUDA driver supports PTDS, call
* {@code org.lwjgl.cuda.CUDA.isPerThreadDefaultStreamSupported()}</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.cuda.ptds</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> CUDA_API_PER_THREAD_DEFAULT_STREAM = new Configuration<>("org.lwjgl.cuda.ptds", StateInit.BOOLEAN);
// -- EGL
/**
* Set this property to false to disable automatic initialization of the EGL library.
*
* <p>By default, LWJGL will automatically initialize the EGL library when it is first accessed.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.egl.explicitInit</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> EGL_EXPLICIT_INIT = new Configuration<>("org.lwjgl.egl.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the EGL library (<b>org.lwjgl.egl.libname</b>). */
public static final Configuration<String> EGL_LIBRARY_NAME = new Configuration<>("org.lwjgl.egl.libname", StateInit.STRING);
/** Similar to {@link #OPENGL_EXTENSION_FILTER} for the EGL library (<b>org.lwjgl.egl.extensionFilter</b>). */
public static final Configuration<Object> EGL_EXTENSION_FILTER = new Configuration<>("org.lwjgl.egl.extensionFilter", StateInit.STRING);
// -- FMOD
/** Similar to {@link #LIBRARY_NAME} for the FMOD Core library (<b>org.lwjgl.fmod.libname</b>). */
public static final Configuration<String> FMOD_LIBRARY_NAME = new Configuration<>("org.lwjgl.fmod.libname", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the FMOD Studio library (<b>org.lwjgl.fmod.studio.libname</b>). */
public static final Configuration<String> FMOD_STUDIO_LIBRARY_NAME = new Configuration<>("org.lwjgl.fmod.studio.libname", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the FMOD FSBank library (<b>org.lwjgl.fmod.fsbank.libname</b>). */
public static final Configuration<String> FMOD_FSBANK_LIBRARY_NAME = new Configuration<>("org.lwjgl.fmod.fsbank.libname", StateInit.STRING);
// -- FREETYPE
/** Similar to {@link #LIBRARY_NAME} for the FreeType library (<b>org.lwjgl.freetype.libname</b>). */
public static final Configuration<String> FREETYPE_LIBRARY_NAME = new Configuration<>("org.lwjgl.freetype.libname", StateInit.STRING);
// -- GLFW
/** Similar to {@link #LIBRARY_NAME} for the GLFW library (<b>org.lwjgl.glfw.libname</b>). */
public static final Configuration<String> GLFW_LIBRARY_NAME = new Configuration<>("org.lwjgl.glfw.libname", StateInit.STRING);
/**
* macOS only: Set this property to false to disable first thread detection on {@code glfwInit}.
*
* <p>By default, LWJGL will check if {@code glfwInit} is called on the first thread of the process. If not, an {@link IllegalStateException} will be
* thrown.</p>
*
* <p>The JVM can be launched with {@code -XstartOnFirstThread} to make the main thread the first thread of the process.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.glfw.checkThread0</b><br>
* Usage: Dynamic</p>
*/
public static final Configuration<Boolean> GLFW_CHECK_THREAD0 = new Configuration<>("org.lwjgl.glfw.checkThread0", StateInit.BOOLEAN);
// -- HARFBUZZ
/**
* Similar to {@link #LIBRARY_NAME} for the HarfBuzz library (<b>org.lwjgl.harfbuzz.libname</b>).
*
* <p>The default LWJGL HarfBuzz build does not include FreeType support and the {@code hb_ft_*} functions will not be available. However, LWJGL's FreeType
* build includes HarfBuzz and exports its full API. When working with both HarfBuzz and FreeType, the HarfBuzz bindings can be made to use FreeType's
* shared library, with one of the following ways:</p>
*
* <ul>
* <li>launch the JVM with {@code -Dorg.lwjgl.harfbuzz.libname=freetype}</li>
* <li>run {@code Configuration.HARFBUZZ_LIBRARY_NAME.set("freetype")}</li>
* <li>run {@code Configuration.HARFBUZZ_LIBRARY_NAME.set(FreeType.getLibrary())} - recommended</li>
* </ul>
*
* <p>The {@code org.lwjgl.harfbuzz.natives} module is not necessary when enabling the above.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.harfbuzz.libname</b><br>
* Type: String or a {@link SharedLibrary} instance<br>
* Usage: Dynamic</p>
*/
public static final Configuration<Object> HARFBUZZ_LIBRARY_NAME = new Configuration<>("org.lwjgl.harfbuzz.libname", StateInit.STRING);
// -- HWLOC
/** Similar to {@link #LIBRARY_NAME} for the hwloc library (<b>org.lwjgl.hwloc.libname</b>). */
public static final Configuration<String> HWLOC_LIBRARY_NAME = new Configuration<>("org.lwjgl.hwloc.libname", StateInit.STRING);
// -- JAWT
/** Similar to {@link #LIBRARY_NAME} for the jawt library (<b>org.lwjgl.system.jawt.libname</b>). */
public static final Configuration<String> JAWT_LIBRARY_NAME = new Configuration<>("org.lwjgl.system.jawt.libname", StateInit.STRING);
// -- JEMALLOC
/** Similar to {@link #LIBRARY_NAME} for the jemalloc library (<b>org.lwjgl.system.jemalloc.libname</b>). */
public static final Configuration<String> JEMALLOC_LIBRARY_NAME = new Configuration<>("org.lwjgl.system.jemalloc.libname", StateInit.STRING);
// -- KTX
/** Similar to {@link #LIBRARY_NAME} for the KTX library (<b>org.lwjgl.ktx.libname</b>). */
public static final Configuration<String> KTX_LIBRARY_NAME = new Configuration<>("org.lwjgl.ktx.libname", StateInit.STRING);
// -- LLVM
/** Similar to {@link #LIBRARY_NAME} for the LLVM library (<b>org.lwjgl.llvm.libname</b>). */
public static final Configuration<String> LLVM_LIBRARY_NAME = new Configuration<>("org.lwjgl.llvm.libname", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the LLVM/Clang Library (<b>org.lwjgl.llvm.clang.libname</b>). */
public static final Configuration<String> LLVM_CLANG_LIBRARY_NAME = new Configuration<>("org.lwjgl.llvm.clang.libname", StateInit.STRING);
/** Similar to {@link #LIBRARY_NAME} for the LLVM/LTO library (<b>org.lwjgl.llvm.clang.libname</b>). */
public static final Configuration<String> LLVM_LTO_LIBRARY_NAME = new Configuration<>("org.lwjgl.llvm.lto.libname", StateInit.STRING);
// -- NativeFileDialog
/**
* Set to true to enable NativeFileDialog's XDG Desktop Portal backend on Linux.
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.nfd.linux.portal</b><br>
* Usage: Static</p>
*/
public static final Configuration<Boolean> NFD_LINUX_PORTAL = new Configuration<>("org.lwjgl.nfd.linux.portal", StateInit.BOOLEAN);
// -- ODBC
/** Similar to {@link #LIBRARY_NAME} for the ODBC library (<b>org.lwjgl.odbc.libname</b>). */
public static final Configuration<String> ODBC_LIBRARY_NAME = new Configuration<>("org.lwjgl.odbc.libname", StateInit.STRING);
// -- OPENAL
/** Similar to {@link #EGL_EXPLICIT_INIT} for the OpenAL library (<b>org.lwjgl.openal.explicitInit</b>). */
public static final Configuration<Boolean> OPENAL_EXPLICIT_INIT = new Configuration<>("org.lwjgl.openal.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the OpenAL library (<b>org.lwjgl.openal.libname</b>). */
public static final Configuration<String> OPENAL_LIBRARY_NAME = new Configuration<>("org.lwjgl.openal.libname", StateInit.STRING);
/** Similar to {@link #OPENGL_EXTENSION_FILTER} for the OpenAL library (<b>org.lwjgl.openal.extensionFilter</b>). */
public static final Configuration<Object> OPENAL_EXTENSION_FILTER = new Configuration<>("org.lwjgl.openal.extensionFilter", StateInit.STRING);
// -- OPENCL
/** Similar to {@link #EGL_EXPLICIT_INIT} for the OpenCL library (<b>org.lwjgl.opencl.explicitInit</b>). */
public static final Configuration<Boolean> OPENCL_EXPLICIT_INIT = new Configuration<>("org.lwjgl.opencl.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the OpenCL library (<b>org.lwjgl.opencl.libname</b>). */
public static final Configuration<String> OPENCL_LIBRARY_NAME = new Configuration<>("org.lwjgl.opencl.libname", StateInit.STRING);
/** Similar to {@link #OPENGL_EXTENSION_FILTER} for the OpenCL library (<b>org.lwjgl.opencl.extensionFilter</b>). */
public static final Configuration<Object> OPENCL_EXTENSION_FILTER = new Configuration<>("org.lwjgl.opencl.extensionFilter", StateInit.STRING);
// -- OPENGL
/** Similar to {@link #EGL_EXPLICIT_INIT} for the OpenGL library (<b>org.lwjgl.opengl.explicitInit</b>). */
public static final Configuration<Boolean> OPENGL_EXPLICIT_INIT = new Configuration<>("org.lwjgl.opengl.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the OpenGL library (<b>org.lwjgl.opengl.libname</b>). */
public static final Configuration<String> OPENGL_LIBRARY_NAME = new Configuration<>("org.lwjgl.opengl.libname", StateInit.STRING);
/**
* Can be used to limit the maximum available OpenGL version.
*
* <p>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 {@link APIUtil.APIVersion} instance.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.opengl.maxVersion</b><br>
* Type: String (M.n) or an {@link APIUtil.APIVersion} instance<br>
* Usage: Static</p>
*/
public static final Configuration<Object> OPENGL_MAXVERSION = new Configuration<>("org.lwjgl.opengl.maxVersion", StateInit.STRING);
/**
* Can be used to disable specific extensions.
*
* <p>This can be useful to ensure that an application behaves correctly with or without an extension. Supported values:</p>
* <ul>
* <li><em>comma-delimited string</em> - A list of extension names to disable.</li>
* <li><em><classpath></em> - A class that implements the {@link Predicate Predicate<String>} interface. It will be instantiated using reflection.</li>
* </ul>
*
* <p>When set programmatically, it can also be:</p>
* <ul>
* <li><em>a {@link java.util.List List<String>} instance</em> - A list of extension names to disable.</li>
* <li><em>a {@link Predicate}<String> instance</em> - A predicate that accepts an extension name and returns true if it should be disabled.</li>
* </ul>
*/
public static final Configuration<Object> OPENGL_EXTENSION_FILTER = new Configuration<>("org.lwjgl.opengl.extensionFilter", StateInit.STRING);
// -- OPENGL ES
/** Similar to {@link #EGL_EXPLICIT_INIT} for the OpenGL ES library (<b>org.lwjgl.opengles.explicitInit</b>). */
public static final Configuration<Boolean> OPENGLES_EXPLICIT_INIT = new Configuration<>("org.lwjgl.opengles.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the OpenGL ES library (<b>org.lwjgl.opengles.libname</b>). */
public static final Configuration<String> OPENGLES_LIBRARY_NAME = new Configuration<>("org.lwjgl.opengles.libname", StateInit.STRING);
/** Similar to {@link #OPENGL_MAXVERSION} for the OpenGL ES library (<b>org.lwjgl.opengles.maxVersion</b>). */
public static final Configuration<Object> OPENGLES_MAXVERSION = new Configuration<>("org.lwjgl.opengles.maxVersion", StateInit.STRING);
/** Similar to {@link #OPENGL_EXTENSION_FILTER} for the OpenGL ES library (<b>org.lwjgl.opengles.extensionFilter</b>). */
public static final Configuration<Object> OPENGLES_EXTENSION_FILTER = new Configuration<>("org.lwjgl.opengles.extensionFilter", StateInit.STRING);
/**
* Defines the API that manages OpenGL ES contexts.
*
* <p>Supported values:</p>
* <ul>
* <li><em>EGL</em> - context management is provided by EGL.</li>
* <li><em>native</em> - context management is provided by the native platform.<br>
* </ul>
*
* <p>If this option is not set, LWJGL will first attempt to use EGL. If EGL is not available, it will attempt to use the native platform API.</p>
*
* <p style="font-family: monospace">
* Property: <b>org.lwjgl.opengl.contextAPI</b><br>
* Type: String<br>
* Usage: Dynamic</p>
*/
public static final Configuration<String> OPENGLES_CONTEXT_API = new Configuration<>("org.lwjgl.opengles.contextAPI", StateInit.STRING);
// -- OPENVR
/** Similar to {@link #LIBRARY_NAME} for the OpenVR library (<b>org.lwjgl.openvr.libname</b>). */
public static final Configuration<String> OPENVR_LIBRARY_NAME = new Configuration<>("org.lwjgl.openvr.libname", StateInit.STRING);
// -- OpenXR
/** Similar to {@link #EGL_EXPLICIT_INIT} for the OpenXR library (<b>org.lwjgl.openxr.explicitInit</b>). */
public static final Configuration<Boolean> OPENXR_EXPLICIT_INIT = new Configuration<>("org.lwjgl.openxr.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the OpenXR library (<b>org.lwjgl.openxr.libname</b>). */
public static final Configuration<String> OPENXR_LIBRARY_NAME = new Configuration<>("org.lwjgl.openxr.libname", StateInit.STRING);
// -- OPUS
/** Similar to {@link #LIBRARY_NAME} for the Opus library (<b>org.lwjgl.opus.libname</b>). */
public static final Configuration<String> OPUS_LIBRARY_NAME = new Configuration<>("org.lwjgl.opus.libname", StateInit.STRING);
// -- SHADERC
/** Similar to {@link #LIBRARY_NAME} for the Shaderc libshaderc library (<b>org.lwjgl.shaderc.libname</b>). */
public static final Configuration<String> SHADERC_LIBRARY_NAME = new Configuration<>("org.lwjgl.shaderc.libname", StateInit.STRING);
// -- SPVC
/** Similar to {@link #LIBRARY_NAME} for the SPIRV-Cross library (<b>org.lwjgl.spvc.libname</b>). */
public static final Configuration<String> SPVC_LIBRARY_NAME = new Configuration<>("org.lwjgl.spvc.libname", StateInit.STRING);
// -- VULKAN
/** Similar to {@link #EGL_EXPLICIT_INIT} for the Vulkan library (<b>org.lwjgl.vulkan.explicitInit</b>). */
public static final Configuration<Boolean> VULKAN_EXPLICIT_INIT = new Configuration<>("org.lwjgl.vulkan.explicitInit", StateInit.BOOLEAN);
/** Similar to {@link #LIBRARY_NAME} for the Vulkan library (<b>org.lwjgl.vulkan.libname</b>). */
public static final Configuration<String> VULKAN_LIBRARY_NAME = new Configuration<>("org.lwjgl.vulkan.libname", StateInit.STRING);
private interface StateInit<T> extends Function<String, T> {
StateInit<Boolean> BOOLEAN = property -> {
String value = System.getProperty(property);
return value == null ? null : Boolean.parseBoolean(value);
};
StateInit<Integer> INT = Integer::getInteger;
StateInit<String> STRING = System::getProperty;
}
private final String property;
@Nullable
private volatile T state;
Configuration(String property, StateInit<? extends T> init) {
this.property = property;
this.state = init.apply(property);
}
public String getProperty() {
return property;
}
/**
* Sets the option value.
*
* @param value the value to set
*/
public void set(@Nullable T value) {
this.state = value;
}
/**
* Returns the option value.
*
* <p>If the option value has not been set, null will be returned.</p>
*/
@Nullable
public T get() {
return state;
}
/**
* Returns the option value.
*
* <p>If the option value has not been set, the specified default value will be returned.</p>
*
* @param defaultValue the default value
*/
public T get(T defaultValue) {
T state = this.state;
if (state == null) {
state = defaultValue;
}
return state;
}
}