1. Install OpenGL library
For installing OpenGL, again, make sure you follow the instructions carefully. In this section, we will point
you to verified approaches to get going with OpenGL on CSIL and your own Linux,
Windows, or MacOS computers. OpenGL is available for all modern operating
systems, but you will need to make sure you have the latest drivers for your
computer GPU in order for it to work properly, or install a software-only
implementation (e.g. Mesa).
Once you have the proper libraries installed, you will need to link
those libraries and include the proper header files for OpenGL/GLUT
development
CSIL
OpenGL is already installed for you on CSIL. Include the following header files:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
Additionally, you will
need to point the linker to several libraries. This can be accomplished with CMake by
adding the following lines to your CMakeLists.txt
FIND_PACKAGE( OpenGL )
FIND_PACKAGE( GLU )
FIND_PACKAGE( GLUT )
and update your target link libraries to also include ${OpenGL_LIBRARY}, ${GLU_LIBRARY} and
${GLUT_LIBRARY}.Alternatively, for command-line
compilation/linking, you can use the following flags for g++ or ld: "-lGL -lGLU -lglut".
X11 libraries (-L/usr/X11R6/lib/ -lXmu -lXi -lXext -lX11 -lXt) apparently don't currently need
to be specified.
Your own Linux system or Windows system
Both Linux and Windows system will likely require you to download drivers specific to your graphics card.
Unfortunately, these drivers are not consistent in their installation and will
likely install in different folders on your machine depending on which driver
you need. Instructions for downloading and installing these drivers can be
found on the OpenGL
website. Linux and Windows users will also likely need to install
GLUT. If you are developing under MinGW, you can follow
these instructions.On your own Linux system, the include and library
specifications are likely similar to the ones on CSIL.
On Windows, you will have to link against the libraries opengl32.lib, glut32.lib,
glu32.lib that were installed in previous steps. This can be done both
with MinGW and CMake or within an IDE such as Visual Studio. You will have to include
the following lines in source code:
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <windows.h>
Your own MacOS system
Luckily, MacOS installs OpenGL as part of the OS, and OpenGL updates are
pushed with regular software updates. Before beginning, make sure you have
the latest software update on your Mac.
Follow the same instructions as for linux, except your include lines should
instead be:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
If you want to compile/link from the Terminal command line, add the
following flags:
-framework OpenGL -framework GLUT