An OpenGL based function grapher for Linux
GLgraph is my first Perl program and is a ported Version of my old Worm(g).
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.
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.
I only tested it on my PC:
- libopengl-perl/perl-OpenGL >= 0.5
- Imagemagick (optional, for screenshots)
- 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) 220.127.116.11
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:
All use OpenGL. 3D Solid uses the accelerated TRIANGLE methode.
GLgraph has preview capabilities too.
- 2D (
-2d) : 3D Graph (very fast ;)
- 3D Wire (
-wire) : 3D Wireframe model
- 3D Solid (
-3d) : Default, solid 3D model (slowest)
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
The time can also be used as a parameter. But to get acceptable fps the
resolution has to be lowered.
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 (
See bellow to save the function as an animation.
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.
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
A screenshot can be taken using the
To create an info file with a function description, use the
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:
- Save every frame to the files
glgraph -save <options> -o movie.jpg
- 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
mencoder -vop scale movie\*.jpg -mf on:fps=<fps> -ovc divx4 -o movie.avi
glgraph [options] 'function1' 'function2' ...
4.2. Command line options
glgraph -h for a list of available options.
4.3. Control from keyboard
glgraph -h for a list of available keys.
Display the default builtin GLgraph functions
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
Q: I use perl-OpenGL 0.4 and get an error about
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.
Jonas Jermann (g0th) <email@example.com>
David Gunzinger (pfy) <firstname.lastname@example.org>
- Syntax introduction/help of OpenGl/glut/Perl
- Second color-mode
- eval optimations!
- Structure help
- Screenshot code
- Help with OpenGL
GLgraph is under GPL v2 license. Read the file
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