Download Article
Easily install the latest OpenGL libraries on Linux Mint to render 2D and 3D graphics
Written byNicole Levine, MFA
Last Updated: September 13, 2023Fact Checked
Download Article
- Installing Mesa |
- Creating an OpenGL Program |
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>.
Method 1
Method 1 of 2:
Installing Mesa
Download Article
1
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
2
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.
Advertisem*nt
3
Add the Kisak Mesa PPA. You can use the Kisak PPA to get a newer version of Mesa on your Linux Mint system.[1] 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
4
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
5
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.
6
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]
- 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
Advertisem*nt
Method 2
Method 2 of 2:
Creating an OpenGL Program
Download Article
1
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.
2
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
3
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;}
4
Save the file and exit.
5
Compile your program. To build your program and link your Open GL libraries, use this command: g++ main.c -lglut -lGL -lGLU -o OpenGLExample
6
Run the program. To do this, type ./OpenGLExample and press Enter.
7
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".
Advertisem*nt
Community Q&A
Search
Question
Will this work for uBuntu 15.10?
Community Answer
Yes, it will definitely work for uBuntu 15.10.
Thanks! We're glad this was helpful.
Thank you for your feedback.
If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.Support wikiHowNot Helpful 4Helpful 12
Question
Will this work for Ubuntu 17.04?
Pingu
Top Answerer
It 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.
Thanks! We're glad this was helpful.
Thank you for your feedback.
If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.Support wikiHowYesNo
Not Helpful 2Helpful 2
Question
Can 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"?
Pingu
Top Answerer
Yes, you can. It's a long command and quite hard to read, but it will install all the necessary libraries.
Thanks! We're glad this was helpful.
Thank you for your feedback.
If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.Support wikiHowYesNo
Not Helpful 0Helpful 4
See more answers
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Advertisem*nt
Tips
Submit a Tip
All tip submissions are carefully reviewed before being published
Submit
Thanks for submitting a tip for review!
You Might Also Like
Advertisem*nt
References
About This Article
Written by:
Nicole Levine, MFA
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 336,227 times.
How helpful is this?
Co-authors: 16
Updated: September 13, 2023
Views:336,227
Categories: Linux
In other languages
Español:instalar Mesa (OpenGL) en Linux Mint
Русский:установить Mesa (OpenGL) в Linux Mint
Português:Instalar Mesa (OpenGL) no Linux Mint
- Send fan mail to authors
Thanks to all authors for creating a page that has been read 336,227 times.
Is this article up to date?
Advertisem*nt