Building A Flight Simulator

Part 1 - Flight Simulator with C++ and OpenGL

A picture of the author, Jakob Maier
Jakob Maier
Apr 4, 2020

Update: I have been working on a significantly improved simulator, you can find the article here.

During the quarantine I discovered OpenGL and got the idea of building a game. I have always been very interested in aircraft so the idea of building a flight simulator came quite naturally. In the end I chose to model the F-16 Flying Falcon, as there is a lot of data available for it, not just on its systems but also about its aerodynamics. The visual style of the simulator is in the tradition of iconic early to mid 90s flight simulators like A-10 Attack! (1995), SU-27 Flanker (1995) and of course Falcon 3.0 (1991).

During the quarantine I I am really enjoying this project as it has forced me to learn about topics that I have never really encountered before, especially the simulation of physics. When I first started this project my aproach to simulating the physics of flight was quite naive, but I quickly realized that this was a lot more complex than I thought. Fortunatly I found a book that covers this topic quite well (Physics for Game Developers by Bryan Bywalec and David Bourg), teaching me both about flight but also about game physics in general. I had never before heard about numerical integration, so this was extremely useful.

F-16 Another thing that I had never before been exposed to is graphics programming. Luckily there are some great tutorials that teach modern OpenGL available here and here. OpenGL also forced me to work with C++, which was also a first for me. I have some experience with C but it was still a bit of a shock coming from languages like Java and Python. It has definetly been a learning experience and I am sure my code is apalling to any experienced C++ programmer.

Accurate values for lift and drag coefficients in different flight conditions are absolutely critical to modeling an aircrafts flight characteristics accurately, so I was thrilled to find a 1979 NASA technical paper (TP-1538) containing all the necessery data and equations to simulate the airplane. But just having an accurate flightmodel only gets you half way there, as the F-16 is inherently unstable and needs a fly-by-wire system to fly. Luckily there is a very good book called Aircraft Control and Simulation by Brian L Stevens and Frank L Lewis about the design of flight control systems which specifically uses the F-16 as an example and so I was able to use this as a reference for the flight control system.

If you are interested in my code you can find it here.

↑ back to top

© 2023 Jakob Maier
kontakt & impressum
edit