This tutorial is about getting started with modern OpenGL and assumes knowledge of C/C++. For this tutorial, you will need a fairly new graphics card and the latest drivers. Specifically, a graphics card that implements OpenGL 4.2 so this means you must have what is generally known as a DirectX 11 card. In this tutorial, we will compile the open source toolkit Freeglut, the GL extension loader Gl3w, and we will check that we can run OpenGL 4.2 core programs. I will use the free Mingw compiler. You can use Visual Studio if you prefer, but I started using Mingw back when Visual Studio wasn't available for personal use so I will stick to what I know best. You're on your own if you use Visual Studio.

So why do we need Freeglut?
Freeglut is an open source toolkit that abstracts all the OS specific code that every OpenGL program requires. This prevents us from having to learn Win32 API or GLX if you use Linux. If you don't already know OpenGL, it saves you from having to write a lot of boiler plate code just to get started. Once you have the basics of OpenGL, using a toolkit is entirely optional and can be dropped if you don't want the extra dependencies. For simple tutorials and demos, Freeglut is the way to go to get started.

What is Gl3w?
Gl3w is a utility that loads all the core OpenGL 4.2 functions and extensions for us. (You could also use Glew, but it loads deprecated functions as well as the core ones, so you have to be more careful when you use it.)The alternative is to spend time manipulating function pointers and loading extensions by hand which can get tedious very quick. Again, later you can drop the Gl3w utility if you prefer and load in everything by hand, but for now we will use the library.

Installing Freeglut
So now we can get started. The first thing to do is download, compile, and install Freeglut. Why do we compile Freeglut when we can get the binaries? We compile it because we are programmers and because we can. Further, Freeglut is open source so it defeats the purpose if all we do is use pre-built binaries. Download Freeglut from http://freeglut.sourceforge.net/

Next, open a command window and navigate to the Freeglut source code. I assume that Mingw is on the path. Type the following compiler commands:

Freeglut should compile without any problem. Next, find the newly built files freeglut32.dll, libfreeglut32.a, libfreeglut32_static.a and the include directory. Copy the header files from the include directory to the ..\Mingw\include\GL directory. The path ..\Mingw is the install location of Mingw on disk. Put freeglut32.dll into ..\Mingw\bin and put libfreeglut32.a and libfreeglut32_static.a into ..\Mingw\lib. Make sure that ..\Mingw\bin is on the path. That takes care of the installation of Freeglut.

Installing Gl3w
For Gl3w, you should have Python 2.XX installed. Download the Python script located at https://github.com/s...ter/gl3w_gen.py Run the Python script and it will download the core header files from opengl.org and it will create a source file that can be compiled. Copy the downloaded header files to ..\Mingw\include\GL3 directory. The source file gl3w.c we will link with our application. I renamed it to gl3w.cpp and modified it to compile with g++, but it should work just the same.

The Code
Now we can write a minimal program to check that we can run OpenGL 4.2 core profile programs. The following is a simple program that creates a window and paints it black. I named it test.cpp: