CSc 433/533: OpenGL and GLUT Tutorial

Contents

  1. Useful link
  2. Introduction
  3. Platforms
  4. A Simple Example
  5. GLUT Event Loop
  6. OpenGL Command Syntax
  7. OpenGL Primitives
  8. Double Buffering in GLUT
  1. OpenGL Specification
  2. OpenGL Man Pages at Sun.

  1. Introduction
  2. OpenGL is an interface to graphics hardware. The GL stands for Graphics Library. It provides commands for specifying geometric objects in two or three dimensions, and for controlling how these objects are drawn on the display. Objects, in this case, are points, lines, polygons, images, and bitmaps.

    Mesa is a free implementation of the OpenGL specification. Mesa is the implementation of OpenGL on Lectura that we will use. It is in ~cs433/Fall00/Mesa-3.2.1/. The Mesa distribution contains many demo programs. They are in the subdirectories demos, xdemos, samples, and book. In order to execute these demos, you must set your LD_LIBRARY_PATH environment variable using the following command:

    setenv LD_LIBRARY_PATH /home/cs433/Fall00/Mesa-3.2.1/lib

    This tells the computer where to look for the Mesa shared libraries that are needed by the demo programs.

    OpenGL does not provide commands for performing windowing tasks or for obtaining user input. These commands are provided by GLUT (the OpenGL Utility Toolkit). GLUT provides commands to create windows, subwindows, and menus; and to handle input from a variety of devices via a callback mechanism. Documentation is available in pdf or postscript form.

    Both OpenGL and GLUT work with the C or C++ programming languages.

  3. Platforms
  4. Mesa and GLUT are free and they work on a wide range of operating systems including Linux and Windows. They are both very easy to install. The Mesa distribution, in fact, contains a version (perhaps not the latest version) of GLUT. So if you install Mesa, you get GLUT at no extra effort. If you have a 3D graphics card that supports OpenGL, you might be able to configure Mesa to take advantage of its features. Look at Mesa's installation instructions for further information.

    It is possible that an OpenGL library came with your compiler (e.g. Microsoft Visual C++) in which case you only need to get GLUT. You can use Mesa (I think) but it probably isn't worth the trouble. I used GLUT with Microsoft's OpenGL library without any problems.

    Whatever your system, it should be possible to set up the required libraries so that you will be able to do all the assignments on your home machine. HOWEVER, you should make sure that your programs compile and run correctly on Lectura because that's where I will execute them.

    Windows 95/98 With Visual C++ If you would like to develop your program using Windows with Visual C++, a project with the glut .lib file for windows can be downloaded here. This project includes the GLUT/OpenGL example file canvas.c. For more information on canvas.c, click here.

    If you would like the entire GLUT package for windows (the source code), click here. The library must be complied, and it includes a Makefile using nmake which can be read by visual c++.

    See the GLUT home page or the Mesa home page for more detailed installation instructions.