Skip to content

harveydevereux/FortranOpenGL

Repository files navigation

Basic example of using Opengl and fortran

Shows some text in red and you can quit the app!

Screenshot from 2022-12-02 13-13-53

The code uses Opengl 1.x.x APIs, using F03GL (see below readme) to expose OpenGL to Fortran

Tested on ubuntu 22.04.1 LTS with Mesa Intel® HD Graphics 4400 (HSW GT2) using

  • gfortran 11.3.0
  • make 4.3

Build by calling make

You may have to install opengl, glu, and glut dev packages etc

F03GL readme - Anthony Stone and Aleksandar Donev, below

F03GL -- modules for using the OpenGL graphics library from Fortran

Copyright 2009-2022 Anthony Stone and Aleksandar Donev

This file is part of f03gl.

f03gl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

f03gl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with f03gl (see file COPYING). If not, see http:https://www.gnu.org/licenses/.

To use this package you need a Fortran 2003 or later compiler.

Unpack the files: tar xzvf f03gl.tgz or unzip f03gl.zip The files will be extracted into a new f03gl directory. Change to this directory.

The f03gl_gl* files can be used without any changes in a graphical Fortran program, and have been used in Anthony Stone's Orient program for many years. The OpenGL routines can be called straightforwardly with the appropriate arguments, some of which will be the named constants defined in these files. For most purposes nothing else will be needed.

However the package also includes a number of programs that display some of the capabilities of the OpenGL routines, and they can be used as examples when building new programs. At the moment these all work with the gfortran and ifort compilers, but while nagfor compiles without error, the compiled programs fail immediately without providing a useful error message. At present this behaviour is unexplained.

To run these examples, check that the Makefile is set up to use the correct compiler and the appropriate libraries. Also set the GLUT variable for the version of GLUT that you intend to use. Then just run make. This should compile the OpenGL_gl, OpenGL_glu and OpenGL_glut object and module files, and then compile and run the test files, one after the other. You will need to quit from each test (by closing its window) before the next one will run. The first three tests are rather boring, but in the last three you can bring up a menu with a right mouse click and change some of the properties of the display. From the f90 code you can see how to do similar things in your own code. These examples are slightly-modified versions of the examples provided with Bill Mitchell's f90gl package http:https://math.nist.gov/f90gl/ and used with his permission. They should run on both 32-bit and 64-bit architectures. (As they were written when computers were much slower the motion in these examples is excessively fast on modern computers.)

The package also includes the perl code used to generate the Fortran files from the C header (*.h) files. The intention here is to provide for the regeneration of the Fortran files from updated header files, but we have not so far found that to be necessary.

Anthony Stone ajs1 at cam dot ac dot uk Aleksandar Donev aleks dot donev at gmail dot com

7 February 2022

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published