Project Information

  • Language: C++
  • Graphics API: DirectX 11
  • Creation: Summer 2020
  • Source URL: GitHub Page

DirectX 11 Engine

As part of a series of summer projects, and following the creation of my OpenGL projects, I decided to see what I could learn regarding the DirectX 11 graphics API. Consequently, I followed Planet Chili's DirectX programming tutorials to achieve a foundational understanding. Completing the tutorials taught me a lot about the uses of DirectX and how various C++ programming techniques can be used to further improve the efficiency of the engine, such as perfect forwarding, template metaprogramming. A video of the completed engine is shown below.



What Did I Learn?

While my initial aim was to learn the DirectX 11 API, I found that I learned even more about C++ with regards to how it can be used to dynamically bind states to the pipeline at runtime. Template metaprogramming along with perfect forwarding allowed for most of this to be achieved. Dynamically assigning different layouts to DirectX's constant buffers at runtime made for an efficient program that was easy to manage, making the incorporation of ImGui for the changing of these parameters a more simple task.

 // dynamically create a layout and add "blurColor" as a parameter
 Dcb::RawLayout layout;
 layout.Add( "blurColor" );

 // move it into a buffer and assign it default values
 auto buf = Dcb::Buffer( std::move( layout ) );
 buf["blurColor"] = DirectX::XMFLOAT4{ 1.0f, 0.4f, 0.4f, 1.0f };

 // add the constant as a bindable for the current step in the draw pass
 draw.AddBindable( std::make_shared<Bind::CachingPixelConstantBufferEx>( gfx, buf, 1u ) );
As for DirectX, I learned the general format of the pipeline and how to best abstract and encapsulate classes for use by the engine. I learned how to implement several features to the engine this way, including a scene graph, render graph along with a lighting system that incorporates shadow mapping. While I have implemented a shadow mapping system in OpenGL, I discovered that the DirectX method requires a lot more work, considering that it offers more control by default. With the addition of a cubemap, I also learned the method required to implement shadow mapping around a point light source, in all directions.

The importance of memory management was also something that became quite apparent while building this engine. Opting for smart pointers, using lambda functions, const references, virtual functions and appropriate scopes were all examples optimization techniques that were used to ensure the efficiency of the engine. Moving forward, I plan to gain a better understanding of these programming techniques so that I can use them more freely in the creation of future graphics engines.

Future Additions

With my newfound knowledge of DirectX and some of the more advanced C++ programming techniques, I plan to adapt this graphics engine with new features and optimizations. The implementation of multi-threading would likely be the greatest optimization to the graphics engine, as several processes, such as concurrent model loading which could be achieved by dividing the work across multiple threads simultaneously. This would also allow for more options at runtime, as new models could be instantiated at runtime would halting the engine.


Feel free to drop a comment below.