# GLgraph

### An OpenGL based function grapher for Linux

###

### 1. Introduction

1.1. About
GLgraph is my first Perl program and is a ported Version of my old Worm(g).

1.2. Description
GLgraph visualize mathematical functions. It can handle 3 unknowns (x,z,t) and can produce a 4D function with 3 space and 1 time dimension.

1.3. History
It began with my first program Worm(g)... Because I didn't find a mathematical function visualiser which fit my needs, I started to write my own in pascall (Worm(g)). GLgraph is a perl/OpenGL portation of my first Worm(g) program. It's result was a complete new structured program.

### 2. Installation

2.1. Requirements
GLgraph needs:

- libopengl-perl/perl-OpenGL >= 0.5
- libmath-basecalc-perl
- libtime-hires-perl
- Imagemagick (optional, for screenshots)

I only tested it on my PC:

- Pentium III 600
- Matrox G400 32 MB DH
- Linux 2.4.18
- Debian (sid)
- libopengl-perl 0.54
  - Perl 5.6.1
  - glutg3 3.7
  - XFree86 4.1.0 (xlibmesa3)
- libmath-basecalc-perl 1.009
- libtime-hires-perl 1.20
- imagemagick (optional, for screenshots) 5.4.7.1

### 3. Features

3.1. Functions
You can add your own functions to the default ones. All math functions of Perl's math module can be used (even trigonometrical). PI is built in too and the function interval can contain complex solutions.

3.2. Output modes
There are 3 Modes:

- 2D (`-2d`) : 3D Graph (very fast ;)
- 3D Wire (`-wire`) : 3D Wireframe model
- 3D Solid (`-3d`) : Default, solid 3D model (slowest)

All use OpenGL. 3D Solid uses the accelerated TRIANGLE methode. GLgraph has preview capabilities too.

3.3. Axis
There are 4 Modes:

- no axis (`-noaxis`) : Default
- normal (`-axis 1`) : Changes automaticaly from 2D to 3D
- 3D square (`-axis 2`) : Draws a base square
- 3D cube (`-axis 3`) : Draws a base cube

3.4. Time
The time can also be used as a parameter. But to get acceptable fps the resolution has to be lowered.

3.5 Animation
After one time periode, the saved display lists are being used to display the frames. This leads to a tremendous speedup (animation). The flimmering is caused by the clear call which can be deactivated with the `-noclear` option (looks ugly). Large time and space resolutions can lead to crashs/freezes (memory), don't use this methode in this case (`-noanim`).
See bellow to save the function as an animation.

3.6. Color
There are 3 modes:

- no colors (`-nocolors`) : Fastest mode ;)
- color mode 1 (`-colors 1`) : Default, my own iterative color mode
- color mode 2 (`-colors 2`) : Absolute color scale (slow)

3.7 Preview mode
The preview mode can be toggled with the `p` key. It uses a resolution of 20 (x and z) and can be used to avoid intense calculation while trivial changes.

3.8 Screenshots
Glgraph uses Imagemagick's import over a system call to take screenshots. All Imagemagick output formats are therefore supported. A non-default output name (default is image.jpg) can be specified with the `-o` option. A screenshot can be taken using the `m` key. To create an info file with a function description, use the `-i` option. If no extension in the output name is present, just the info file will be created.
To create a movie of the whole function, do as follows:

1. Save every frame to the files `movie_00xx.jpg`:
   `glgraph -save <options> -o movie.jpg`
2. Create a MJPEG or directly a AVI/MPG file, using the created images (with MEncoder for example):
   `mencoder -vop scale movie\*.jpg -mf on:fps=<fps> -ovc lavc -lavcopts vcodec=mjpeg -o movie.avi
   or
   `mencoder -vop scale movie\*.jpg -mf on:fps=<fps> -ovc divx4 -o movie.avi
   ``

### 4. Usage

4.1. Synopsis
`glgraph [options] 'function1' 'function2' ...`

4.2. Command line options
See `glgraph -h` for a list of available options.

4.3. Control from keyboard
See `glgraph -h` for a list of available keys.

4.4. Examples
Display the default builtin GLgraph functions
`glgraph`
The same without colors and a wireframe model
`glgraph -wire -nocolors -xzres 20`
A 2D Graph (color mode 2) of a normal parabola
`glgraph -2d -colors 2 -notime -xres 600 -nocolors 'x*x'`
The same with no colors and axis
`glgraph -axis 1 -ax_size 1 -2d -notime -xres 600 -nocolors 'x*x'`
High quality picture of the default function
`glgraph -xzres 150 -tmin 1 -notime -cfact 1 -cconst 0.1`
Create info file of the default function
`glgraph -i -o function1`

### 5. FAQs

Q: I use perl-OpenGL 0.4 and get an error about `OpenGL::EXPORT_TAGS`.
A: Perl-OpenGL 0.4 seems to be incompatible with GLgraph (see libopengl-perl's README file for more details). Upgrade to perl-OpenGL >= 0.5.

### 6. Authors

Jonas Jermann (g0th) <jjermann@gmx.net>

- main developer

David Gunzinger (pfy) <david@zhadum.ch>

- Syntax introduction/help of OpenGl/glut/Perl
- Second color-mode
- eval optimations!
- Structure help

Addi (?)

- Screenshot code
- Help with OpenGL

### 7. Law

7.1. License
GLgraph is under GPL v2 license. Read the file COPYING for more details.

7.2. Standard Disclaimer
Use only at your own risk! There may be errors and inaccuracies that could be damaging to your system or your eye. Proceed with caution, and although this is highly unlikely, we don't take any responsibility for that!