Download Article
Easily install the latest OpenGL libraries on Linux Mint to render 2D and 3D graphics
Download Article
Mesa is an open-source implementation of OpenGL for Linux. Installing Mesa on Linux Mint gives you access to OpenGL, Vulkan, and other graphics-related libraries needed for gaming (including with Steam ) and game development. The most up-to-date version of Mesa is not available from your system's repository, but you can get the latest hardware support and features by installing the Kisak Mesa PPA. This wikiHow guide will walk you through installing Mesa and other important OpenGL libraries on Linux Mint and show you how to create and compile your first OpenGL program.
Things You Should Know
- To install the Kisak Mesa PPA, use this command: sudo add-apt-repository ppa:kisak/kisak-mesa
- If you want to write games and programs, you'll also want to install other OpenGL libraries, including GLEW, freeglut, mesa-common-dev, and mesa-utils.
- To compile a C program that uses these OpenGL libraries, use g++ <program_name.c> -lglut -lGL -lGLU -o <program_name> .
Steps
-
Update the package index and installed packages. Before installing the necessary libraries for OpenGL development , you'll need to make sure Linux Mint has the latest version of the package index, and that your existing packages are up to date. Run the following commands in your Terminal:
- sudo apt update
- sudo apt upgrade
-
Remove previous Mesa PPAs. If you've already installed kisak-mesa and want to upgrade the libraries, remove the current installation first. To do so, run these commands:
- sudo apt install ppa-purge
- sudo ppa-purge -d jammy ppa:kisak/kisak-mesa
- If you're using a version of Linux Mint that isn't based on Ubuntu Jammy Jellyfish, replace jammy with your version. For example, if you're using Linux Mint 20, which is built on Ubuntu Focal Fossa, you'd use sudo ppa-purge -d focal ppa:kisak/kisak-mesa .
Advertisement -
Add the Kisak Mesa PPA. You can use the Kisak PPA to get a newer version of Mesa on your Linux Mint system. [1] X Research source To do so, run these commands:
- sudo add-apt-repository ppa:kisak/kisak-mesa
- If you get an error that says "command not found," run sudo apt-get install software-properties-common . Then, try again.
- sudo apt update
- sudo add-apt-repository ppa:kisak/kisak-mesa
-
Install Mesa Utilities. the Kisak Mesa to Linux Mint. Now that you've added the PPA, run this command to install the Mesa utilities on Linux Mint:
- sudo apt install mesa-utils
-
Verify the installation. Once Mesa is installed, run the command glxinfo | grep "OpenGL version" to check your Mesa version.
- If you plan to upgrade Linux Mint or upgrade Mesa, remove this PPA before doing so using the command in Step 2 .
-
Install additional libraries. To make sure you have what you'll need to be able to compile programs with GLEW (OpenGL Extension Wrangler Library), and have several other libraries installed:
- Run this command to install GNU make and other build tools: sudo apt install build-essential libxmu-dev libxi-dev libgl-dev binutils . [2] X Research source
- Install the GLEW packages using this command: sudo apt install glew-utils libglew2.2 libglewmx-dev libglewmx1.13
- Install freeglut: sudo apt install freeglut3-dev freeglut3
- Install mesa-common-dev: sudo apt install mesa-common-dev
Advertisement
-
Create a directory for your program. Change into your preferred directory, then use the mkdir command to create a directory for your program. For example, mkdir Sample-OpenGL-Programs .
-
Create a text file with your favorite text editor. Enter the directory you created using cd Sample-OpenGL-Programs , then use any text editor (such as vi, nano, or gedit) to create a file called main.c . For example, nano main.c
-
Copy and paste OR type the code:
#include <GL/freeglut.h> #include <GL/gl.h> void renderFunction () { glClearColor ( 0.0 , 0.0 , 0.0 , 0.0 ); glClear ( GL_COLOR_BUFFER_BIT ); glColor3f ( 1.0 , 1.0 , 1.0 ); glOrtho ( - 1.0 , 1.0 , - 1.0 , 1.0 , - 1.0 , 1.0 ); glBegin ( GL_POLYGON ); glVertex2f ( - 0.5 , - 0.5 ); glVertex2f ( - 0.5 , 0.5 ); glVertex2f ( 0.5 , 0.5 ); glVertex2f ( 0.5 , - 0.5 ); glEnd (); glFlush (); } int main ( int argc , char ** argv ) { glutInit ( & argc , argv ); glutInitDisplayMode ( GLUT_SINGLE ); glutInitWindowSize ( 500 , 500 ); glutInitWindowPosition ( 100 , 100 ); glutCreateWindow ( "OpenGL - First window demo" ); glutDisplayFunc ( renderFunction ); glutMainLoop (); return 0 ; }
-
Save the file and exit.
-
Compile your program. To build your program and link your Open GL libraries, use this command: g++ main.c -lglut -lGL -lGLU -o OpenGLExample
-
Run the program. To do this, type ./OpenGLExample and press Enter .
-
Wait for a result. If you did everything right, a window will open. It will show a white square on a black background. The window will be titled "OpenGL - First window demo".
Advertisement
Community Q&A
Search
-
QuestionWill this work for uBuntu 15.10?Community AnswerYes, it will definitely work for uBuntu 15.10.
-
QuestionWill this work for Ubuntu 17.04?PinguTop AnswererIt should work on any platform for which these packages are available through apt (i. e. on any recent version of Ubuntu or Debian or Mint). It worked on Ubuntu 16.04 for me. The only thing different from these instructions is that the package libglew1.5-dev doesn't exist. But if you just install libglew-dev, it will still work.
-
QuestionCan I install the libraries with a single command: "sudo apt-get install build-essential freeglut3 freeglut3-dev binutils-gold g++ cmake libglew-dev mesa-common-dev libglew1.5-dev libglm-dev"?PinguTop AnswererYes, you can. It's a long command and quite hard to read, but it will install all the necessary libraries.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Tips
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
References
About This Article
Thanks to all authors for creating a page that has been read 346,130 times.
Advertisement