First, double check that you have all of the prerequisites and that you have compiled and installed Togl.
Then, Togl acts like any other extension package —
to load it, you use the Tcl
After that, you can create a Togl widget just like any other Tk widget.
package require Togl 2.0
There are six working examples:
double.tcl — compares single vs double buffering with two Togl widgets texture.tcl — lets you play with texture mapping options index.tcl — example of using color index mode overlay.tcl — example of using overlay planes (requires overlay hardware) stereo.tcl — stereo example gears.tcl — spinning gears example
Each example consists of two files: a Tcl script for the user interface,
and a Tcl C package that does the OpenGL drawing.
To compile the examples, type
in the Togl source directory.
The C packages are compiled into shared libraries
that are loaded into the Tcl interpreter as Tcl/Tk-extensions.
The examples are started by running the corrsponding Tcl script:
or run under one of the Tcl interpreters, i.e.,
Other examples that use Tcl for OpenGL drawing can be found in the Tcl3D demos.
All of the examples have similar structure. First they create the user interface with one or more Togl widgets. Each Togl widget is configured with the desired pixel format and several callback commands (not all are needed):
||Called when Togl widget is mapped — when it is safe to initialize the OpenGL context.|
||Called when the Togl widget is resized — when the OpenGL context's viewport needs to be changed.|
Called when the contents of the Togl widget needs to be redrawn.
Redraws are normally delayed to be when the Tcl event loop is idle
(see the togl widget's
||Called when the Togl widget is destroyed. While OpenGL frees display lists and other resources, sometimes there's some associated state that is no longer needed.|
Called every n milliseconds
as given by the
||Called when the overlay planes needs to be redrawn. The overlay planes are created and reshaped at the same time as the main OpenGL context.|