Getting started with openGL on Linux and Windows
Compiled by Vinod Pathangay (
vinod AT cse DOT iitm DOT ernet DOT in )
Updated by Amit Padhy
(padhy AT cse DOT iitm DOT ac DOT in )
OpenGL (GLUT) on Linux (Fedora core 4)
Starting FC4 you just need to
install freeglut .
OpenGL (GLUT) on Linux (Fedora core 1)
Installation
Check if the following rpms are installed
1.
XFree86-Mesa-libGL-4.3.0-42 download
2. XFree86-Mesa-libGLU-4.3.0-42
download
3. glut-3.7-8 download
4. glut-devel-3.7-8
download
You can check this using the commands
rpm -qa |
grep glut
rpm -qa | grep GL
If you do not have
the above packages installed, then download and install using the following
command as root (replace fileName.rpm
with each of the above
downloaded files)
rpm -ivh fileName.rpm
Once you have
the above RPMs and their dependencies installed then you are ready to compile
and run OpenGL programs.
OpenGL (GLUT) on Linux (Ubuntu)
Installation
Install the following packages from the ubuntu repository:
1. freeglut3-dev
2. mesa-common-dev
sudo apt-get install freeglut3 freeglut3-dev mesa-common-dev
Check your /usr/include/GL folder to verify the installation of the openGL headers that you intend to use.
Compiling and Linking
You will have to use the -lglut
linker option with gcc/g++ to compile a program with glut library.
For example, to compile the program cube.c that uses GLUT
type, use
gcc -o cube cube.c -lglut -lGLU
to get the binary executable
cube.
If you are not using GLUT and want to use the lower level
libraries then use -lGL -lGLU
also in the linker options.
OpenGL (GLUT) on Windows
Installation
You will need the following files for developing OpenGL
programs
opengl32.lib
glu32.lib
gl.h
glu.h
These are
usually provided by the manufacturer of your display adapter. The following
files will also be needed for using GLUT
glut32.dll
glut32.lib
glut.h
Download GLUT.
Unzip and copy glut32.dll to C:\Windows\system32
Compiling and Linking using MS Visual Studio
For GLUT programs
1.
Start Visual C++ and create a new empty project of type Win32 Console
Application.
2. Add a GLUT program to the project like cube.c .
3. Goto
Projects, Settings, C++ tab, select Category - Preprocessor. In the additional
include directory box give the path where GL/glut.h is present.
4. Goto
Projects, Settings, Link tab, select Category - Input. In additional library
path give the location of glut32.lib
Some examples
dot plot
single torus
complex scene
.