Computational Geometry

Programming Tools for Computational Geometry

Contents

C++ programming hints

Practical information about C++ programming at DAIMI: how to use the GDB debugger, an introduction to STL, how to get started using CVS, how to use make to build your programs etc.

A simple programming example

This simple program illustrates the use of GLUT and OpenGL i 2D from C++. The program should compile on both Linux, IRIX and Windows. Under Linux the program is compiled with the command:
g++ -L/user/X11R6/lib 3dpoints.cpp -lglut -lGLU -lGL -lXmu -lX11 -lXi -lm
The program opens a window where a triangle is displayed. The corners of the triangle can be moved by the mouse. If you press the right mouse button a popup-menu appears where you can create a new triangle or quit the program. Try resizing the window and observe how all graphics scales automatically.

[screenshot]

Note: The SGI machines support GLX (OpenGL over X) which means that an OpenGL program running on one SGI may display on another SGI, just like with ordinary X windows. This, however, does not work too well with Linux unless you are using the unaccelerated Mesa OpenGL libraries. To avoid problems: compile and run your programs on the local machine.

A 3D example

This program illustrates how to program simple 3D graphics with OpenGL and GLUT. Under Linux the program is compiled with the command:
g++ -L/usr/X11R6/lib 3dpoints.cpp -lglut -lGLU -lGL -lXmu -lX11 -lXi -lm
The program controls a spherical cursor in 3D using the mouse. Points can be placed in the 3D world by pressing the space key. The camera can be rotated around the cursor while pressing the shift key and moving the mouse. The program also draws a ground plane and shadows to make it easier to judge the distance to objects.

other screenshot

GLUT reference documentation

GLUT (the Open GL Utility Toolkit) builds on top of OpenGL, and provides an API which makes it easy to write simple, portable, programs that use OpenGL. You may learn more about GLUT via opengl.org and the GLUT reference documentation.

OpenGL reference documentation

OpenGL is a standard, cross-platform, API for drawing 3D and 2D graphics. The OpenGL specifications are available at opengl.org. There is a tutorial on Gamedev.net.

GLU reference documentation

GLU (OpenGL Utilities) also builds on top of OpenGL, and is used by GLUT. GLU implements mipmapping support, polygon tessellation, quadrics and NURBS. The GLU specifications are available at opengl.org.


Peter Ørbæk, poe@daimi.au.dk, August 2001
Modified by Gerth Stølting Brodal, gerth@cs.au.dk, September 2004