No need for off-heap Buffers in LWJGL 3
jakobkmar opened this issue · 3 comments
The tutorial uses Buffers allocated in off-heap a lot.
But this is not necessary since LWJGL 3.
https://github.com/LWJGL/lwjgl3/releases/tag/3.0.0
LWJGL/lwjgl3#175
So in a lot of cases it would be easier to just use arrays.
I have currently only followed the tutorial to Loading more complex models and the following are parts where I remember Buffers being used:
Mesh
forglBufferData
ShaderProgram
forglUniformMatrix4fv
(herevalue.get(stack.mallocFloat(16))
can be replaced withvalue.get(new float[16])
Texture
where inloadTexture
aByteBuffer
is still necessary becausestbi_load
does only return this type, but the buffers ofw
h
andchannels
can be replaced with normal arrays
Hi Jakob,
It seems that Hotspot Critical Natives is considered an undocumented feature with some bugs. You can see some thoghts about this from Spasi here:
So, by now I would not use them, at least in the initialization code, which would get little benefit from this change. In any case, I would leave this open until LWGL 3.3 is released, beacuse it is supposed to get some updates on this issue. Plesae, let me know your view on this.
Best regards.
Hey,
after reading through this I would leave this issue here open until the release of LWJGL 3.3 and then look at it again.
I think it is more important that this tutorial uses practices which work than having good readability.