Blog

The VulkAda Project

by | Sep 25, 2020

My current game project is being written in C++, which is my second favorite programming language.  My favorite is Ada.

Ada doesn’t get that much attention among most programmers and it’s a shame.  My favorite way to describe it is “C++ without all the C baggage.”  Whenever people talk about wanting a better C++, I tell them that it already exists.  It’s called Ada.

For those unfamiliar with it, Ada was originally developed for the US Department of Defense.  Ada is a language that doesn’t fool around.  It was designed for the sort of programming where bugs are completely unacceptable.  Software where glitches could have disasterous consequences.  Think air-traffic control systems, missile guidance, railway switching, and so on.  Over the years, Ada has evolved into a robust and full-featured general programming language.  It’s the only language I’m aware of that can stand toe-to-toe with C++ in terms of features.  I love it.

I’ve been toying with game development in Ada for several years.  I’ve done a few toy-projects, and one very large one that unfortunately never made it across the finish line.  It’s a fine language for that sort of work.  The only problem is libraries.

I love writing library interfaces for Ada.  In the past I’ve done complete Ada bindings for both OpenAL and OpenGL.  I really want to do my next PC project in Ada, and I also want to make the jump to from OpenGL to Vulkan.  Thus, the VulkAda project was born.

If there’s already an Ada binding for Vulkan, I haven’t found it.  Even if there is one, I still want to make my own.  Most Ada interfaces to C APIs aren’t very Ada-like.  GCC even includes a tool that will generate Ada specification files from C headers.  They work, but they’re awkward to use due to fundamental differences in the languages.  String handling is an excellent example.  Ada strings and C strings are incompatible with each other.  Ada provides all the tools necessary to convert to back and forth, but it’s pain to do this in user code so I want this nonsense wrapped up.

VulkAda is something I work on when I have nothing else to do.  It’s a long tedious process, but I’m finally starting to see the light at the end of the tunnel.  I’ve nearly completed the Vulkan 1.0 API.  My C header goes up to 1.2, so that’s where I’ll stop for now.  Check this out:

Here’s some simple test code I wrote using my Vulkan interface.  It doesn’t do much, just queries the video card for some properties and creates a Vulkan instance, but it works!  I have a matching C program that I compare the output with and it’s an exact match, so I must be doing something right.  Running this little program produces this:

This is the list of Vulkan layers supported by my video card.  I have no idea what a Vulkan layer is, but there they are!

Oh yeah, that’s the other fun thing about this.  Despite binding most of the Vulkan 1.0 API, I’ve still never really used Vulkan.  I still have a lot to learn.

When I start my next game, which for now shall be referred to as “Untitled Frooty Project,” I’ll finally get the chance to give this stuff a thorough testing.  I plan to make VulkAda available once that project starts, with the understanding that it’s a work-in-progress and parts of it will almost certainly change as my game develops and I find bugs.  Fun stuff, and I can’t wait to start working with it.

 

Join Our Community


Find Us In Any Of These Sweet Places

Contact Us

We would love to hear from you. Please use this form to contact us, and we will get back to you as soon as possible!

12 + 8 =