0% found this document useful (0 votes)
161 views2 pages

How To Install Mesa (OpenGL) On Linux Mint - 6 Steps

Uploaded by

ankitfrnd45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views2 pages

How To Install Mesa (OpenGL) On Linux Mint - 6 Steps

Uploaded by

ankitfrnd45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

12/13/2016 How to Install Mesa (OpenGL) on Linux Mint: 6 Steps

How to Install Mesa (OpenGL) on Linux Mint


Three Parts: Prepare your Linux Mint operating system for OpenGL Development Create your first OpenGL program
Compile and Run your OpenGL application

Mesa is an open-source implementation of the OpenGL specification - a system for rendering interactive 3D graphics. Technically,
OpenGL is just a specification, implemented by your graphics driver. There's no such thing like an OpenGL SDK library. There's
just libGL.so which comes with your driver. To use it, you need bindings for your programming language of choice. If that is C,
the "bindings" consist of just the header files. However you'll probably also want to use OpenGL extensions, which is easy using
GLEW.

A variety of device drivers allows Mesa to be used in many different environments ranging from software emulation to complete
hardware acceleration for modern GPUs. Mesa ties into several other open-source projects: the Direct Rendering Infrastructure
and X.org to provide OpenGL support to users of X on Linux, FreeBSD and other operating systems.

Part
1 Prepare your Linux Mint operating system for OpenGL
Development
1 Open a terminal and enter the following commands to install the necessary libraries for OpenGL
development:
Type/Copy/Paste: sudo apt-get update
Type/Copy/Paste: sudo apt-get install freeglut3
Type/Copy/Paste: sudo apt-get install freeglut3-dev
Type/Copy/Paste: sudo apt-get install binutils-gold
Type/Copy/Paste: sudo apt-get install g++ cmake
Type/Copy/Paste: sudo apt-get install libglew-dev
Type/Copy/Paste: sudo apt-get install g++
Type/Copy/Paste: sudo apt-get install mesa-common-dev
Type/Copy/Paste: sudo apt-get install build-essential
Type/Copy/Paste: sudo apt-get install libglew1.5-dev libglm-dev

2 After your development libraries have been installed to get information about the OpenGL and GLX
implementations running on a given X display.
Type/Copy/Paste: glxinfo | grep OpenGL

Part
2 Create your first OpenGL program

1 To create an OpenGL program, open up a terminal, make a directory, change into the directory and use your
favorite text editor such as nano or gedit to create your OpenGL source code. Enter the following commands
below.
Type/Copy/Paste: mkdir Sample-OpenGL-Programs
this will create a directory to hold your OpenGL programs

Type/Copy/Paste: cd Sample-OpenGL-Programs
this will change you into your directory

Type/Copy/Paste: "nano main.c" OR "gedit main.c"

http://www.wikihow.com/Install-Mesa-(OpenGL)-on-Linux-Mint 1/2
12/13/2016 How to Install Mesa (OpenGL) on Linux Mint: 6 Steps

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

Part
Compile and Run your OpenGL application
3

1 While in the Sample-OpenGL-Programs directory run the following command below.

Type/Copy/Paste: g++ main.c -lglut -lGL -lGLEW -lGLU -o OpenGLExample


this command will compile and link your OpenGL libraries.

2 In order to run the program type the following below:

Type/Copy/Paste: ./OpenGLExample

3 For more information on OpenGL and other tutorials for you to try, see the following online reference
manuals.
OpenGL Red Book
OpenGL Blue Book

http://www.wikihow.com/Install-Mesa-(OpenGL)-on-Linux-Mint 2/2

You might also like