Next: 2 Example Walk Through Up: OpenGL and X Previous: OpenGL and X

1 Introduction

In the first article in this series, the OpenGL graphics system was introduced. Along with an explanation of the system's functionality, a simple OpenGL X program was presented and OpenGL was compared to the X Consortium's PEX extension. In this article, a more involved example of programming OpenGL with X is presented. The example is intended to demonstrate both sophisticated OpenGL functionality and proper integration of OpenGL with the X Window System.

This article is intended to answer questions from two classes of programmers: first, the X programmer wanting to see OpenGL used in a program of substance; second, the OpenGL or IRIS GL programmer likely to be unfamiliar with the more mundane window system setup necessary when using the X Window System at the Xlib layer.

The example program called glxdino renders a 3D dinosaur model using OpenGL. Hidden surfaces are removed using depth buffering. Back-face culling improves rendering performance by not rendering back-facing polygons. Hierarchical modeling is used to construct the dinosaur and render it via OpenGL display lists. The OpenGL Utility Library (GLU) polygon tessellation routines divide complex polygons into simpler polygons renderable by OpenGL. Sophisticated lighting lends realism to the dinosaur. If available, double buffering smoothes animation.

The program integrates well with the X Window System. The program accepts some of the standard X command line options: -display, -geometry, and -iconic. The user can rotate the model using mouse motion. Top-level window properties specified by the Inter-Client Communication Convention Manual (ICCCM) are properly set up to communicate with the window manager. Colormap sharing is done via ICCCM conventions. And the proper way of communicating to the window manager a desire for a constant aspect ratio is demonstrated.

A walk through of the glxdino source code is presented in Section 2. While glxdino tries to demonstrate a good number of OpenGL features and many of the issues concerning how X and OpenGL integrate, it is only an example. Section 3 explores more of the issues encountered when writing an advanced OpenGL program using Xlib. The third and last article in this series discusses how to integrate OpenGL with the Motif toolkit.



Next: 2 Example Walk Through Up: OpenGL and X Previous: OpenGL and X


mjk@asd.sgi.com
Wed Oct 19 18:11:46 PDT 1994