Setting Up Graphics Library, New Games, and Shader Changes in a Personal 3D Game Engine
- reynosorobertov
- Sep 6, 2024
- 4 min read
Updated: Sep 28, 2024
Download Example Output for OpenGL and Direct3D
My process in setting up my Graphics library, for setting up having new games, and changing what the shader will do graphicly in my personal 3D game engine that I am building in the class that I am taking. Note I am building the engine using C++, Visual Studio and another side note is that I use Lua to build the shaders. Along, with that my Graphics library currently supports both Direct3D and OpenGL to render the graphics to the screen.
I started off by creating a Static Library through the Windows Desktop Wizard and called my project “Graphics” which would be included within the filter, which is named Engine.

I found what was most difficult in getting this to work was the fact that we need make sure that all of dependencies are correctly setup, if we don’t, we will end up getting linker errors, since every system that our game engine uses will possibly depend on another library that we have built, so we need to make sure that all of the references are in order. References are not the only possible problem we might have to worry about, we should also look under properties within the project, to check our additional included directories and if we need to force include anything.



When we are working with two possible ways to render our graphics, in this case I am using OpenGL and Direct3D. We need to make sure that OpenGL is excluded from the x64 platform, while Direct3D is excluded from the w32 platform, the reason we do this is so that we can easily differentiate the two renderers, when we choose the platform that we are building for, so that we don’t need to write a more complicated system to determine which platform we need to build for, we can just have a condition to check for what platform we are building to and run it accordingly without having to write more code that isn’t needed.


Now moving on, if we want to have our Game Engine be able to build multiple games. My current process for making a new game is that I copied the initial game that the project currently holds into a new project, but before doing this you need to make sure to save the unique “ProjectGuid” that a new project creates and you can get this by editing the “MyGame.vcxproj” file itself, I did this using Notepad++. After that I would delete all of the files that were under this newly created project for the new game I want to make, I would then copy all of the files from the initial game project that our 3D Game Engine contains and would then rename the files accordingly and change the “ProjectGuid” of that new project with the one that we had saved previously. Lastly, you need to make sure that your new Game has a “UniqueIdentifier” which you can find this in the “MyGame.filters” file, you would then find a new GUID to replace it with, which you can use this online tool to generate one.


You can change what the shaders do visually to your game. By going into the “. shader” file we can check whether or not we are using OpenGL or Direct3D and then change the shader output for each separately, by editing the shader file.
After getting the output you desire for your shader, the output may look something like this.

You can then check the generated log files that get outputted by checking folder where you launched the game, there should a log there, that should the game’s initialization and clean up messages.

Through out the code I found that the Application project had a reference to Graphics, but the only project that I found that doesn’t need a reference for Graphics, is the Graphics project itself, it also indeed mentions the Graphics namespace and the files within that project don’t need a reference too Graphics, since they belong to that project, so they should be able to use the Graphics namespace freely.
My thoughts on the on the engine code base and how it is organized, I very much like how many of the systems that the engine uses are separated into projects and how each project only references another project if they need something from that particular project, this way we can keep the code base much more contained. After looking at the Graphics project, I don’t very much like how everything concerning initializing the Graphics is all in one class and not separated into specific sub systems in the Graphics project. The code style seems to be very well written out and I don’t really have too many problems with it, but if I were to point anything out, in my own style I very much preferring camel case over snake case for about everything, function names should be pascal case, constants should be in all caps, and lastly what I like to do that I don’t really see in this style of coding is adding an underscore (_) in front of the parameters for the functions I build.
I am actually still a little confused on how property pages actually work, looking them over I see that the game project that is being built has a property page of itself and the property page of the project Application, which I guess would make sense since Application references all the other projects that are needed to run the game properly, so that is why that is added as a property page to the game project itself to satisfy it’s “build configuration”.
My expectations for this class are to learn the insides and outs on how to properly build a 3D game engine by scratch. In our final project we are personally going to build a system that we will be adding to the engine itself and then come together with another system that another student will build and then make a game incorporating those two systems, I am very excited for this portion of the class, since I personally want to dive in and make an online multiplayer system for the engine, since over the summer I was only working on Unity net code and have found interest in the subject matter.
Kommentit