Summary
LWJGL is a Java library for cross-platform development. Nuklear is a small C library useful for developing GUIs for games. It has bindings for OpenGL, GLFW, and STB, and can be integrated into a 3D game.
An array buffer containing the position, texture coordinates, and colors is allocated. An element array buffer is allocated which contains element indices. A Nuklear library needs to be configured with the same layout of the array buffer. The Nukleartest code compiles and links the shaders and checks for possible errors.
OpenGL needs to be configured for rendering the Nuklear GUI. Blending with existing pixel data is enabled and the blending equation and function are set. Depth testing is disabled and Scissor testing is enabled. The first texture slot is enabled to create a texture.
The rendering backend sets the viewport and then array buffers for the vertices and indices. Then the buffers are mapped to memory resulting in the two java.nio.DirectByteBuffer objects “vertices” and “elements” The two static buffers are then converted to Nuklear buffer objects. A loop then is used to get chunks of type NkDrawCommand from the render buffer.
Directions for the NkText font can be found at the bottom of the page. The Nktext font can now be used to create a full-size version of the NKText font. The full version of Nk Text can be seen at the top of the screen.
The following code adds a main menu with an exit item to the window. One can add option labels to implement a choice between different options. Property widgets let you change a value by either clicking on the arrows or by clicking and dragging across the widget. There is a screenshot with a screenshot of the result.
A combo box lets you choose an option using a drop down menu. It is even possible to have combo boxes with multiple columns. It's possible to use draw commands to draw a custom widget. There are also methods for checking if the mouse is hovering over the widget or if theMouse was clicked.
Except for undo and redo I managed to get the keyboard combinations from the GLFWDemo.java example to work. Now it is possible to move the cursor in the text box and also delete characters. Clipboard and other Control Key Combinations Finally one can implement some Control key combinations.
There are still more things to explore. Check out the LWJGL Nuklear package documentation. The Nuklear Usage Guide by The Coding Fox is a good place to start. The Coder's Handbook is a guide to the best ways to use the Nukulele.