GLUT is the OpenGL Utility Toolkit used for writing programs in OpenGL (Open Graphics Library). It is a window system independent toolkit which makes exploring and learning about OpenGL programming easier and simpler. In other words, GLUT is a library of utilities for OpenGL programs which help perform the system-level input/output operations.
In post, I will show you step-by-step procedure to properly setup OpenGL (GLUT) in CodeBlocks IDE for windows. I have also embedded snapshots of the setting up process below steps wherever necessary.
For OpenGL, GLUT utilizes a simple windowing API (Application Programming Interface) so that a single OpenGL program written runs across PCs and Operating System platforms. Designed for making small to medium sized programs in OpenGL, GLUT does no require large and sophisticated user interfaces.
Steps to Setup OpenGL (GLUT) in CodeBlocks:
Step – 1
- Download GLUT Library and unzip the file.
Step – 2
- Open include folder from the downloaded file
- Copy the glut.h file and paste to the folder “C:\Program Files\CodeBlocks\MinGW\include\GL“.
- Open lib folder from downloaded file.
- Copy all files and paste to the folder “C:\Program Files\CodeBlocks\MinGW\lib“.
- Open bin folder from the downloaded file.
- Copy the glut.dll file and paste to the folder “C:\Windows\System32“.
Step – 3
- Open Code::Blocks. You’ll see the window as shown below.
- Click on Create a new project link.
- Click on GLUT project, then click Go.
- Enter the title name of the project, and give path to save the project.
- The project file is created by default from the title name of the project.
- Click Next.
Step – 5
- For GLUT location, give the path “C:\Program Files\CodeBlocks\MinGW“
- Click Next.
- Click Finish.
Step – 6
- As of this step, a project is finally created, and you’ll get a default main.cpp file.
- Don’t forget to include the header file – “#include<windows.h>“, otherwise you’ll get error.
- Build and Run, and you’ll see a window as shown below.
If you see the output of your program as shown above, you’ve properly setup OpenGL (GLUT) in CodeBlocks, and successfully created a project. Already aforementioned – GLUT makes learning OpenGL easier, and as a cross-platform it creates a much portable code between operating systems.
If you’re just getting started with programming in OpenGL, using GLUT is the best choice. It takes only a few lines of code, and does not require in-depth knowledge of operating system.
You can check out my earlier post which was about setting up graphics.h in CodeBlocks. You can also find “How to set up” articles regarding SDL, wxWidgets, GLFW in CodeBlocks, and more in this site. I hope this post helped you to easily setup OpenGL (GLUT) in CodeBlocks. If you encounter any problems, do mention them in the comments section below.