OPENGL
Examples of OpenGL Graphics


OPENGL is a directory of C programs which demonstrate the use of the OpenGL graphics library.

It is possible to do a wide range of sophisticated 2D and 3D graphics presentations. OpenGL v1.1 software runtime is included as part of the operating system for WinXP, Windows 2000, Windows 98, Windows 95 (OSR2) and Windows NT. The OpenGL v1.1 libraries are also available as a self-extracting archive file from the Microsoft Site via HTTP or FTP.

OpenGL is most commonly used with C or C++ programs, but can also be called by a FORTRAN program if the necessary intermediate "FORTRAN bindings" (an interface package) have been installed.

OpenGL only does graphics rendering, and has no concept of windowing systems, input devices, printing to the screen and so on. These extra functions must be provided by an auxilliary package. One common package as known as GLUT, for the Graphics Language Utility Toolbox.

OpenGL on Macintosh OS X

OpenGL ships with OS9 and OSX for the Macintosh. You can obtain the latest software version on the Apple OpenGL web site.

Note that the source code and compilation script have been adapted for use on a Macintosh running OS X.

For that reason, the include file references have been changed from:


        # include <GL/gl.h>
        # include <GL/glu.h>
        # include <GL/glut.h>
      
to:

        # include <OpenGL/gl.h>
        # include <OpenGL/glu.h>
        # include <GLUT/glut.h>
      

The compilation statement, which might ordinarily be


        g++ myprog.C -lGL -lGLU -lglut 
      
was modified to:

        g++ myprog.C -framework OpenGL -framework GLUT
      

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

OPENGL examples are available in a C version and a C++ version.

Related Data and Programs:

CAUSTIC_OPENGL, a C++ program which computes a caustic curve and displays it using OpenGL.

FLOOD_OPENGL, a C program which allows a user to select a region and flood it with color, using OpenGL, by Art Wetzel.

LIFE_OPENGL, a C program which simulates a version of John Conway's "Game of Life", displaying the results using OpenGL.

PPMA, a data directory which describes the ASCII Portable Pixelmap format, which is a possible means of storing the graphics information displayed by OpenGL. One of the example programs shows how this can be done.

TET_MESH_DISPLAY_OPENGL, a C++ program which reads a pair of files defining a tetrahedral mesh and displays an image using OpenGL.

TRIANGULATION_DISPLAY_OPENGL, a C++ program which reads a pair of files defining a triangulation and displays an image using OpenGL.

XY_DISPLAY_OPENGL, a C++ program which reads an XY file of 2D point coordinates, and displays an image of those points using OpenGL.

XYZ_DISPLAY_OPENGL, a C++ program which reads an XYZ file of 3D point coordinates, and displays an image of those points using OpenGL.

Reference:

  1. Edward Angel,
    Interactive Computer Graphics, a Top-Down Approach with OpenGL,
    Addison-Wesley, 2000,
    ISBN: 0-201-38597-X,
    LC: T385.A514.
  2. Renate Kempf, Chris Frazier, editors,
    OpenGL Reference Manual,
    Fourth Edition,
    Addison-Wesley, 2004,
    ISBN: 032117383X,
    LC: T385.O642.
  3. Mason Woo, Jackie Neider, Tom Davis,
    OpenGL Programming Guide,
    Addison-Wesley, 1997,
    ISBN: 0-201-46138-2,
    LC: T385.N435.
  4. Richard Wright, Michael Sweet,
    OpenGL Superbible,
    Third Edition,
    Sams, 2004,
    ISBN: 0672326019,
    LC: T385.W73.
  5. http://www.opengl.org/
    The official OpenGL site.

Examples and Tests:

GASKET_POINTS displays the Sierpinksi gasket by showing 5000 points.

HELLO just draws a blue rectangle.

PLANET draws a wireframe sun and planet. The "d" and "y" keys make the planet rotate and revolve.

TEAPOT draws a teapot. The level of recursion is a command-line argument.

You can go up one level to the C source codes.


Last revised on 12 September 2012.