1
0
weblog/_posts/2023-09-25-setup-for-a-game-engine.markdown
JackCarterSmith d836338b70
All checks were successful
Build Jekyll weblog / build (push) Successful in 2s
Game engine setup post
2023-09-21 15:27:16 +02:00

6.2 KiB

layout, title, author, categories, thumbnail, highlight
layout title author categories thumbnail highlight
post Setup for a game engine development JackCarterSmith Programming C++ GameDev engine_tools_setup true
  • Contents {:toc}

My first point of reflection was to choose/find the tools I needed to develop my game engine. As I intend to use Direct3D for GPU interface and rendering, my developement platform will be Windows obligatory (but maybe not, see below...)

For those who haven't followed the reasons behind my choice of API and platform, I invite them to have a look at my [previous blog post]({% post_url 2023-09-10-build-a-game-engine %}).

I'm used to Eclipse IDE for C++ developement with CMake as project manager. But as Direct3D has been part of the Windows SDK since version 10, support for it will be more complete if I use VisualStudio and the MSVC toolchain. Sometimes, for a quick modification or comparison, I use VisualStudio Code.

It may seem superfluous, but I always recommend a large whiteboard to put your ideas on. It's quite effective for me in clearing up the mess in my head.

Direct3D and DirectX

Throughout this blog, you'll come across the terms DirectX, Direct3D, DXGI and so on. A brief aside to explain exactly what I'm talking about is in order to avoid losing anyone from the outset.

DirectX was developed from version 1 to 9 from Windows 95 to Windows XP to make graphics game development more accessible (before DirectX, a heavier version of OpenGL existed, but could only be used on specialized machines). At the time, the real advantage of DirectX was its ability to interface with the graphical display as well as the human-machine interface (keyboard, joystick, etc.) or sound. Using DirectX means you only need one library to manage user interfaces!

As you can see, DirectX is more than just a graphics API... In fact, DirectX is a set of multiple libraries for gaming:

  • Direct3D/2D for the graphic rendering,
  • Xaudio (aka. DirectSound) for... sound,
  • DirectPlay for multiplayer session,
  • Xinput (aka DirectInput) for Human Interface Device (HID),
  • DXGI for hardware management like GPU card selection,
  • And others for specialized usage.

At this time, DirectX is used for a mono-thread usage and all action taken inside user code, are executed immediatly (no command list). Multi-threading will not be available until version 11 on Windows Vista.

Versions 11 and 12 essentially change the way resources are allocated in video memory and how GPU instructions are processed by it.

Since May 20, 2020, DirectX12 has been ported to linux as open source. This is particularly interesting for the idea of porting my engine to other platforms. I wasn't aware of this when I chose this API, but it makes me all confident for the future.

DirectX is included as standard in the Windows SDK, which is installed with Visual Studio (as long as you select Game Development with C++ in the installation options). So let's move on to the next part...

VisualStudio setup

I'm using VisualStudio Community edition for my game engine developement. It has all the tools you need for design and debugging. Although it can be heavy to install, I can recommend to the purist to install only the SDK with the MSVC toolchain, but I won't detail the procedure here (far too long and technical for this post).

For the setup options, the minimal is:

  • Game Development with C++,
  • Windows SDK (normally included by default),
  • HLSL tools,
  • Graphics tools (located in Windows Optionals Features in Apps settings).

Others usefull graphic debugging tools

In addition to code design and debugging tools such as Visual Studio, I use graphical debugging tools that are specifically designed to check the graphical pipeline.

I recommend two of them, mainly because I'm used to using them, but they were the ones who got me up quickly:

  • PIX is a precise measurement and tunning tools of render timing. Developed by Microsoft, it come as a standalone program (for GUI) and a library to integrate into our code. When our game start, the PIX program will connect to the lib interface and begin to collect datas about the current running graphic pipeline, getting all GPU resources and event timing on the move. It can also be launch on a separate machine from the one where the game is run and connect to it through network. It only work with Direct3D API.
  • RenderDoc is equivalent to PIX in terms of features but it's open source and can have plugins and scripts to extends its limits. Unlike PIX, it support Direct3D, OpenGL and Vulkan API. It plug on app using debug layer of the API (who need to be integrated by dev in its code). Linux support is a plus!

Both of this tools work better on Direct3D-12 API, with retro-compatibility to version 11.

Project template and others examples

My main aim is to give you my experience of game engine development. I won't go into detail here on how to create a new project in VisualStudio.

With the DirectX suite integrated into the IDE, you'll have access to 4 template variants:

  • Direct3D-11 with or without Device Resource (DR),
  • Direct3D-12 with or without DR.

DR handle the boiler-plates of Direct3D and DXGI instance. And it give some example of how basically interface with your GPU card and render an empty scene on your screen. I recommand using this in first time and after some tries, you can make your own implementation. Try, experiment, fail... That the only good method to learn effectively!

But if you're feeling a bit lost on VisualStudio, I'd advise you to go here or there.