TIL DOOM 3 Source Compilation
Tags: todayilearned, gamedev, idtech, vs2019
Published: 2021-05-11 23:55:14

2021-05-11

For fun, I decided to check out id Tech 4. Instead of using [id's repo](https://github.com/id-Software/DOOM-3-BFG), I was turned on to [RBDOOM 3](https://github.com/RobertBeckebans/RBDOOM-3-BFG) which is a modern version. Fortunately, I found this [guide](https://bartlomiejwolk.wordpress.com/2017/09/12/doom3-bfg-how-to-compile-from-source/) which made my life 100x easier.

Following the guide, I cloned the master branch (using GitHub Desktop). I had Visual Studio 2019 already installed which fortunately RBDOOM 3 supports. The next step was to install cmake which I found [here](https://cmake.org/download/). I deviated from the guide and didn't use msi, opting for the zip version. This meant I had to ensure cmake's bin folder was in my PATH variable. 

Then I generated the solution using one of the existing batch files, opting for cmake-vs2019-64bit-windows10.bat. 
![Screenshot of batch files](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpjac7ukhls32extw6wa.png)

Deviating a little from the guide once more, I skipped ahead and immediately opened the RBDoom3BFG solution generated in the new `build` folder which opened up with no issues in VS2019. Without changing anything, I built the solution and this produced an RBDoom3BFG.exe in a Debug folder. Attempting to run this produced missing DLL errors which I took note of.

Returning to the guide, I jumped to the step I skipped and grabbed ffmpeg-4.4-full_build-shared.7z from [gyan.dev](https://www.gyan.dev/ffmpeg/builds/). The necessary DLLs are in the bin folder which I placed alongside the RBDoom3BFG.exe file:
* avcodec-58.dll
* avformat-58.dll
* avutil-56.dll
* swresample-3.dll
* swscale-5.dll

Or you could copy all the dlls like the guide suggests.

Upon running the game, I ran into the same error as the guide depicted and instead of copying just default.cfg, I copied the whole `RBDOOM-3-BFG\base\` folder into my Saved Games folder.

Finally it was time to ensure the game assets were available to the build. The game's on [sale](https://isthereanydeal.com/game/doomiiibfgedition/info/#/) right now on [Steam](https://store.steampowered.com/app/208200/Doom_3_BFG_Edition/). Install the game and find its `base\` folder where all the assets reside. The guide suggests copying it but I used [junctions](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/mklink) instead. Using junctions would mean that I can potentially ruin my game files but since I don't intend to play the game it should be okay.

Unfortunately after all this, DOOM 3 still didn't run. I got this error.
![Error while linking glsl program](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4apltyfbkb618yto4t0n.png)

It turns out that the game tried to run with my system's integrated graphics processor which does not support OpenGL 4.5 which RBDOOM 3 now [needs](https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/523#issuecomment-779578329). Indeed, it complained about failing to make OpenGL 4.5 contexts and falling back to OpenGL 4.3. Fortunately I was able to specify which GPU to use.
![Use the right-click menu to set the GPU](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cj2kneor7gvp92p1xx0.png)

Upon changing to the better graphics card, the game finally ran. I loaded up a dev map.
![Game Capture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ygmepa8dl1baflxj9u3.png)
Rip and Tear, anyone?