OCaml for Scientists

Chapter 6: Visualisation

This web page contains programs derived from chapter 6 of our book OCaml for Scientists.

In order to compile the programs on this page, you will need to have the OCaml compilers and run-time installed and the lablGL bindings to OpenGL and glut, as well as the libraries which they depend upon.

In order to run the downloadable executables on this page, you will need an OpenGL implementation, such as Mesa or the nVidia drivers (if you have an nVidia graphics card). In most cases, you will already have OpenGL installed.

Minimal OpenGL program

Compile with:

                        ocamlc -I +lablGL lablgl.cma lablglut.cma base.ml -o base
                      

Download: Source code (6 lines of code), Linux executable, Mac OS X executable.

Simple 2D animation

Compile with:

                        ocamlc -I +lablGL lablgl.cma lablglut.cma unix.cma simple.ml -o simple
                      

Download: Source code (26 lines of code), Linux executable, Mac OS X executable.

3D animation

Compile with:

                        ocamlc -I +lablGL lablgl.cma lablglut.cma unix.cma annuli.ml -o annuli
                      

Download: Source code (51 lines of code), Linux executable, Mac OS X executable.