Original can be found at LevelByLevel.com: OpenGL, C++ and GLUT using CodeBlocks and MinGW – Updated.
On my old blog, CodieCode, I wrote a tutorial on how to set up an OpenGL, C++ and GLUT environment using the CodeBlocks IDE and MinGW compiler on a Windows XP and Vista machine. This was a popular post which seemed to help quite a few people. However time moves on, software updates and operating systems change. I’ve decided to update this tutorial with Windows 7 (though this should still work fine on XP and Vista) and the latest version of CodeBlocks and MinGW. Hope it helps
I would like to add that if you’re serious about learning OpenGL, I think it’s a must that you own “The Red Book” (OpenGL Programming Guide by Dave Shreiner). You can buy it from Amazon (with the link on the left) or wherever you normally buy your coding books. Either way it’s a fantastic resource to have and it’s helped me countless times in the past.
———
If you’re interested in coding in OpenGL and C++, a great way to start is by using GLUT. GLUT takes care of a lot of the difficulties in setting up an OpenGL project and lets you get started on your project quick and easily. In this tutorial I will guide you through installing and setting up the software you’ll need (CodeBlocks, MinGW and GLUT).
Before you can start you’re going to need a few things:
Windows – I’ve updated the steps below to run on Windows 7, Windows XP and Vista, If you manage to get this working on other operating systems, let me know
OpenGL – I’m not going to go into how to install OpenGL in this tutorial as most people will be using Windows XP or later and OpenGL comes ready in these operating systems.
GLUT – To download the GLUT files you’ll need click here and download ‘glut.zip’.
IDE (Integrated Development Environment) – While it’s possible to use an editor (such as Notepad++) and makefiles. I find the easiest and most efficient way to code is using a good IDE (be careful there’s some not-so-good IDE’s out there). The best that I’ve come across is CodeBlocks (I’m not a fan of using Visual Studio for OpenGL but you can use that too if you wish) and it’s this IDE that we’ll be setting up today.
C++ Compiler – The compiler I’ll be using is MinGW, there are many advantages to using this but I wont go into these here.
So without further ado, lets start: