Monthly Archives: July 2022

How to install GLUT in Windows 10.

I was following a tutorial on OpenGL based in GLUT which is an auxiliary library created by Mark Kilgard to create a window in an easy way so that one can focus in learning OpenGL.

GLUT can be found at the URL http://opengl.org/resources/libraries/glut/glut_downloads.php

The problem is that GLUT has been abandoned and the last version runs on Windows XP and it isn’t an open source project either so no one can develop it on.

Fortunately Pawel W. Olszta, Andreas Umbach and Steve Baker developed an Open Source alternative called Free GLUT which is compatible with GLUT and replaces it in modern operating systems.

In this article I’m going to explain how to install it in Code::Blocks and on Windows 10.

The project is hosted at this URL: http://freeglut.sourceforge.net/ where you can download the sources and compile them yourself but it also links to Martin Payne’s web where the library is already compiled and available for MinGW which is Code::Block’s compiler or for Microsoft Visual Studio.

The URL of Martin Payne for the compiled library is https://www.transmissionzero.co.uk/software/freeglut-devel/

We click on the link Download freeglut 3.0.0 for MinGW, it’s a zip file which contains a folder called freeglut. I unzipped it in the path C:\freeglut

At this point you can create a project in Code::Blocks and manually add the pats to the folders include and lib plus the linker flags.

In order to do that we click the right button of the mouse on the project and in the menu we select Build Options… This will open a window.

In this window, in the profile Debug move onto the the tab Search directories and search for the sub tab compiler. In it enter the path C:\freeglut\include

Now move onto the sub tab Linker and add the path to C:\freeglut\lib\x64

Afterwards go to the tab Linker settings which is next to Search directories and inside it there is a vertical textbox titled Other linker Options: and enter the flags: -lfreeglut -lopengl32 -lglu32

To compile in Release you need to do the same setting as for Debug.

Lastly you need to copy the file C:\freeglut\bin\x64\freeglut.dll in the folder with the executable file that it’s created in the paths bin\Debug or bin\Release in your project.

At this stage you can now compile your OpenGL program making use of the auxiliary library FreeGLUT.

You’ll need to do the same configuration every time you start a new project but it doesn’t have to be so.

Code::Blocks has a template out of the box to create GLUT project but this template is broken because it’s designed to do it with the original library which as I said it won’t work in Windows 10.

What we need to do however is to make some changes to generate project that use FreeGLUT.

In order to do that we need fist to edit the file C:\Program Files\CodeBlocks\share\CodeBlocks\templates\glut.cbp with Notepad or any other text editor and replace any occurrence of the word glut32 for freeglut.

Then we go to the file C:\Program Files\CodeBlocks\share\CodeBlocks\templates\wizard\glut\wizard.script and also there we replace all the occurrences of glut32 for freeglut.

Now, if when creating a new project we select GLUT, a wizard will pop up asking things like the project name and the path.

Then it will ask the path to the GLUT library. Here you need to provide the path to the folder C:\freeglut and then finish creating the project.

This Wizard will create a demonstration project which you can compile and run.

I hope you find this tutorial useful.