Fork me!

Introduction

This guide will teach you the basics of using OpenGL to develop modern graphics applications. There are a lot of other guides on this topic, but there are some major points where this guide differs from those. We will not be discussing any of the old parts of the OpenGL specification. That means you'll be taught how to implement things yourself, instead of using deprecated functions like glBegin and glLight. Anything that is not directly related to OpenGL itself, like creating a window and loading textures from files, will be done using a few small libraries.

To show you how much it pays off to do things yourself, this guide also contains a lot of interactive examples to make it both fun and easy to learn all the different aspects of using a low-level graphics library like OpenGL!

As an added bonus, you always have the opportunity to ask questions at the end of each chapter in the comments section. I'll try to answer as many questions as possible, but always remember that there are plenty of people out there who are willing to help you with your issues. Make sure to help us help you by specifying your platform, compiler, the relevant code section, the result you expect and what is actually happening.

E-book

This guide is now available in e-book formats as well:

Credits

Thanks to all of the contributors for their help with improving the quality of this tutorial! Special thanks to the following people for their essential contributions to the site:

Prerequisites

Before we can take off, you need to make sure you have all the things you need.

  • A reasonable amount of experience with C++
  • Graphics card compatible with OpenGL 3.2
  • SFML, GLFW or SDL for creating the context and handling input
  • GLEW to use newer OpenGL functions
  • SOIL for textures
  • GLM for vectors and matrices

Context creation will be explained for SFML, GLFW and SDL, so use whatever library suites you best. See the next chapter for the differences between the three if you're not sure which one to use.

You also have the option of creating the context yourself using Win32, Xlib or Cocoa, but your code will not be portable anymore. That means you can not use the same code for all platforms.

If you've got everything you need, let's begin.