This program reads a 3D graphic image file, in AutoDesk DXF format and displays it using openGL.
I wrote this program as a tool when I started learning openGL. OpenGL provides a set of low level functions that support 3D graphics. Because of its low level nature, creating an image directly from an openGL program can be tedious, since every point, of every polygon, in the image must be specified. I have a copy of the trueSpace 3D modeling program, so I decided to use this to build models. These models would then be written out in DXF format and read by my openGL program. An added benefit, I though, would be that I could read models created with other modeling programs, like 3D Studio and autoCAD.
The DXF file format was originally created by AutoDesk to represent 3D models and scenes built with autoCAD. The DXF file format is much more complicated that I originally realized. It has the feel of a file format created by Fortran programmers and it has evolved over the years. I succeeded in getting my program to read and properly display models that are described using the DXF file 3DFACE entity. The program also attempts to support the POLYLINE entity. Despite downloading documentation on both the autoCAD release 12 and release 13 DXF file formats, I was not able to get enough information to successfully implement the POLYLINE entity. Perhaps someone else will be able to use my code as the starting point for a DXF file reader than can successfully read POLYLINE entities.
A 3D model is, almost by definition, a dynamic object and the DXF to openGL program contains code to rapidly allocate and deallocate memory. At one point I thought that dynamic allocation, deallocation and reallocation were necessary to support POLYLINE entities, so I developed a memory allocater to support these features. This code is included as a separate program.
The software published on this web page is the oldest software on bearcave.com. It was published in early 1996, about six months after bearcave.com came on line (which was in the summer of 1995). I have not revised this software since.
A few things have happened since this software was published (like the dot-com boom and bust, the rise of Linux as a standard, "W" and his war without end). In the realm of 3D graphis, openGL seems to have become a solid standard. Microsoft supported openGL on Windows NT, but it has since become much more popular. For example, nVidia supports openGL on their blazing graphics chips. The popularity of openGL and some strong adherents, like John Cormack at Id Games, has placed a road block in the way of Microsoft's DirectX graphics "standard", which like many initiatives from Microsoft could be seen as yet another attempt to control "the platform" and dictate the standard (some things have not changed).
Historically computer games were software hacks, with little thought toward elegance in their design and implementation. John Cormack, who designed and implemented the 3D graphics engine for the Quake games, has never followed this course. He seems to pride himself in elegant, reliable, reusable code. He has also avoided the bloated ego of some game designers and implementers An interesting article on Cormack and his determination to use openGL (which is also supported on Linux) can be found in the reference below.
Lord of the Games by Dean Takahashi, February 1, 2002
AutoDesk DXF Reference, 2005 (PDF format)
Almost ten years ago, when I wrote this software, AutoDesk considered the DXF format proprietary and did not publish any documentation explaining the format. Documentation was available from other sources (people who had reverse engineered the format).
Sean Z. pointed me to the above document, published by AutoDesk. This 208 page document provides at least a partial reference for the DXF format. The format appears to have been significantly extended over the years since I last worked with it. The software published here reads only a small fraction of this format into OpenGL display lists. OpenGL has itself evolved over time. For example, the vertex and shading language did not exist in the version of OpenGL I was using. So there is much that could be done that is not implemented in this software.
back to home page