Hello, I have been binge following the recordings of HandMade Hero streams, reimplementing the code and taking notes. I am still in the initial episodes, going through the grunge work of dealing with the Windows OS to create a window and displaying bitmaps into the window client area, etc. It is very illuminating to me because I have only ever programmed in the terminal before. Casey sometimes refered that the Handmade Hero game would work on multiple platforms, but browsing through the video titles I have not found any Linux layer or Mac layer titled videos. Did the windows grunge work of setting up a prototype OS interface layer annoy him so much that he was postponing the Linux and Mac OS interface layers to when he got close to the proverbial shipping of the game?
Because, since the original idea is to implement as much of the code that the game was going to use by hand, things like using SDL were off the radar, which probably means that there would need to be specific code to interface with X11 in Linux, right? (As Wayland wasn't available at the time); and I think Macs use quartz or something, right? Or is there a way to make the code that integrates with the windowing environment by just using OpenGl and the POSIX API that basically every OS, that isn't Windows, uses?
I just ask because he talked about perhaps removing the C runtime library from the generated executable if there was time and interest some times, and sure enough, there seems to be something about that in day 435 - Removing the CRT from the Win32 Loader, although this may not exactly be what he was referring in the first streams. There are some videos with titles such as platform independent user input, or platform independent sound output, perhaps in those he says how to make the game open windows in the posix compliant OS's; but I have the impression that these videos have more to do with making the program conform with certain formats, like audio formats and I/O encoding.
I don't want to in any way sound ungrateful, Casey deserves all the merit in the world for setting his mind into showing to the world how good software development can be done from the bottom up, in particular in game development, and keeping with that effort for 8 years in Handmade Hero. Casey Muratori should be awarded a medal for that, and, I know it is kind of selfish of me to say this, I hope that some day he may return to doing Handmade Hero streams, IF only for finishing the game, I think that after 667 streams the ones accompaning are already familiar with most of the ins and outs, and don't really require such attention to details as he has kindly done in all of the recorded streams that I have seen so far.
Casey never did linux or Mac OS platform layer.
One of the reason for doing that at the end of the project is that at that point you know what you really need for the game. Also if you do it early, you "have to" maintain several platform working and that doesn't bring any value, in fact it takes some of your time working on the game away. You'd do it only if you need to ship to people before the end (previews, beta...) but even then, according to the steam hardware survey (February 2025) Windows is 97.58% of the market, so it might not be worth it.
For doing the platform layer on different platforms, I think it would be better to use each operating system API, to be able to take advantage of specific feature. For example on windows use CreateThread
, don't try to use POSIX threads.
Several thing in Handmade Hero, would probably be written differently if Casey did the series now. The main example for me would be to use DirectX 11 instead of OpenGL (it's just better on Windows). In a similar way you wouldn't use OpenGL on Mac (I think you can't really anymore) but their native API. On linux OpenGL might still be the "best" way (not everybody agrees on Vulkan).
The videos about platform independent things are about defining an API that the game use to communicate with the platform, so that if you change to another platform, the game code doesn't need to change, only the platform code changes.
The CRTÂ never got fully removed, but if I remember correctly there were only a few trigonometry functions (sin/cos/tan) from the CRT that were used.
Several people made platform layer for linux and Mac. You might find some if you search the forums or you could ask on the handmade network discord (where most people are). It's also fine to use SDL if you want. HMH is more about learning how to program, than providing a ready to use platform layer/game engine. If you need to switch from SDL later, you should be able to do it.
Thanks for the answer Simon Anciaux,
that does make a lot of sense, in fact I thought that was the case. I just had some doubt because on the first or second streams he did say briefly that he would first finish the win32 layer and then go on to do Linux/Mac so that those people in these platforms could also follow the streams. I am very new to programming with windows/GUI/graphics, so I thougt that perhaps Linux or MacOS were easier to set up a basic window and then to just print the bitmap buffer into them, from what you appear to be saying is that Handmade Hero ends up needing to use much more from Windows OS than just setting up a window, a way to print to it, and perhaps some I/O like mouse position, mouse clicks, keyboard input and optionally controller input.
I certainly can see how doing each OS with a dedicated layer can be better than using SDL, but if to do a dedicated layer you need to delve into the idiosyncrasies of how each OS decides to deal with displaying graphics, window buttons, etc. I can see also why it would be a lot more sane to just use SDL and write a single code that runs on more systems than you would care to make a dedicated layer by hand, like the BSD systems (may be different from X11?) and other OS's like android or obscure ones.
There was this tutorial following along when Casey was doing the series, which was SDL with Linux. The Posix functions in the tutorial mostly also work on Mac.