How to Install Mesa (OpenGL) on Linux Mint

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

Part 1 of 3:

Preparing Your Linux Mint Operating System for OpenGL Development

  1. Picture 1 of How to Install Mesa (OpenGL) on Linux Mint
    Open a terminal and enter the following commands to install the necessary libraries for OpenGL development:
    1. Enter sudo apt-get update
    2. Enter sudo apt-get install freeglut3
    3. Enter sudo apt-get install freeglut3-dev
    4. Enter sudo apt-get install binutils-gold
    5. Enter sudo apt-get install g++ cmake
    6. Enter sudo apt-get install libglew-dev
    7. Enter sudo apt-get install g++
    8. Enter sudo apt-get install mesa-common-dev
    9. Enter sudo apt-get install build-essential
    10. Enter sudo apt-get install libglew1.5-dev libglm-dev
  2. Picture 2 of How to Install Mesa (OpenGL) on Linux Mint
    Get information about the OpenGL and GLX implementations running on a given X display. To do this, enter glxinfo .
Part 2 of 3:

Creating Your First OpenGL Program

  1. Picture 3 of How to Install Mesa (OpenGL) on Linux Mint
    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.
    1. Enter mkdir Sample-OpenGL-Programs
      1. This will create a directory to hold your OpenGL programs.
    2. Enter cd Sample-OpenGL-Programs
      1. This will change you into your directory.
    3. Enter nano main.c OR gedit main.c
  2. 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; } 
  3. Picture 4 of How to Install Mesa (OpenGL) on Linux Mint
    Save the file and exit.
Part 3 of 3:

Compiling and Running Your OpenGL Application

  1. Picture 5 of How to Install Mesa (OpenGL) on Linux Mint
    Enter the Sample-OpenGL-Programs directory. While there, run the following command:
    1. g++ main.c -lglut -lGL -lGLEW -lGLU -o OpenGLExample
      1. This command will compile and link your OpenGL libraries.
  2. Picture 6 of How to Install Mesa (OpenGL) on Linux Mint
    Run the program. To do this, type the following:
    1. Enter ./OpenGLExample
  3. Picture 7 of How to Install Mesa (OpenGL) on Linux Mint
    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".

You've just finished reading the article "How to Install Mesa (OpenGL) on Linux Mint" edited by the TipsMake team. You can save how-to-install-mesa-opengl-on-linux-mint.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.

« PREV : How to Install Linux...
How to Uninstall... : NEXT »