Skip to content
3DGEP logo

3D Game Engine Programming

Graphics programming tutorials for game developers, from your first DirectX window to rendering millions of lights.

Online course

Learn C++ by making games: my video course on Udemy.

Udemy courseC++23 for Game ProgrammingLearn how to create games from scratch using C++23.

C++ Fast Track for Games Programming

Learn C++ from scratch by making games: from your first program in Visual Studio to sprites, tilemaps, classes, physics and AI, using the tmpl8 game template.

16 parts · C++ · Visual Studio · Start with part 1

  1. Getting Started
  2. The Template
  3. Variables and Functions
  4. Sprites and Loops
  5. Conditions
  6. Floats
  7. Debugging
  8. Memory Addresses
  9. Colours
  10. Arrays
  11. Tiles
  12. Classes
  13. Data Structures
  14. File I/O
  15. Physics
  16. AI

More C++

ArticleC++ Template ProgrammingFunction, class, variable and alias templates, template type deduction, type traits, SFINAE and C++20 concepts.2021
ArticleDLL Plug-InsImplicit and explicit linking of DLLs, exporting classes and functions, and a plug-in system with LoadLibrary.2011

Learning DirectX 12

Build a DirectX 12 application from scratch: devices, command queues and fences, resources and pipeline state, a reusable framework, and textures with mipmaps generated on the GPU.

4 lessons · DirectX 12 · C++ / HLSL · 2017–2019

Lesson 1Initialize DirectX 12Query adapters, create the device, command queue, swap chain and fences, and implement the render loop.2017
Lesson 2RenderingResources, root signatures and pipeline state objects: render a rotating cube with vertex and pixel shaders.2018
Lesson 3FrameworkAn upload buffer, descriptor allocator, dynamic descriptor heap and automatic resource state tracking.2018
Lesson 4TexturesLoading textures, mipmapping, filtering and addressing modes, and generating mipmaps in a compute shader.2019

DirectX 11

Where it started: a DirectX 11 application from scratch, then textures, constant buffer packing and per-pixel lighting.

2 articles · DirectX 11 · C++ / HLSL · 2014

Part 1Introduction to DirectX 11Create a DirectX 11 application from scratch: window, device, swap chain, states and shaders, and a rotating cube.2014
Part 2Texturing and LightingTextures, samplers, filtering and addressing modes, constant buffer packing and per-pixel Phong lighting.2014

OpenGL

Texturing and lighting with OpenGL and GLSL, and skeletal animation of MD5 models, on the CPU and in a vertex shader.

3 articles · OpenGL · C++ / GLSL / Cg · 2011–2014

ArticleTexturing and Lighting with GLSLTexture objects, mipmaps, filtering and wrap modes, and per-pixel Blinn-Phong lighting in an OpenGL 3.3 core profile.2014
Part 1Loading and Animating MD5 ModelsParse the MD5 mesh and animation files, interpolate the skeleton between frames and skin the mesh.2011
Part 2GPU Skinning of MD5 ModelsMove the vertex skinning to the GPU: bone weights and indices in vertex buffers, and a skinning vertex shader.2011

Rendering Techniques

How to render scenes with thousands, and then millions, of dynamic lights in real time.

2 articles · DirectX 11 / 12 · Compute shaders · 2015–2017

ComparisonForward vs Deferred vs Forward+Forward, deferred and tiled forward rendering compared, with G-buffers, grid frustums and light culling in a compute shader.2015
ThesisVolume Tiled Forward Shading3D volume tiles and a bounding volume hierarchy over the lights: millions of light sources in real time.2017

Math

The math behind 3D graphics: coordinate systems, vectors and matrices, building a view matrix, and rotations with quaternions.

5 articles · Linear algebra · 2011–2012

Primer 1Coordinate SystemsLeft- and right-handed coordinate systems, the direction of rotation, and object, world and inertial space.2011
Primer 2Vector OperationsVector addition, length and normalization, distance, the dot and cross products, and projection.2011
Primer 3MatricesLinear and affine transformations (rotation and scale), the determinant, the inverse and orthogonal matrices.2011
ArticleUnderstanding the View MatrixHow to build a view matrix: look-at, FPS and arcball cameras, and the camera position in world space.2011
ArticleUnderstanding QuaternionsComplex numbers, quaternion operations, rotating points with quaternions, and SLERP interpolation.2012

GPGPU

General purpose GPU programming with CUDA and OpenCL: how threads are scheduled, the memory hierarchy, and optimization.

5 articles · CUDA · OpenCL · 2011

CUDACUDA Thread Execution ModelGrids, blocks and warps, the streaming multiprocessor, warp scheduling, thread divergence and occupancy.2011
CUDACUDA Memory ModelRegisters, local, shared, constant and global memory, and a tiled matrix multiply using shared memory.2011
CUDAOptimizing CUDA ApplicationsTiming kernels, coalesced global memory access, shared memory bank conflicts, occupancy and flow control.2011
Case studyN-Body SimulationAn all-pairs N-body gravity simulation in CUDA, with tiles of bodies loaded into shared memory.2011
OpenCLIntroduction to OpenCLThe platform, execution and memory models, the host API, and writing and running OpenCL kernels.2011