For game development I have been using LWJGL3 which is a great Java library for cross-platform development. Among other things it has bindings for Ope

Implementing GUIs using Clojure and LWJGL Nuklear bindings · Jan Wedekind

submited by
Style Pass
2024-05-11 00:00:06

For game development I have been using LWJGL3 which is a great Java library for cross-platform development. Among other things it has bindings for OpenGL, GLFW, and STB. Recently I discovered that it also has Nuklear bindings. Nuklear is a small C library useful for developing GUIs for games. It receives control input and commands to populate a GUI and converts those into render instructions. Nuklear focuses solely on the user interface, while input and graphics backend are handled by the application. It is therefore very flexible and can be integrated into a 3D game implemented using OpenGL, DirectX, Vulkan, or other.

LWJGL Nuklear bindings come with the GLFWDemo.java example. In this article I have basically translated the input and graphics backend to Clojure. I also added examples for several different controls. I have pushed the source code to Github if you want to look at it straight away. A big thank you to Ioannis Tsakpinis who developed LWJGL and GLFWDemo.java in particular.

The demo is more than 400 lines of code. This is because it has to implement the graphics backend, input conversion, and truetype font conversion to bitmap font. If you are rather looking for a Clojure GUI library which does not require you to do this, you might want to look at HumbleUI. There also is Quil which seems to be more about graphics and animations.

Leave a Comment