Whenever I want to start a new project with Raylib I used to start from a simple template, which I’ve now dusted off revamped and added a second version with the addition of Nuklear to provide a GUI, I simply do a quick
cp -a Template MyNewProject
And I’m ready to start on my next
mad idea adventure! The templates have the following features:
- Convenient Makefile, put new source code in the src directory and its automagically compiled into the project
- Targets to provide debug, instrumentation and release versions.
- “Letterbox” scaling so your application has the same aspect ratio as it started with.
- flipping to fullscreen mode changes the resolution to match that of the current monitor resolution.
- returning from fullscreen changes the window size back to its original (start size) and centres the window.
- Includes a simple 3D lighting shader, to improve the look of your models.
- V-Sync to avoid excessive load and tearing caused by wait timers on some system (you must use delta values when moving stuff).
- None GUI version just 102 lines excluding blank lines and comments, according to ssc
- Clipboard support and cursor key repeat moderation in edit boxes
- Nuklear GUI boiler plate inside a separate unit, with convenience functions provided.
There is the least to say about the none GUI version as without the complication of a GUI it’s far simpler, despite being reasonably compact it includes a good solid set of features that’s nice or even essential to have in any project. I’ve spent a fair bit of time in making it both simple to use and not overly complex, while keeping an eye towards flexibility.
I have to say I was a little lukewarm about the look of Nuklear out of the box, I looked at the single theme provided and realised making my own would be a lot of pixel work and specifying lots of coordinates, so I shelved it. It was only when refreshing my previous work with Nuklear that I added a colour style and relied much more on dynamic layout, I hope you’ll agree just from looking at the above screenshot it looks quite smart.
I’ve only used Nuklear in about 3-4 projects now, so it’s not impossible I’m doing the layout wrong especially in regards to the padding, but how you layout a GUI for yourself is up to you, there is enough example use of different widgets that it should give you a solid start with Nuklear, at first it can be a little bit of an uphill struggle to get used to.
You would be forgiven for thinking that a “simple” template should be easy to throw together, and indeed my first take at a template was just thrown together, part of the motivation for doing this was repeatedly adding the same features from different projects and thinking “I really must update that template”. I think it’s also been worth all the extra effort I put in to make it both flexible and easy to use, with an eye towards what other people might find helpful. In the end I’ve ended up with something far better than what I started with.
Looking with scc, it thinks I’m giving away £10,000 of code between the two templates, I must be mad ! But if you want a shock look how much it thinks the cost of developing Nuklear would be, now that’s expensive !
You might notice that there is a windows version of the make file, to be honest I don’t use Windows very often at all and it may well be you could have issues with it. I’d appreciate feedback on this and for that matter generally too.
The template is available here
The GUI version is available here