Free OpenGL Fortran 77 and C++ environment for Windows
The following components were used as a start point for
- Borland C++ Builder compiler (free command line tools)
source for F77 binding headers
- fortran to c translator recompiled with BCC
- Fortran binding
for GLUT, GL and GLUT
- No Fortran GL examples were available so I wrote some to verify success
of the idea
For teaching graphics with the free tools which can be
given to students for home use without violating the license. Primarily
this kit is intended for Fortran 77 users as there is no simple and
free solution for use on MS Windows. With simple solution I mean the
kit size, ease of installation, ease of use and portability of the executables.
This prerequisites ruled out free tools on Windows such as Cygnus, djgpp,
mingw as they require a lot of unix tools and runtime dlls (portability).
Our executables run with the prerequisite of glut32.dll installed or
placed with executable in the same directory. The use of GLUT is mandatory
for OpenGL window programming abstraction in F77 on Windows.
C++ Builder Compiler
command line tools from
- Download our kit of headers, libraries, binaries,
batch files and F77 examples
- Install BCC command line tools in directory c:\bcc55
- Create c:\bcc55\bin\ilink32.cfg with the link
- Create c:\bcc55\bin\bcc32.cfg and add include
- Extract zip contents into c:\. This will overlay c:\bcc55
- Copy/move glut32.dll from lib into system directory (eg.
c:\windows\system32 or c:\winnt\system32)
- Update Windows search to point to c:\bcc55\bin. For 98/ME update
autoexec.bat, NT/2000 System/Envitonment/Path
Fortran compiling comes with f77 batch script that eases two
step procedure of converting fortran source into ANSI C and then proceeding
with C compiling and linking into executable. Compilation should be initiated
with Fortran file without extension i.e..:
Of course, usage of the f77.bat is limited to simple projects/users.
Use it as template for Makefile. To support modular programming several
files can be compiled/linked with one command. The first file should contain
program statement. Precompiled modules should be specified as
files. Example command line:
f77 mainprog module1 module2 module3.c module4.obj module5.obj
f90gl subdirectory is provided for rebuilding fopengl32.lib
from source. No makefile is provided but you can compile fortran
bindery with simple C compile command eg. bcc32 -c cwrap.c
You can build the library with tlib fopengl32.lib +- ..\f90gl\gl\cwrap.obj
in the lib subdir. Maybe someone will properly patch the
files and submitted it to f90gl project
or to me. For rebuilding glut with proper fortran callbacks please
use sources from f90gl. You will need MS Visual C++ for that. As usual
user command implib glut32.lib glut32.dll for building bcc
library extract from .dll.
There are differences in internal handling of the string type between
different fortran implementations. f2c is no exception. So if you get
exception violation message from a function this may be the case. Not
many glut routines accept strings. Please send bug reports to
an I will see what I can do.
For F77 you can use
fortran specification, f2c
and binding for
For convenience I collected and converted into PDF
fortran binding specification for off-line reading. For GLUT we
use f prefix naming convention as suggested by ARB.
You should start with this hello sample with minimal code needed for
GLUT windowing application. It consist of two compilation units: Subroutine
display and main program named line. Every program
unit needs include files at the beginning of the code. Usually this is
GL/fglut.h for main and additionally GL/fgl.h and
GL/fglu.h for callback routines. Default callback routines are assumed
except for display. Window area is (-1,-1) (1,1) and anamorphical resize.
Adds keyboard event demo and glut predefined object. Note that every
callback function needs to be specified with external otherwise
this name will be treated as variable. I strongly suggest to use implicit
none for every program unit.
Mouse events are captured and then viewport coordinates are back projected
into world coordinates which are then drawn as polyline. This is 2D demo
as the z is assumed.
Shaded cube with their sides marked with stoked font text.
Lighting demo and quaternion rotation example with external C source routine
and builtin Fortran binding.
Compile this demo with: f77 tblight trackball.c
MadMax highway animation of 5 vehicles.
University of Ljubljana
Created: March 2002