Game Programming C++, Sanjay Madhav, 2018
This is the book I would recommend as an intro to gamedev.
Yes, it uses the STL and yes, it does make use of
inheritance and even talks about dependency injection.
Don’t let yourself fall into the trap of
rejecting this material just because very experienced
programmers despise the STL and anything that comes close
to object oriented programming. It is true that
especially the STL brings many problem to the table that,
especially in the beginning, won’t be obvious. But to be honest,
if you’re just starting out you can only afford to keep
so much in your head. And there is plenty of other stuff
like understanding how to capture input, how to open
a window, how to render graphics into it, how to load and
write files from/to disk, etc. And this book has it all.
It will show you how you can write your own sprite-based
2D-Asteroids and builds up from there until you can run around
in 3D and shoot projectiles into the 3D world. I enjoyed his
explanation and implementation of the Unreal-Engine like
Actor-Component architecture to manage game-objects and
their behaviour. He covers skeletal-based animation with
the best mathematical explanation I have found so far!
It covers user-interfaces, how to do music and sound via Fmod,
the math behind differnet camera-models and some more advanced
rendering techniques such as deferred rendering.
Within ~500 pages it gets you up to speed very quickly and it
comes with a GitHub repository
that has actual, working code. At the end of each
chapter it also recommends some further resources that I have
found very helpful. He also provides the reader with alternative
solutions to the ones he presented so he doesn’t claim his
solutions is the best or the only one. Quite the contrary, he
always gives a very good explanation for certain decisions, its
benefits and drawbacks. One thing the book does lack is
networked games. But it gives you all the tools to
built up on and grow from there.
Highly recommend!
Tricks of the 3D Game Programming Gurus, André LaMothe, 2003
LaMothe’s books hold a special place in my heart. Especially
his Black Art of 3D Game Programming is still a valuable book
if you’re interested in how games were made for DOS. The “Tricks 3D”
book can be considered a second edition, programming for Win32.
Don’t get me wrong, though, this still is an old book and you
won’t get any of the examples to compiled on any modern
Windows for multiple reasons, one of them being the outdated
version of DirectX being used. But André only uses DirectX to
capture input, draw into the window, etc. You could easily
replace that part with something like SDL, like I did
with the first example game in his book: https://github.com/michaeleggers/Raiders3D-SDL
(My code isn’t great in this one but it shows that it is doable).
He even explains that all the operating-system and DirectX specific
code is going to be abstracted away into a lib so that one could
replace it with something completely different. That lib that he calls the Virtual Computer
has been developed throughout his previous book, Tricks of the Windows Game Programming Gurus.

Other codebases or books call this the Platform Layer. LaMothe doesn’t really
create a static link library of his Virtual Computer, he just calls the files
that belong to the Virtual Computer *LIB.cpp
and *LIB.h
respectively.
By the way, the structure might seem familiar to you if you have seen
Casey Muratori’s Handmade Hero:

Of course, this is an absolutely
reasonable thing to do, even in non-game-code. But his book
was the first that taught me the concept of bundling code into a module (a lib)
and defining an interface for it so that other parts of the program can make
use of its functionality.
And I still find this really beautiful: No matter how complex the program
is, if the boundaries of a program’s problem domains are well defined it will
be possible to reason about it as a whole and therefore keep it maintainable
and, though rarely achieved in reality, extendible.
Interestingly, I still find this
the most challenging thing to do in programming: Where to introduce
those boundaries and how the API should expose its functionality to
the user. And to my relief, I am not alone:
I have to tell you, as someone that has shipped several libraries
now…no one is an expert in this field. Some (most?) of the most
important programming interfaces, across all of technology,
designed by capable engineers, are honestly terrible.
Past some obvious rookie mistakes, the best of us are just the
most lucky, I suspect.
– Ryan C. Gordon, source: https://www.patreon.com/posts/project-sdl3-138034434
Of course, it is always a bit subjective as well, but I think LaMothe does a
good job throughout the codebase.
This is something that Madhav’s book doesn’t show you. The platform layer
there is the C++ STL (file IO) and SDL. And this, as I mentioned above, is
absolutely fine.
The book continues to introduce all of the mathematics required to build your
own software 3D rasterizer. I find it encouraging and fun how LaMothe goes
over the subject. However, the typesetting of formulas isn’t great. Don’t
expect nicely rendered Latex-like mathematical content. Anyways, it is all
there and it doesn’t get boring. With all the theoretical knowledge equipped
the book shows you how to build your very own math library. It even comes
with a floating point math primer talking about FPU architecture and whatnot.
I am not sure if the knowledge is outdated for current x64 architectures,
I haven’t studied that part thoroughly and it is a domain that I lack knowledge of.
So this is something I should get back to at some point :)
The software rasterizer is built incrementally, adding features to it throughout
most of the following pages. This is definitely the meat of the book. I loved that he
also explains how binary space partitioning (BSP) works, it was my first
introduction to it, only having heard that Quake used this data-structure.
With roughly 1600
pages “Tricks 3D” is a very long book. So don’t expect to read and understand all
of it in one sitting. Not saying it isn’t possible, but I certainly couldn’t
and still haven’t read all of it. I keep coming back to it, though, and find small insights that
turn out useful.
In conclusion, if you want to learn how to write a platform layer (or, Virtual
Computer in Tricks 3D terms) from scratch and how to build a whole software 3D
engine, load models without using any libraries at all, this is still
a great book. You will have to rewrite a whole lot by yourself, because of
the dated code. But that might be a good exercise. And even if you move on
to using a pre-built gameengine later on, I believe it is worth having
at least spent some time with this book once. I wish tomes that cover
so much ground about game-programming would still be written to this day.
You have to hunt online for used copies as the book is out of print.
The CD-ROM can be found here: Tricks 3D CD-ROM
(This is not my upload. Note that the CD-ROM data is technically still copyrighted material.
So download at your own risk.)