Simple OpenGL Classes

Environment: Windows NT4 SP5, Windows 95b/98, Visual C++ 6

In engineering applications it is necessary to have 3D graphics functions which can make visualization using engineering data. The following simple classes provide such functions which have been implemented using SDK rather than MFC.

1. Features:

(1). 2D, 3D, and True 3D (4D) display
(2). Zooming and rotation.
(3). 4D cutting
(4). Legend and marker
(5). DIB printing
(6). Support some visualization properties such as color selection
(7). Support mixed GDI and OpenGL map rendering

2. History

From 1996 to 1998, I involved to develop a 3D reservoir modeling package using OpenGL and MFC on Windows NT with interpolation algorithms, such as Kriging, Neural Network, Fuzzy Logic, and genetic algorithms interpolation algorithms. However, the provided classes, which have been rewritten using Win32 API completely, only implement part of the original 3D reservoir modeling package. Due to time constraints, all interpolation algorithms and their binary file outputs, and nonregular 4D map display are not included in the above classes.

You are free to use or modify these classes and to use them in any of your applications. But I make no guarantees about these classes suitability for use. If there is any problem with anything I wrote, I will certainly try to help solve it.

3. Source Code

(1). OpenGL.h and OpenGL.cpp: property definition, map framework description, zooming, rotation, etc.

(2). OpenGL3D.h and OpenGL3D.cpp: implement the simplest 2D and 3D rendering.

(3). OpenGL4D.h and OpenGL4D.cpp: implement the simplest True 3D (4D) rendering.

4. Support classes

(1). ClassArr.h: template based class similar to MFC CArray, but independent on MFC.

(2). ColourPicker.h and ColourPicker.cpp: Codeguru code to implement colorpicker.

(3). Hdibapi.h and Hdibapi.cpp: DIB loading and saving.

(4). Str.h and Str.cpp: The simplest string class.

(5). TabWindow.h and TabWindow.cpp: MFC CTabCtrl derived component and contains an implementation of tab views.

5. Demo Project

The GLDemo, which is an MFC MDI application, demonstrates how to use classes mentioned above. It uses a splitter window. Most actions are shown in the left window and rendering is shown in the right window.

From the View menu, click Grid Data to load one of the grid data files (*.grd), where Surfer format files SurfA.grd (ASCII) and SurfB.grd, and other format files (defined by myself and available by request ) test3d.grd, test4d.grd, and true3d.grd. For 3D visualization, you can load maker file (the text file Marker.mrk only for SurfA.grd and SurfB.grd). Please note that Shitf + left mouse button down can move the legend. You can find most visualization properties in the left window. In addition, From File/Save To BMP, you can save the active window, client area, and any part of the client area (rectangle) to BMP.

About the Author

I am a senior software engineer for TechComm Simulation Pty Ltd., Sydney, Australia, where I specialize in Client/Server and TCP/IP programming on Unix and Windows NT. My e-mail address is


Download demo project - 253 Kb
Download source - 47 Kb