CSPC 3710: OpenGL Installation

The instructions were last updated January 1, 2022. Some of these may be outdated.

You should setup your machine to be able to compile and run the sample code included here: opengl.zip. Once running, you may press 's' to start rotation, 'e' to stop rotation, and 'Esc' to quit.


Linux installation

We are assuming you use the standard g++ compilers.

The libraries needed are freeglut, mesa, and libglew. Depending on your distribution, there may be prebuilt packages available. Instructions below are for a recent Ubuntu distribution. If you use other distributions, you will have to adjust appropriately.

For Ubuntu (20.04LTS), some instructions to install the necessary libraries can be found here or here. Actually more than the minimum is installed but they should work.

Note: in the first link, there is a typo in one of the commands: "cmakelibglew-dev" should be "cmake libglew-dev".

Note: on some machines the Mesa driver in 20.04LTS is bugged and may cause your OpenGL programs to crash on exit. This can be solved by upgrading to Ubuntu 20.10 (or you can ignore it).


MacOS installation

Unfortunately it appears that modern OpenGL is not supported on Macs. Your best option may be to set up a virtual machine and run Ubuntu Linux on top of it. Once you set up a Virtual machine and installed Ubuntu, you can follow the instructions above.

If you managed to install Ubuntu but the program crashes with something about GLSL 1.50 not supported or other kinds of GLX errors, you may want to try adding these two lines to your environment (assuming bash) before you run the program:

export MESA_GL_VERSION_OVERRIDE=3.2
export MESA_GLSL_VERSION_OVERRIDE=150

If that works, add it to your .bashrc file the environment is set up every time you log in.

Here are some other resources that may or may not be relevant if you choose to not use a virtual machine.


Windows installation

It looks like the best bet is to use the MSYS2/MinGW. See here.

Note: the library names appear to be somewhat different. You will need to edit the Makefile to use

  LIBS=-lfreeglut -lglew32 -lopengl32 -lglu32


howard.cheng@uleth.ca