Hello Guest

How different Lwjgl and C++ opengl implementation?

  • 2 Replies
  • 315 Views
How different Lwjgl and C++ opengl implementation?
« on: March 22, 2018, 14:26:19 »
Greetings,
I have seen some great tutorials for Opengl in C++, but I wish to use lwjgl simply because memory management is easier.
I'd like to ask, can I just read the opengl C++ code (opengl 3.3) and write it down mirror-like in lwjgl? I know lwjgl is a wrapper to c++ calls, but how different the two? At first glance they looked pretty much the same.
Further, how stable is lwjgl?
Thanks :)
« Last Edit: March 22, 2018, 14:53:07 by tamask »

*

Offline KaiHH

  • ***
  • 108
Re: How different Lwjgl and C++ opengl implementation?
« Reply #1 on: March 22, 2018, 15:26:31 »
LWJGL provides JNI methods to (currently) C-only APIs, such as OpenGL, OpenAL, OpenCL, Vulkan, etc. NOT C++ APIs.
LWJGL tries to mirror the C functions via static Java methods as close as possible. For example, the function names are the same, the parameter order is the same and primitive integer and floating point arguments are the same. What naturally is different to C is address/pointer handling. Where you write char* in C you use a String, ByteBuffer or other NIO buffers in LWJGL, depending on the pointer type and level of indirection.

You should totally read this GitHub Wiki entry: https://github.com/LWJGL/lwjgl3-wiki/wiki/1.4.-Bindings-FAQ

And also this blog entry for memory management in LWJGL 3: https://blog.lwjgl.org/memory-management-in-lwjgl-3/

LWJGL 3 is very stable. I've never had any problems that could not have been solved in a few hours by @Spasi (the project owner). He is devoted to his project and will react on very short notice to any bugs. However, do note that LWJGL provides JNI _bindings_ to other third-party libraries, such as GLFW. If you find any bugs in them, the time to actually land a fix might vary.
But concerning the OpenGL API, you can pretty much be certain that LWJGL 3 is rock solid in that area.
« Last Edit: March 22, 2018, 21:43:10 by KaiHH »

Re: How different Lwjgl and C++ opengl implementation?
« Reply #2 on: March 22, 2018, 15:40:29 »
Thanks for the reply.
Exactly what I was after :D
I have seen a difference with `GLFWwindow*` c++ and `long` Java already - but I believe this is written nicely in the docs you sent me.
And you answered perfectly what I was asking: it's a direct mirror of the C++ version. Any memory management mismatch can be handled via the docs you linked so I can comfortably develop along C++ code tutorials.