SIGGRAPH '97

Course 24: OpenGL and Window System Integration

OpenGL Language Bindings



Contents



1. Introduction

The OpenGL API is defined in terms of C/C++ but bindings for several other languages exist.

Fortunately, the OpenGL function parameters are all simple types (boolean, integer, floating point, constants, arrays) so the API translates easily from C to other languages.

The OpenGL Architecture Review Board (ARB) controls the C, C++, Fortran, Pascal and Ada binding specifications at this time.



2. Bindings

C++
Same as the C bindings. The ARB voted not to use the C++ function overloading facility. Therefore, the C++ OpenGL interface is identical to that for C.
Fortran
Fortran bindings are shipped by several vendors including SGI. The Fortran API functions are prefixed with f. For example, glVertex3f() becomes fglVertex3f().

The OpenGL constants are not supposed to be prefixed with F (i.e. GL_POLYGON, not FGL_POLYGON) but SGI's IRIX 5.3 Fortran header file for OpenGL does use the F prefix. The GLUT toolkit includes an fgl.h header file with correctly named constants.

Finally, the maximum length of identifiers varies among Fortran compilers. Since OpenGL has several long (+32 character) identifiers they may be truncated in the header file.

Bill Mitchell of the NIST has written fortran 77 and fortran 90 bindings for OpenGL and Mesa. (http://math.nist.gov/f90gl/)

Ada
Silicon Graphics offers Ada bindings for OpenGL. You must have the SGI Ada compiler (GNAT) installed on your system. The GLUT library also has Ada bindings since version 3.4
Modula-3
OpenGL bindings for Modula-3 are available from Columbia University. (http://www.cs.columbia.edu:80/graphics/modula3/opengl/)
Pascal
No Pascal bindings for OpenGL are known to exist.
Tcl/Tk
Python
David Ascher at Brown University has information about Python and OpenGL. (http://maigret.cog.brown.edu:80/python/opengl/)
Java
The preliminary Java 3D specification is now available (http://java.sun.com/products/java-media/3D/). Java3D may be implemented on top of OpenGL but that is not a requirement. As of mid-July there is no release date for a Java3D implementation.

In the mean time, there are several possible solutions to using OpenGL with Java:

STk (Scheme/Tk)
Carnegie Mellon University has OpenGL bindings for StK, a Scheme interpreter with a Tk interface. Contact James Grandy (jcg@cs.cmu.edu) for more information.
Delphi
Delphi bindings for OpenGL 1.0 (written by Rick Hansen, 71043.2142@compuserve.com) and 1.1 (written by Mike Lischke, Lischke@imib.med.tu-dresden.de) are available from the Delphi Super Page (http://sunsite.icm.edu.pl/delphi/"). Search for opengl.


3. Notes

While OpenGL's API is easily adapted to many languages the same can't be said of most window system interfaces. For example, a Fortran-based OpenGL application may still need some C code to interface OpenGL with Xlib since there's no Fortran interface to Xlib.

In some cases, such as Tcl/Tk, a special interface layer written in C may encapsulate the details of the OpenGL window system interface. Another example is GLUT. GLUT hides the details of OpenGL window system integration, providing a simple, window system-independent interface with C, Fortran and Ada bindings.




Last edited on July 17, 1997 by Brian Paul.