Home
Break Arcade Games Out
Aug. 2022
The title screen of Break Arcade Games Out, originally by Dan Zaidan
I was looking for a way to generate random numbers without using the rand() function, and I stumbled upon this video by Dan Zaidan (Implementing a Random Number Generator Algorithm in C (from scratch)).
It explored the xorshift algorithm by George Marsaglia. Many years later, this is still my PRNG of choice, and I wrote my own little library for it that I use pretty much any time I need something better than rand().
This video eventually led me into a rabbit hole of exploring game porting, and was the project that got me interested in porting software as a whole.
I started my initial port in December 2021. At this time, I had an OpenGL / GLFW, X11, and SDL2 port respectively. I didn't know what I know now about porting software, so every API / platform layer was pretty much written from scratch, with very little code reuse. However, this taught me a lot, and allowed me to explore different approaches in each port.
A few weeks after I began my work, I had a very crude port for each API, full of bugs and inconsistencies.
Sound was still out of the question at this point, as I had never worked with it before.
In April 2022, I started looking into getting sound working. I chose OpenAL as my API of choice, and slowly began uncommenting all of the sound code that I #ifdefed out initially. Again, I had no idea how to properly port missing API calls, so things like stubbing out function calls or making dummy interfaces for things one would implement later were foreign concepts to me. Instead, the code was a slew of #ifdef LINUX_NO_SOUND macros that I slowly had to untangle.
Eventually, I wrote a simple wrapper for OpenAL that worked with the existing sound API that the game used.
For SDL, I also wrote a similar audio layer using SDL_mixer.
ThinMatrix has a very nice introductory series to OpenAL which I highly recommend.
Dan, if you ever read this, thank you. I wish you all the best!
Shader Playground
Feb. 2022
A version of "Over the Moon" by Martin from The Art of Code
In early 2022, I wanted to learn shaders. My only prior experience with 3-D graphics was using the OpenGL fixed-function pipeline, and, not knowing anything about 3-D graphics, it was very overwhelming at first. I recall spending about 4 to 5 hours figuring out how to move a 2D rectangle in the vertex shader (I had almost no knowledge about matrices or the concept of NDC space at the time, other than the fact that calling glOrtho() with a width and height could set up a 2D drawing area).
Suffice to say, a better way was needed.
I stumbled upon The Art of Code, which introduced me to shaders in a much better way than whatever I was doing previously (I honestly do not remember how I was approaching learning shaders before). The author of the videos (Martin) was using Shadertoy for his instructional videos, which provided an excellent way to iterate.
Desiring something similar offline, I wrote program that created an OpenGL window and rendered the output of the vertex and fragment shaders.
It also tracked the timestamp of the vertex, and fragment shader files respectively. Whenever the program detected that the timestamps were updated, it reloaded the shaders, providing an almost instant feedback loop for doing edits. On error, the error message would be displayed to the console, and the screen would turn red as a visual cue to indicate that something was wrong.
With the main program written, I was able to follow along with Martin's videos, enjoying many an evening coding along and exploring how shaders worked. At the time, I did not seek to completely re-create Shadertoy, so this version did not have things like image loading or some of the more advanced features. Just getting that feedback loop was enough for me. Naturally, this meant that some videos were not possible to complete, as they relied on things like loading external images, or reading from multiple framebuffers / textures, but the majority of videos that interested me were entirely doable from within this simple program.
Thank you Martin.
Back to top