Using Bloodshed Dev-C++ for OpenGL-GLUT Programming

By: Allan Spale, Teaching Associate
Fall 2005

Obtaining the Software
Installing the Software
Obtaining GLUT  Files
Project Settings For an GLUT OpenGL Project
Compiling and Running Your Project

OpenGL is an open graphics programming library developed by Silicon Graphics. Programmers use the application programming interfaces (APIs) of these libraries in order to write graphics programs using a variety of different languages including C++, Java, and Python. The purpose of this document is to enable you to use an open-source integrated development environment (IDE) for writing OpenGL programs using C++.

Writing a program in any programming language requires a text editor, compiler, and linker in order to generate the executable, or software application that runs on a particular operating system such as Windows XP or Mac OS X. To simplify the task of writing programs, software developers created an IDE that organized all of the tasks of writing a program into one application. Popular IDEs include NetBeans (Java), Eclipse (multiple language bindings), and Visual Studio (all Microsoft-supported languages).  NetBeans and Eclipse are freely available, while Visual Studio is not free. Additionally, many of these IDEs have more features than you will probably need to use in an introductory programming course.

Obtaining the Software
In order to find the best of both worlds-- a free IDE and a fairly straightforward IDE for C++, I recommend downloading Bloodshed Software's Dev-C++ for writing OpenGL C++ programs. The link to Bloodshed Software is: The link to downloading the most recent version of Dev-C++ can be found at: and select the link that says "Dev-C++ 5.0...with Mingw/GCC". Please be aware that this software only runs on Windows operating systems.

Installing the Software
To install the software, follow these steps:
  1. From the section labeled "Dev-C++ 5.0...with Mingw/GCC", select the SourceForge link or click here.

  2. You will be taken to the SourceForge download server. Here, you can select the serve from which to download Dev-C++. In most cases, it will be better to choose a mirror (or download server) somewhere in the United States; however, this is not required. In the Download column, click on the link of the server of your choice.

  3. The page will refresh. If a download window does not appear after a few seconds, click on the link given near the top of the page. Then, choose a location to save the file. Wait while the file downloads.

  4. Find the location on your computer where you downloaded the file and double-click on the Dev-C++ installation icon. A dialog box will appear indicating the progress of preparing for the installation.

  5. A dialog box will appear asking what language you want for this installation and then press the Ok button.

    • step 1

  6. Review the license agreement. If you are able to accept the terms of the license agreement, press the I Agree button.

    • step 2
  7. Now it is time to select the type of installation. In order to keep things simple, choose the option Full for the option of Select the Type of Install. Make sure that you have sufficient space to perform the full installation.

    • step 3

  8. Select the location where you want the files installed. Because of some difficulties that may occur if you install to a directory name that contains spaces, choose a directory location or make a new directory that does not contain spaces. Although program installation should typically be in C:\Program Files, either make a new directory called C:\other-programs or simply accept the default location of C:\Dev-cpp.

    • step 4

  9. Watch the program install the files.

    • step 5

  10. After the installation program installs all of the necessary files, Dev-C++ should be ready to run. If you want to run Dev-C++ now, make sure to check the item labeled Run Dev-C++ 5... Then, click on the Finish button.

    • step 6

The first time that you run Dev-C++, you will have to complete some additional configuration steps which are listed below:
  1. Read the notice that appears with the beta software.

    • config-1

  2. Configure the software using the dialog boxes. Speicifically, you will choose the language that you want to use and decide on the style of the user interface.

    • config-3

  3. If you would like to have a hierarchy of the classes that you are using and/or would like to have the ability for code to be completed by the editor if you type in a series of unique letters, select the Yes... option; otherwise, select the No... option.

      • config 4

      • If you selected the Yes... option, you will be presented with the option of using a cache to assist the IDE with code completion. Unless there is a good reason not to do so (such as in the case with the IDE using too much memory and CPU power), create the cache now by selecting the Yes... option and pressing the Next button.

  4. If everything worked as expected, you should see the following message:

    • config 6

Obtaining GLUT Files
If you are running a Windows computer, the necessary OpenGL files should already be available. When in doubt, check the directory C:\WINNT\system32. In this directory, there should be files like opengl32.dll and glu32.dll. If you are missing any of these files, things will not work correctly when you try to write OpenGL. Traditionally, the windows that are used for OpenGL programs were dependent upon the underlying operating system window management system. This did not allow OpenGL programs to be as portable across platforms as they should be. To solve this problem, the OpenGL Utility Toolkit, or GLUT, was created. If you have never written any OpenGL programs using GLUT before, the necessary files for running GLUT will not be avaiable. For this reason, you need to download them. A website which explains how to use Dev-C++ to write OpenGL GLUT programs also provides information on where to download the appropriate GLUT files in addition to where to put them. The information about how to do these tasks was taken from: Download the following files from these locations:
As stated on the website where these files can be downloaded, make sure to include glut32.dll with any OpenGL GLUT programs that you distribute since your end-users may not have this file available for running OpenGL GLUT programs.

Project Settings For an GLUT OpenGL Project
In Dev-C++, the IDE organizes your code files into projects. For this reason, you need to specify the project type whenever you begin start writing a new application. Follow the steps below to setup an OpenGL GLUT project:
  1. From the Dev-C++ menu, select File -> New -> Project. A new dialog box will appear.

  2. Press the Basic tab and select Console Application from the types of projects.

  3. Type the name of the project in the field named Name.

  4. Select the C++ Project option from the box with options.

  5. Press the Ok button.

  6. It would be advisable to keep your projects organized in some hierarchy. It may be suitable to make a new directory that contains all of your Dev-C++ projects or place these Dev-C++ projects in some other appropriate directory. In any case, choose a location and make sure that the project name is indeed what you want the project to be named. The settings for the project will be stored in a file called where project-name is the name you wanted to name the project.

Below is a picture that shows how things should look when you are finished filling out the information in the dialog box:

project 1

You want to choose a console application because the program that you write should not contain any Win32 API code (this is code written that accesses programming libraries specific to the Windows operating system). The console application will enable you to have code that can be run on an operating system that does not have Windows.

The next series of steps involves configuring the project options so that files needed to make an OpenGL GLUT program can be easily found by the Dev-C++ IDE. Instructions similar to the steps listed below appear on the website whose address is:
  1. From the Dev-C++ menu, select Project -> Project Options. A new dialog box will appear

  2. Press the Parameters tab which should make the dialog box appear as seen below:

    • project 2

  3. It is necessary to add libraries that will support the operation of  OpenGL and GLUT. Repeat the following steps-- press the Add Library or Object button and then select the appropriate library file. These files begin with the letters "lib" and ends in ".a". It will be necessary to add the following files: libglut32.a, libglu32.a, and libopengl32.a. These files will be located in the lib\GL directory of your Dev-C++ installation directory. For instance, one path possibility could be: C:\Dev-C++\lib. When you are finished, the dialog should look like this:

    • project 3

  4. Then press the Ok button.

Now, it is necessary to find a sample program. Andrew Johnson of the Electronic Visualization Laboratory at UIC has a simple C program that meets this requirement. You can download it from: Either copy and paste the code from the website into the Dev-C++ editor or save the file and load the shell.c file into the current project. A change that you will likely have to make is to change a line with #include <glut.h> to #include <GL/glut.h>. One thing to note, if you are new to programming, C++ is an "improved" version of C that supports data structures named objects. This loosely means that C program code can be compiled by a C++ compiler.

Compiling and Running Your Project
Compiling and running the code in your project is very easy...but...figuring out why your specific program does not compile or run can become very difficult. This is true of anyone-- those who have spent a lot of time programming and those people who are learning how to program. Since errors are typically unique to each situation for compiling or debugging, it is up to you to learn how to do this. Assuming that everything written correctly and the project is configured to use the proper libraries, do the following:
There are also buttons that can be pressed to compile and run without having to go to the menu each time you want to compile or run a program.