3 Ways to Install Mesa Open GL on Linux Mint

Table of contents:

3 Ways to Install Mesa Open GL on Linux Mint
3 Ways to Install Mesa Open GL on Linux Mint
Anonim

Mesa is an open-source implementation of the OpenGL engine - a system that allows you to view interactive 3D graphics. Technically, OpenGL is just a specification, implemented by your graphics drivers. There is no such thing as an Open GL SDK library; exists libGL.so which is present in your drivers. To use it, you need "bindings" for the programming language of your choice. If it is C, the "binding" consists only of the header files. But you'll probably want to use OpenGL extensions too, and it's easy using GLEW.

Many drivers allow Mesa to be used in many different environments, from software emulation to full hardware acceleration for modern GPUs. Mesa pairs with many other open-source projects: the Direct Rendering Infrastructure and X.org to provide OpenGL support for users running X on Linux, FreeBSD, and other operating systems.

Steps

Method 1 of 3: Prepare the Linux Operating System for OpenGL

Install Mesa (OpenGL) on Linux Mint Step 1
Install Mesa (OpenGL) on Linux Mint Step 1

Step 1. Open the terminal and enter the following commands to install the libraries needed 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

Install Mesa (OpenGL) on Linux Mint Step 2
Install Mesa (OpenGL) on Linux Mint Step 2

Step 2. After installing the development libraries to get information about OpenGL and GLX implementations on a given X display

  • Type / Copy / Paste:

    glxinfo | grep OpenGL

Method 2 of 3: Create Your First OpenGL Program

Install Mesa (OpenGL) on Linux Mint Step 3
Install Mesa (OpenGL) on Linux Mint Step 3

Step 1. To create an OpenGL program, open the terminal, create a folder, navigate to that path and use your favorite text editor such as nano or gedit to create your OpenGL source code

Type the following commands.

  • Type / Copy / Paste:

    mkdir Sample-OpenGL-Programs

    you will create a folder to hold the OpenGL programs

  • Type / Copy / Paste:

    cd Sample-OpenGL-Programs

    you will reach the folder path

  • Type / Copy / Paste:

    "nano main.c" OR "gedit main.c"

    Copy and paste OR type the code

    #include #include 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.

      Install Mesa (OpenGL) on Linux Mint Step 4
      Install Mesa (OpenGL) on Linux Mint Step 4

Method 3 of 3: Build and Run Your OpenGL Application

Install Mesa (OpenGL) on Linux Mint Step 5
Install Mesa (OpenGL) on Linux Mint Step 5

Step 1. When you are in the Sample-OpenGL-Programs folder path run the following commands

  • Type / Copy / Paste:

    gcc -lglut -lGL -lGLEW -lGLU main.c -o OpenGLExample

    With this command you will compile and link your OpenGL libraries

Install Mesa (OpenGL) on Linux Mint Step 6
Install Mesa (OpenGL) on Linux Mint Step 6

Step 2. To run the program type the following command:

  • Type / Copy / Paste:

    ./OpenGLExample

Step 3. For more information on OpenGL and other tutorials to try, check out the following online reference materials

  • OpenGL Red Book
  • OpenGL Blue Book

Recommended: