Tcl/Tk Cookbook - Tcl/Tk and C


Purpose

This Chapter shows how to extend Tcl/Tk commands to include your own. The example used here is based on PHIGS (Programmer's Hierarchical Interactive Graphics System) programming library for 3D graphics. The rationale behind this example is to include 3D drawing capabilities to Tk canvas with Tk handling all the input while PHIGS handles the 3D output.

You will need

The example is compiled and run using the X11 Release 5 sample implementation of PHIGS which is freely available public domain software and conforms to ISO specification. If you want to run this application you will require access to X11 Release 5 PHIGS (or SunPHIGS) and your workstation kernel configured to run PHIGS.

If the reader already knows PHIGS, it is easy to understand the self-contained PHIGS procedures but the reader is not required to know PHIGS to understand how to register user commands with Tcl interpreter. You can either use the c routines as a unit or better still you can follow the relevant parts of Tcl/Tk and apply the methodology to a software package of your choice.

If you want to learn/use PHIGS, refer to Tom Gaskin's PHIGS Programming Manual which has examples showing the use of PHIGS with X Window System based toolkits.

Tcl/Tk scripts similar to ones described in earlier chapters are not explained again. If you are new to Tcl/Tk programming, you should at least read through previous chapters.

Dish to Serve Up

Create a simple Tk based graphical user interface with canvas widget. Interface a PHIGS workstation to the canvas to allow PHIGS to draw and update a simple 3D object

Recipe