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 (brianp@elastic.avid.com) and Benjamin Bederson (bederson@cs.umd.edu). See the LICENSE file for details.
The Togl WWW page is available from:You should have Tcl and Tk installed on your computer, including the Tk source code files. Togl has been tested with Tcl 7.4/Tk 4.0, Tcl 7.5/Tk 4.1, Tcl 7.6/Tk 4.2 and Tcl/Tk 8.0 at this time.
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.5. You may download it from either:
The Makefile included with Togl is configured for SGI systems. It shouldn't
be hard to adapt it for others.
In practice, you'll just add togl.c to your application's Makefile.
There is no mailing list for Togl at this time but several people have
asked about it.
If you have the means and time to setup and administer such a mailing
list please contact Brian.
The Togl source code is intended to be included with your application.
You may elect to compile the Togl code into a library file but that's not
necessary.
Unix/X systems only need the
Windows 95/NT systems also need the other
Also, you'll have to copy the
Togl defines an API of C-callable functions and an API of Tcl-callable
functions. The functions are documented here. See the demo programs
for examples of how they are used.
These are the Togl commands one may call from a C program.
You should include the togl.h header before any others so that various
WindowsNT/95 stuff falls into place.
Each C callback must be of the form:
The C callback must be of the form:
These functions are only used for color index mode.
These functions are modelled after GLUT's overlay sub-API.
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.
If you choose to use these functions in your application your must first
define the TOGL_X11 preprocessor symbol before including the Togl header
file:
These are the Togl commands one may call from a Tcl program.
There are five demo programs:
To compile the demos, edit the Makefile to suit your system, then
type "make".
The stock Makefile is setup for Linux.
To run a demo just type "double" or "texture" or "index" or "overlay".
Togl on SGI systems supports full-screen stereo.
Quad-buffered stereo-in-a-window is not supported at this time.
To enable stereo support you must add -DSTEREO to the cc compiler flags.
Reportedly, SGI O2's need patches 1979 and 2447 in order to use stereo.
Also, the frame buffer must be set to the 32+32 pixel format and the
monitor set to 1024x768_96s mode.
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.
If you find a bug in Togl please report it to both Ben and Brian.
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.
Windows 95/NT problems should be sent to Robert K. Casto
casto@cis.ohio-state.edu,
author of the Windows 95/NT support for Togl.
Several people have contributed new features to Togl. Among them are:
Getting Togl
Togl may also be obtained manually with ftp:
Mailing list
Using Togl With Your Application
Unix/X11 usage
togl.c
, togl.h
and one of of the tkInt*.h
files.
Windows 95/NT usage
tk*.h
,
WinMain.c
, winMain.c
, and tkConsole.c
files distributed with Togl.
tkInt.8.0.h
file to
tkInt.h
.
C Togl Functions
#include "togl.h"
Setup and Initialization Functions
int Togl_Init( Tcl_Interp *interp )
void Togl_CreateFunc( Togl_Callback *proc )
void Togl_DisplayFunc( Togl_Callback *proc )
void Togl_ReshapeFunc( Togl_Callback *proc )
void Togl_DestroyFunc( Togl_Callback *proc )
void callback( struct Togl *togl )
{
...your code...
}
void Togl_TimerFunc( Togl_Callback *proc )
-time
option to the Togl Tcl command.
void my_timer_callback( struct Togl *togl )
{
...your code...
}
void Togl_ResetDefaultCallbacks( void )
void Togl_CreateCommand( char *cmd_name, Togl_CmdProc *cmd_proc )
int callback( struct Togl *togl, int argc, char *argv[] )
{
...your code...
return TCL_OK or TCL_ERROR;
}
Drawing-related Commands
void Togl_PostRedisplay( struct Togl *togl )
void Togl_SwapBuffers( struct Togl *togl )
Query Functions
char *Togl_Ident( struct Togl *togl )
int Togl_Width( struct Togl *togl )
int Togl_Height( struct Togl *togl )
Tcl_Interp *Togl_Interp( struct Togl *togl )
Color Index Mode Functions
unsigned long Togl_AllocColor( struct Togl *togl, float red, float green, float blue )
void Togl_FreeColor( struct Togl *togl, unsigned long index )
void Togl_SetColor( struct Togl *togl,
int index, float red, float green, float blue )
Font Functions
GLuint Togl_LoadBitmapFont( struct Togl *togl,
const char *fontname )
After Togl_LoadBitmapFont() has been called, returning fontbase,
you can render a string s with:
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( struct Togl *togl, GLuint fontbase )
Client Data Functions
void Togl_SetClientData( struct Togl *togl, ClientData clientData)
ClientData Togl_GetClientData( const struct Togl *togl )
void Togl_ClientData( ClientData clientData)
Overlay Functions
void Togl_UseLayer( struct Togl *togl, int layer )
void Togl_ShowOverlay( struct Togl *togl )
void Togl_HideOverlay( struct Togl *togl )
void Togl_PostOverlayRedisplay( struct Togl *togl )
void Togl_OverlayDisplayFunc( Togl_Callback *proc )
void RedrawOverlay( struct Togl *togl )
{
...your code...
}
int Togl_ExistsOverlay( struct Togl *togl )
int Togl_GetOverlayTransparentValue( const struct Togl *togl )
int Togl_IsMappedOverlay( const struct Togl *togl )
unsigned long Togl_AllocColorOverlay( const struct Togl *togl,
float red, float green, float blue )
void Togl_FreeColorOverlay( const struct Togl *togl, unsigned long index )
X11-only Functions
#define TOGL_X11
#include "Togl.h"
Display *Togl_Display( const struct Togl *togl )
Screen *Togl_Screen( const struct Togl *togl )
int Togl_ScreenNumber( const struct Togl *togl )
Colormap Togl_Colormap( const struct Togl *togl )
Postscript Output
int Togl_DumpToEpsFile( const struct Togl *togl,
const char *filename, int rgbFlag, void (*user_redraw)() )
Tcl Togl commands
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 ignored by togl.
This can be useful in your C callback functions
to determine which Togl widget is the caller.
-rgba true If true, use RGB(A) mode
If false, use Color Index mode
-redsize 1 Min bits per red component
-greensize 1 Min bits per green component
-bluesize 1 Min bits per blue component
-double false If false, request a single buffered window
If true, request double buffered window
-depth false If true, request a depth buffer
-depthsize 1 Min bits of depth buffer
-accum false If true, request an accumulation buffer
-accumredsize 1 Min bits per accum red component
-accumgreensize 1 Min bits per accum green component
-accumbluesize 1 Min bits per accum blue component
-accumalphasize 1 Min bits per accum alpha component
-alpha false If true and -rgba is true, request an alpha
channel
-alphasize 1 Min bits per alpha component
-stencil false If true, request a stencil buffer
-stencilsize 1 Min number of stencil bits
-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.
-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.
NOT YET IMPLEMENTED FOR WINDOWS 95/NT.
-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.
NOT YET IMPLEMENTED FOR WINDOWS 95/NT.
-indirect false If present, request an indirect rendering context.
A direct rendering context is normally requested.
NOT SIGNIFICANT FOR WINDOWS 95/NT.
pathName configure
pathName configure -option
-width
-width width Width W w
where W is the default width in pixels
and w is the current width in pixels
-height
-height height Height H h
where H is the default height in pixels
and h is the current height in pixels
-extensions
GL_EXT_polygon_offset GL_EXT_vertex_array
pathName configure -option value
-width
-height
pathName render
pathName swapbuffers
pathName makecurrent
Demo Programs
Stereo Rendering
Common Questions and Problems
Bad Match X errors on Sun systems
Reporting Bugs
Version History
Version 1.0 - March, 1996
Version 1.1 (never officially released)
Version 1.2 - November, 1996
Version 1.3 - May 2, 1997
Version 1.4 - September 17, 1997
Version 1.5 - September 18, 1998
-sharelist
and -sharecontext
config flags
-indirect
config flag
Future plans
Contributors
Many others have contributed bug fixes. Thanks for your contributions!
Last edited on December 15, 1998 by Brian Paul.