Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.
--- Linus Torvalds
Join us on or Discord to discuss your game programming ideas with us.
You are currently viewing the game programming tutorials for Windows and DirectX 11. Linux tutorials using OpenGL, as well as tutorials about web-based game programming, with WebGL, and about programming games for consoles, using OpenGL ES, are scheduled for a later time.
Introduction to Game Programming with DirectX
Windows Game Programming Fundamentals
Before learning how to program DirectX games, basic knowledge about Win32 programming must be acquired. In the following tutorials, a first fundamental framework for any Windows-based games is created, featuring a robust game loop with time management. The framework encapsulates all the tedious details about Windows programming, such that later, more advanced tutorials, can simply focus on their core ideas, without having to worry about being bothered by Windows.
- Hello World!
- A Thread-Safe Logger
- A real-world Windows application
- Of the Moon and the Sun
- Handling Important Windows Events
- Keeping Track of Time
- The Game Loop
- Keyboard and Mouse
- Of Icons and Cursors
- A First Framework
With all the nasty Windows stuff nicely hidden away, we will learn about Direct3D (we will use Direct3D 11.0, which works on Windows 7, Windows 8 and Windows 10) and the High Level Shader Language to draw vertices to the screen. We will also learn how to make Direct2D and DirectWrite co-operate with Direct3D to output text to our game window.
- First Contact
- The Swap Chain
- Viewports and Render Targets
- Printing text with DirectWrite
- Of Shaders and Triangles
- Among Colourful Stars
- Going Fullscreen
- Game Framework
Please note that none of the following tutorials have been revisited or edited. I have written them as I learned and implemented the topics in question. There might be a ton of grammatical mistakes, the explanations might not be well written and the code might not be optimized. Nonetheless, the demos run fine, and you can surely learn something new. I will revisit those tutorials once I have more time. Thank you for your understanding.
The following short tutorials cover the High-Level Shading Language in more details than the previous tutorials.
Now that a robust DirectX game framework is in place, it is time to study Direct2D in more detail. We will learn how to use Direct2D to render 2D-images, starting with simple geometrical figures and working our way up to complete 2D-sprites. At the end of these tutorials, we will have a very robust DirectX and Direct2D framework, with DirectWrite and Windows Imaging Component support.
To round things off, we will learn how to handle user input and we will add sounds and music to our framework.
User Input will be handled by Windows events for the keybard and mouse, by DirectInput for Joysticks and by XInput for Gamepads. An event queue will be implemented to allow different application components and game entities to interact with each other.
To add sounds and music, we will have a look at XAudio2 and the Windows Media Foundation (in later tutorials, FMOD and Wwise will be introduced as well).
I can't think of a better place to start the journey into computer graphics than Flatland itself! To fully use all of the features in these tutorials, Windows 10 is necessary.
- DirectWrite in Direct2D - A Revision
- Direct2D - A Revision
- Drawing Primitives
- Fun with Brushes
- Creating Geometrical Objects
- Direct2D Transformations
- Bitmaps and the Windows Imaging Component
- Animated Sprites and Sprite Sheets
Input System (I)
User Interface (I)
File System (I)
Input System (II)
Programming Patterns (I)
Music and Sound (I)
XAudio2 with the Windows Media Foundation
A First Game: Tetris
- The Basics
- Creating a basic installer with Inno Setup
- Installing the Visual C++ 2017 Redistributables with Inno Setup
- Resolution Independent Rendering
Playing God (I) - Fundamental Physics
To be able to simulate a real world, it is necessary to understand the laws of physics. The following tutorials give a basic introduction to the most important concepts of classical mechanics. A more rigorous treatment of those concepts will appear in the "mathematics" section of this website, later on.
- Units of Measurement
- One-Dimensional Kinematics
- Two-Dimensional Motion
- Basic Projectile Motion
- Newton's Laws of Motion
- The Evil Head of Friction
- Basic Collision Detection with Bounding Spheres and Rectangles
- Basic Ad-Hoc Collision Response
(in alphabetic order)
- Game Programming Algorithms, by Sanjay Madhav
- Game Programming Patterns, by Robert Nystrom
- Introduction to 3D Game Programming with DirectX 11, by Frank D. Luna
- Microsoft Developer Network (MSDN)
- Tricks of the Windows Game Programming Gurus, by André LaMothe
If you found those tutorials helpful, consider donating a small amount via Paypal.