Togl allows one to create and manage a special Tk/OpenGL widget with Tcl and render into it with a C program. That is, a typical Togl program will have Tcl code for managing the user interface and a C program for computations and OpenGL rendering.
Togl is copyrighted by Brian Paul (brian_e_paul@yahoo.com) and Benjamin Bederson (bederson@cs.umd.edu). See the LICENSE file for details.
The
Togl project and
home page are
hosted by SourceForge.
You should have Tcl and Tk installed on your computer. Togl works with Tcl/Tk version 8.0 and up. The Mac OS X version requires version 8.4.
You must also have OpenGL or Mesa (a free alternative to OpenGL) installed on your computer.
One should be familiar with Tcl, Tk, OpenGL, and C programming to use Togl
effectively.
The current version of Togl is 1.7.
Togl can be downloaded from
SourceForge.
See the
Togl project at SourceForge for mailing list information.
There are basically two ways of using Togl with your application:
README.stubs
for more info.
Unix/X systems only need the togl.c
, togl.h
and the public Tcl/Tk include files.
Windows platforms need tkWinInt.h
and other internal Tk header files. So you need a Tcl/Tk
source distribution in addition to the Togl distribution
(or copy over the various include files).
Here's the minimal way to build Togl with Tcl/Tk using the gcc that is distributed as part of the cygwin tools (Microsoft's compilers work too):
VER=8.4.12
SRCDIR=`pwd`
cd $SRCDIR/tcl$VER/win
env 'CC=gcc -mno-cygwin' ./configure --enable-threads
make libtclstub84.a
cd $SRCDIR/tk$VER/win
env 'CC=gcc -mno-cygwin' ./configure --enable-threads
make libtkstub84.a
cd $SRCDIR/Togl
env 'CC=gcc -mno-cygwin' ./configure --with-tcl=../tcl$VER/win --with-tk=../tk$VER/win
make
The resulting Togl17.dll
and pkgIndex.tcl
should be installed into your Tcl distribution just like any other package.
These special instructions are for building the Aqua version of Togl.
Mac OS X needs tkMacOSXInt.h
and other internal Tk header files. Unfortunately, the Tcl and Tk
frameworks that Apple distributes are missing the internal headers.
So you need a Tcl/Tk source distribution in addition to the Togl
distribution (or copy over the various include files).
You would probably want a newer version of Tcl and Tk anyway
because each minor revision of 8.4 has many Aqua bug fixes.
Here's one way to build Tcl, Tk, and Togl on Mac OS X (assuming they are all in the same directory) to install in your home directory:
VER=8.4.12
mkdir -p ~/bin
make -C tcl$VER/macosx install PREFIX="${HOME}" INSTALL_PATH="${HOME}/Library/Frameworks"
make -C tk$VER/macosx install PREFIX="${HOME}" INSTALL_PATH="${HOME}/Library/Frameworks"
(cd Togl; ./configure --prefix="${HOME}")
make -C Togl install
These are the Togl functions one may call from a C program.
#include "togl.h"
For portability, you should include the togl.h header before any other OpenGL header so that various Windows 95/NT/2000/XP stuff falls into place.
int Togl_Init(Tcl_Interp *interp)
package require
command.
void Togl_CreateFunc(Togl_Callback *proc)
void Togl_DisplayFunc(Togl_Callback *proc)
void Togl_ReshapeFunc(Togl_Callback *proc)
void Togl_DestroyFunc(Togl_Callback *proc)
Each C callback must be of the form:
void callback(Togl *togl) { ...your code... }
void Togl_TimerFunc(Togl_Callback *proc)
-time
option to the Togl Tcl command.
The C callback must be of the form:
void my_timer_callback(Togl *togl) { ...your code... }
void Togl_ResetDefaultCallbacks(void)
void Togl_CreateCommand(char *cmd_name, Togl_CmdProc *cmd_proc)
int callback(Togl *togl, int argc, char *argv[]) { ...your code... return TCL_OK or TCL_ERROR; }
void Togl_PostRedisplay(Togl *togl)
void Togl_SwapBuffers(const Togl *togl)
void Togl_MakeCurrent(const Togl *togl)
char *Togl_Ident(const Togl *togl)
int Togl_Width(const Togl *togl)
int Togl_Height(const Togl *togl)
Tcl_Interp *Togl_Interp(const Togl *togl)
Tk_Window Togl_TkWin(const Togl *togl)
These functions are only used for color index mode.
unsigned long Togl_AllocColor(Togl *togl, float red, float green, float blue)
-privatecmap
option is false.
void Togl_FreeColor(Togl *togl, unsigned long index)
-privatecmap
option
is false.
void Togl_SetColor(Togl *togl,
int index, float red, float green, float blue)
-privatecmap
option is true.
GLuint Togl_LoadBitmapFont(Togl *togl,
const char *fontname)
- TOGL_BITMAP_8_BY_13
- TOGL_BITMAP_9_BY_15
- TOGL_BITMAP_TIMES_ROMAN_10
- TOGL_BITMAP_TIMES_ROMAN_24
- TOGL_BITMAP_HELVETICA_10
- TOGL_BITMAP_HELVETICA_12
- TOGL_BITMAP_HELVETICA_18
glListBase(fontbase);
glCallLists(strlen(s), GL_BYTE, s);
To maximize the portability of your application it is best to use one
of the predefined TOGL_BITMAP_* fonts.
void Togl_UnloadBitmapFont(Togl *togl, GLuint fontbase)
void Togl_SetClientData(Togl *togl, ClientData clientData)
ClientData Togl_GetClientData(const Togl *togl)
void Togl_ClientData(ClientData clientData)
These functions are modelled after GLUT's overlay sub-API.
void Togl_UseLayer(Togl *togl, int layer)
void Togl_ShowOverlay(Togl *togl)
void Togl_HideOverlay(Togl *togl)
void Togl_PostOverlayRedisplay(Togl *togl)
void Togl_OverlayDisplayFunc(Togl_Callback *proc)
void RedrawOverlay(Togl *togl) { ...your code... }
int Togl_ExistsOverlay(Togl *togl)
int Togl_GetOverlayTransparentValue(const Togl *togl)
int Togl_IsMappedOverlay(const Togl *togl)
unsigned long Togl_AllocColorOverlay(const Togl *togl,
float red, float green, float blue)
void Togl_FreeColorOverlay(const Togl *togl, unsigned long index)
These functions are only implemented on systems using the X Window System.
We recommend that you avoid using these functions in your application since
they are not portable to other operating/window systems
(use Togl_TkWin()
and normal Tk functions instead).
Display *Togl_Display(const Togl *togl)
Screen *Togl_Screen(const Togl *togl)
int Togl_ScreenNumber(const Togl *togl)
Colormap Togl_Colormap(const Togl *togl)
int Togl_DumpToEpsFile(const Togl *togl,
const char *filename, int rgbFlag, void (*user_redraw)())
These are the Togl commands one may call from a Tcl program.
togl pathName [options]
Option | Default | Comments |
---|---|---|
-width | 400 | Width of widget in pixels. |
-height | 400 | Height of widget in pixels. |
-ident | "" |
A user identification string. This is used match widgets
for the -sharecontext
and the -sharelist options (see below).
This is also useful in your callback functions
to determine which Togl widget is the caller.
|
-rgba | true | If true, use RGB(A) mode, otherwise use Color Index mode. |
-redsize | 1 | Minimum number of bits in red component. |
-greensize | 1 | Minimum number of bits in green component. |
-bluesize | 1 | Minimum number of bits in blue component. |
-alpha | 1 |
If true and -rgba is true, request an alpha channel. |
-alphasize | 1 | Minimum number of bits in alpha component. |
-double | false | If true, request a double-buffered window, otherwise request a single-buffered window. |
-depth | false | If true, request a depth buffer. |
-depthsize | 1 | Minimum number of bits in depth buffer. |
-accum | false | If true, request an accumulation buffer. |
-accumredsize | 1 | Minimum number of bits in accumulation buffer red component. |
-accumgreensize | 1 | Minimum number of bits in accumulation buffer green component. |
-accumbluesize | 1 | Minimum number of bits in accumulation buffer blue component. |
-accumalphasize | 1 | Minimum number of bits in accumulation buffer alpha component. |
-stencil | false | If true, request a stencil buffer. |
-stencilsize | 1 | Minimum number of bits in stencil component. |
-auxbuffers | 0 | Desired number of auxiliary buffers. |
-privatecmap | false | Only applicable in color index mode. If false, use a shared read-only colormap. If true, use a private read/write colormap. |
-overlay | false | If true, request overlay planes. |
-stereo | false | If true, request a stereo-capable window. |
-oldstereo | false | On SGI workstations only: if true, request divided-screen stereo. |
-time | 1 | Specifies the interval, in milliseconds, for calling the C timer callback function which was registered with Togl_TimerFunc. |
-sharelist | "" | Name of an existing Togl widget with which to share display lists. |
-sharecontext | "" | Name of an existing Togl widget with which to share the OpenGL context. NOTE: most other attributes such as double buffering, RGBA vs CI, ancillary buffer specs, etc are then ignored. |
-indirect | false | If present, request an indirect rendering context. A direct rendering context is normally requested. Only significant on Unix/X11. |
-cursor | "" | Set the cursor in the widget window. |
-pixelformat | 0 | Set the pixel format to the (platform-dependent) given value. |
pathName configure
pathName configure -option
-width
-width width Width W w
-height
-height height Height H h
-extensions
GL_EXT_polygon_offset GL_EXT_vertex_array
pathName configure -option value
togl
command above.
pathName render
pathName swapbuffers
pathName makecurrent
There are six demo programs:
double.tcl — compares single vs double buffering with two Togl widgets texture.tcl — lets you play with texture mapping options index.tcl — demo of using color index mode overlay.tcl — example of using overlay planes (requires overlay hardware) stereo.tcl — stereo example gears.tcl — spinning gears demo
To compile the demos, edit the Makefile to suit your system, then
type make demos
.
The demos are compiled into shared libraries,
that can are loaded into the Tcl interpreter as Tcl/Tk-extensions.
Demos are started by running the corrsponding Tcl script.
To run a demo just type ./double.tcl
or ./texture.tcl
etc.
Quad-buffered stereo-in-a-window is supported. Quad-buffer stereo
is only available on workstation-class graphics cards
(3Dlabs Wildcat series,
ATI FireGL series,
NVidia Quadro series,
and SGI workstations).
Legacy support for divided-screen stereo on SGI workstations is
available via the -oldstereo
option.
Developers for SGI workstations might also like the
autostereo package to automatically switch the display
in and out of stereo (other systems already do it automatically).
Full-screen stereo that gaming graphics cards support (ATI Radeon,
NVidia GeForce) is not supported.
If you have something to add to this section please let us know.
There's a bug in Sun's XmuLookupStandardColormap X library function.
If you compile togl.c with the SOLARIS_BUG symbol defined (-DSOLARIS_BUG)
this function call will be omitted.
There is a bug database on the Togl Project Page. You may also discuss bugs on the mailing list.
When reporting bugs please provide as much information as possible.
Also, it's very helpful to us if you can provide an example program
which demonstrates the problem.
-sharelist
and -sharecontext
config flags
-indirect
config flag
-pixelformat
config flag
Several people have contributed new features to Togl. Among them are: