lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3

Home Page:https://ahbejarano.gitbook.io/lwjglgamedev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No need for off-heap Buffers in LWJGL 3

jakobkmar opened this issue · 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 for glBufferData
  • ShaderProgram for glUniformMatrix4fv (here value.get(stack.mallocFloat(16)) can be replaced with value.get(new float[16])
  • Texture where in loadTexture a ByteBuffer is still necessary because stbi_load does only return this type, but the buffers of w h and channels 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.