everything in lwjgl not ordinary parameters like floats, int etc. are direct buffers of some kind, including write back parameters from GL.
So to make genTextures work, youād have to do something like:
ByteBuffer buf = ByteBuffer.allocateDirect(4);
buf.order(ByteOrder.nativeOrder());
IntBuffer int_buf = buf.asIntBuffer();
GL.genTextures(1, Sys.getDirectBufferAddress(int_buf));
if (int_buf.buffer().get(0) == 0)
throw new RuntimeException("Could not allocate new texture id!");
return int_buf.get(0);
Likewise, when you want to upload pixel data into a GL texture, it has to be in a buffer and given as an address to GL through Sys.getDirectBufferAddress(ā¦).
It might seem overly complicated, but it really is a the fastest way to call GL, that is using explicit C pointers.
Sys.getDirectBufferAddress() returns the int pointer address of a direct buffer (DONāT use a non-direct buffer), and thatsā why for every gl function taking an array or simply a pointer, an int is taken by lwjgl.
Donāt scare yourself because of this, lwjgl is really a slick binding, and almost every user of it (I believe) simply encapsulates the behaviour in utility classes.
The lwjgl author also released spgl (also on sourceforge) that sits on top of lwjgl and exposes more friendly behaviour.