Advanced Graphics Using OpenGL

OpenGL is a library of graphic functions that create sophisticated graphic displays such as 3-D images and animation. OpenGL is commonly available on workstations. Writing to this standard allows your program to be ported easily to other platforms.

OpenGL windows are used independently of and in addition to any console, QuickWin and regular Windows windows your application uses. Every window in OpenGL uses a pixel format, and the pixels carry, among other things, RGB values, opacity values, and depth values so that pixels with a small depth (shallow) overwrite deeper pixels. The basic steps in creating OpenGL applications are:

OpenGL programming is straightforward, but requires a particular initialization and order, like other software tools. References to get you started are:

Visual Fortran provides an OpenGL module, DFOPNGL.MOD, invoked with the USE statement line:

  USE DFOPNGL

When you use this module, all constants and interfaces that bind Fortran to the OpenGL routines become available. Any link libraries required to link with an OpenGL program are automatically searched if USE DFOPNGL is present in your Fortran program.

An OpenGL window can be opened from a console, Windows, or QuickWin application. The OpenGL window uses OpenGL calls exclusively, not normal Graphic Device Interface (GDI) calls. Likewise, OpenGL calls cannot be made within an ordinary Windows window or QuickWin child window, because special initialization is required for OpenGL calls.

The Fortran OpenGL identifiers are the same as the C identifiers (such as using a GL_ prefix for constants), except that the gl prefix is changed to fgl for routines. The data types in the OpenGL C binding are translated to Fortran types as shown in the following table:

OpenGL/C Type Fortran Data Type
GLbyte INTEGER(1)
GLshort INTEGER(2)
GLint, GLsizei INTEGER(4)
GLfloat, GLclampf REAL(4)
GLdouble, GLclampd REAL(8)
GLubyte INTEGER(1)
GLboolean LOGICAL
GLushort INTEGER(2)
GLuint, GLenum, GLbitfield INTEGER(4)
GLvoid not needed
pointers INTEGER

If you include (USE) the parameter constant definitions from DFOPNGLT.F90 (such as by USE DFOPNGL), you can use the constants to specify the kind type, such as INTEGER(K_GLint) instead of INTEGER(4).

Visual Fortran Samples that use OpenGL are available in separate folders in ...\DF98\SAMPLES\ADVANCED\OPENGL. For example, OLYMPIC is a Fortran QuickWin project and CUBE5 is a Fortran Windows project.