Closed CiroZDP closed 1 month ago
Atomic integers (and other atomic types) are meant for synchronization between threads, and are probably much more expensive than simple arrays. Besides, they can only store 1 value, whereas some LWJGL function require longer arrays.
Question
Java provides us with several classes for this purpose: AtomicInteger and AtomicLong (there are more). These classes hold a value which is usually a number or a decimal number. The values contained in these classes can be changed at any time and can be used as an argument in a method.
For example, there are functions in glfw that allow you to get the mouse position, these functions use an array of doubles to represent a pointer, but, in my humble opinion, I think it would be a good idea to replace these arrays with something that "makes more sense".
Some ideas:
Thanks in advance.
EDIT: There are no atomical classes for decimal numbers, but you can use
AtomicReference<Double> dptr = new AtomicReference<>();
for creating a atomical reference to any double number.