Set up OpenGL Utility Toolkit (GLUT) and Codeblocks on Linux
Tags: codeblocks, fedora, glut
Published: 2020-02-03 22:26:35

---
title: Set up OpenGL Utility Toolkit (GLUT) and Codeblocks on Linux
published: true
date: 2020-01-27 17:54:46 UTC
tags: Codeblocks,fedora,GLUT
canonical_url: https://i3.ninja/set-up-opengl-utility-toolkit-glut-and-codeblocks-on-linux/
---

Before we continue, let’s discuss something about GLUT and Codeblocks.

Here we use [FreeGLUT](http://freeglut.sourceforge.net) instead of the original [GLUT](https://github.com/markkilgard/glut) written by [Mark Kilgard](https://en.wikipedia.org/wiki/Mark_Kilgard). FreeGLUT is an open source alternative to the OpenGL Utility Toolkit (GLUT) library with a free software license. FreeGLUT allows us to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard, and joystick functions.

[Codeblocks](https://codeblocks.org/) is a free C++ IDE that is extensible and configurable. Codeblocks can be extended with plug-in DLLs and even you can compile your own plug-ins.

Before we begin to set up, let’s prepare some packages that need to be installed beforehand.

### Install Codeblocks

- On **Fedora**

```
sudo dnf install codeblocks
```

- On **Ubuntu**

```
sudo apt install codeblocks
```

### Install FreeGLUT

- On **Fedora**

```
sudo dnf install freeglut-devel
```

- On **Ubuntu**

```
sudo apt install freeglut3-dev
```

### Set up GLUT in Codeblocks

1. Open Codeblocks  
 ![](https://i1.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-27-23-48-46.png?w=616&ssl=1)
2. Go to **Settings** -> **Global variables…**  
 ![](https://i1.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-27-23-50-25.png?w=616&ssl=1)
3. Under **Current variable** , click **New** and create **glut** variable  
 ![](https://i1.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-27-23-51-26.png?w=616&ssl=1)
4. Fill in each field as shown below, and click **Close** when finish
  - On **Ubuntu**  
 ![](https://i1.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-09-08.png?w=616&ssl=1)
  - On **Fedora**  
 ![](https://i2.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-11-59.png?w=616&ssl=1)

### Let’s try to create a new project

1. Open the project wizard ![](https://i0.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-14-13.png?w=616&ssl=1)
2. Create a “HelloWorld” Project  
 ![](https://i0.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-15-22.png?w=616&ssl=1)
3. Use **glut** global variable  
 ![](https://i2.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-15-51.png?w=616&ssl=1)
4. Leave the default compiler configuration as it is and then click **Finish**  
 ![](https://i0.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-15-56.png?w=616&ssl=1)
5. A demo project will be created as shown in below  
 ![](https://i2.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-16-12.png?w=616&ssl=1)
6. Run the demo project, and we’ll see this wonderful objects  
 ![](https://i0.wp.com/i3.ninja/wp-content/uploads/2020/01/Screenshot-from-2020-01-28-00-16-44.png?w=616&ssl=1)

* * *

Photo by [Olia Gozha](https://unsplash.com/@olia?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/white?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)