A guide to set up OpenGL projects in Debian.

mohimamimino11

Mimino11

Posted on May 14, 2023

A guide to set up OpenGL projects in Debian.

You will find a lot of articles on what OpenGL is & what's the uses of it. So, let's get straight into OpenGL initial setup which is given below step by step:

Step 1

installing dependencies:

Before installing the required libraries, we’ll first have to install a few dependencies. So open your terminal and run the following commands:



sudo apt-get update
sudo apt-get install cmake pkg-config
sudo apt-get install g++ mesa-utils libglu1-mesa-dev freeglut3 freeglut3-dev mesa-common-dev
sudo apt-get install libglew-dev libglfw3-dev libglm-dev
sudo apt-get install libao-dev libmpg123-dev


Enter fullscreen mode Exit fullscreen mode

Step 2

Installing and setting up the GLFW library:

Running the below commands would install GLFW in your system:



sudo nautlius


Enter fullscreen mode Exit fullscreen mode

The above command will grant you access to editing the root folders as a root administrator. Go to /usr and open the terminal there it should look something like this:

Image description

Afterward, run these commands in the terminal:



cd local/lib/
git clone https://github.com/glfw/glfw.git
cd glfw
cmake .
make
sudo make install


Enter fullscreen mode Exit fullscreen mode

Step 3

Now let's install GLAD library,It is an open-source library that makes use of a web service, allowing us to instruct GLAD as to the version of OpenGL we want to define and load all pertinent OpenGL functions for.
So to install this library, perform the following steps:

  1. Head on to the GLAD web service. 2.Set the language to C++ and choose the specification as OpenGL.
  2. In the API section, select gl version of at least 3.3, make sure the profile is set to Core, and that the Generate a loader option is ticked. 4.Ignore the extensions and click Generate to produce the resulting library files. 5.GLAD, by now, should have provided you a zip file: glad.zip containing two folders(include and src). 6.Copy the folders inside include (glad and KHR) into your include(s) directory: cp -R include/* /usr/include/ 7.Now copy the file glad.c inside the src folder to your current working directory.

Step 4

Now choose your prefered IDE as you’re now done with installing the required libraries. It's time to check that everything was installed correctly using the "Hello Triangle" application, a straightforward triangle rendering tool. The code is available here ; you can copy it and save it ashello_triangle.cpp
Let’s compile our code & generate an executable a.out:



g++ hello_triangle.cpp glad.c -ldl -lglfw


Enter fullscreen mode Exit fullscreen mode

Run ./a.out to see the program work. You should get the output as below:

Image description

Your setup for OpenGL is now complete. I hope things went smoothly and you were successful. Read this if you want to understand more about the source code you just copied!

See you then. Until next time!

💖 💪 🙅 🚩
mohimamimino11
Mimino11

Posted on May 14, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related