Game Engine Attempt 1
This project started off as a result of playing around with Vulkan, and taking a graphics course. I realized having a real time graphics rendering applciation is half the battle to building a game engine so I figured I would sit down and try to build a game engine along side a simple city builder for fun. This may end up being more of a Post-Mortem than a recollection as I vividly remember some decisions I made and issues I ran into that will be fun to show off.
Background
My graphics course was in WebGL which is already pretty far removed from desktop graphics API's in a sense, about halfway through the course I decided I wanted to mess with vulkan for the sake of it.
Vulkano
I found vulkano suggested in some older threads as it was being developed by the creator of the glutin, a commonly used OpenGL library for rust. There was already mentions of the developer abandoning the project, but it had the best looking example code and I liked how it utilized macros natively to do shader stuff. I realize now this was likely a mistake, but it was before wgpu really took off, so I can forgive myself there. At the very least the library didn't try to hide too much of the raw vulkan stuff, its main purpose was to create a safe wrapper as far as I can recall. This also meant I spent many late nights trying to figure out vulkan via a game of telephone through the vulkano documentation which I would now assume is bad form.
Math is fun
Due to the ease of adding dependencies in rust and the desire for high interopability between crates, a lot of rust projects will utilize some esoteric math library to do the heavy lifting. For this project I figured it would be simpler to just spin up a math module with vectors and matrices up to 4 by 4. This way I could make up ground on the vulkan handwaving by getting into the messiness that comes with implementing a lot of pretty cool linear algebra logic; such as calulating the determinate of a 3x3 matrix , or inverting a 4x4 matrix. This process also converted me from a row major believer into a column major one for matrices, even though it goes against my inherent computer scientist bias.
Cameras are hard
I have many videos demonstrating strange behaviors as a result of producing bad camera matrices. My favorite is actually not the camera's fault but a result of a flipped sign in calculating mouse collision with objects in the world. I rigged up what was akin to a debug drawing mode that showed the collisions with objects in the world after clicking so I could rotate around and get a sense of what was happening. I was able to ultimately get it working but as previously mentioned, it broke again after updating vulkano to a new version 🙃. If you ever wanted to know how to detect a collision on cube in 3D space in a custom game engine in Rust, look no further, I have you covered.
Key takeaways
I was really just trying to run before I could walk, I had a rough working understanding of basic graphics programming topics and I further abstracted things away by picking a library that kind of hid enough stuff that I really did not know what was happening. When a major API change came around a year or so later I had no real clue where to start and I kind of resolved to let it be. The code around the rendering is useful, and I will likely reuse it for future forays into this space, but it will likely be in a spinoff rather than a refactor.