Documentation

Structure Overview

TkOGL consists of three packages, TkOGL, OpenGL, and OpenGLU. The TkOGL package contains the window manager who's responsible for creating and destroying windows, refreshing, initializing viewports, and handling events. It manages the canvas where all OpenGL graphics are drawn. In creating OpenGL and OpenGLU packages, SWIG is used to generate wrapper code from the OpenGL header files. An HTML or Word document is generated by SWIG that summarizes the functions and its parameters. The generated wrapper code is compiled to create dynamic link libraries (Windows), or shared libraries (Linux). The libraries are seen as Tcl packages through the Tcl interpreter.

After these packages are installed into the Tcl library, the user can manually load each individual package into the Tcl Interpreter. With all the OpenGL commands available, along with the new TkOGL window manager commands, users can now quickly script up interactive 3D graphical applications.

TkOGL Development Process

Getting Started

TkOGL Users

  1. For Tcl/Tk and OpenGL beginners, start of by reading through a Tcl/Tk tutorial and a OpenGL Tutorial in the Related Links page.
  2. If you haven't done so already, download and install the latest supported Tcl/Tk version (For TkOGL 3.2, download Tcl/Tk 8.4).
  3. Download and install the latest TkOGL packages.
  4. Go through a simple TkOGL Tutorial

TkOGL Developers

To re-compile TkOGL in Windows

  1. Download and install the latest supported versions of Tcl/Tk and SWIG and also download the source code for TkOGL.
  2. For Windows developers, the most recommended compiler to use is Microsoft Visual C++ 6.0.
  3. Unzip the TkOGL source code and run the makeWIN.cmd batch file. This will copy all the necessary windows files to the corresponding windows directories (ie: tkogl3.2/src/tkogl/windows).
  4. Modify the Makefiles in the windows directory in tkogl, swig.gl, and swig.glu to indicate where you've installed the Tcl/Tk and SWIG files.
  5. When everything compiles successfully, go to Tkogl3.2/windowsInstall and run the wizard.cmd batch file. This script collects everything that you've just compiled into an installation package.
  6. Run the install.exe file to install the TkOGL packages.

To re-compile TkOGL in Linux

  1. Download and install the latest supported versions of Tcl/Tk and SWIG and also download the source code for TkOGL.
  2. For Linux developers, untar the TkOGL tarball.
  3. Modify the makefiles in tkogl, swig.gl and swig.glu to indicate where Tcl/Tk and SWIG are installed.
  4. Perform the standard ./configure, make, and makeInstall commands. The packages should now be installed.

Note: These are simplified installation procedures. More detailed installation notes are available in the downloaded files

Tutorial

This is a simple TkOGL example that illustrates the process and the syntax involved in creating a simple image on the canvas. It performs the following operations.

  1. Loads the TkOGL, OpenGL, and OpenGLU packages in Tcl.
  2. Creates a procedure to draw a pink triangle in the widget.
  3. Creates the drawing widget and binds the procedure created in step 2 to the window.
  4. Draws the triangle.

Code:

Run wish from Windows or Linux and type the following at the command prompt. Most developers would write this in a script file with file extension ".tcl". This file is platform independent and can be ran on both Windows and Linux.

package require Tkogl

package require OpenGL

package require OpenGLU

 

proc draw {} {        

        glClear GL_COLOR_BUFFER_BIT        

        glColor3f 1 0 0.5        

        glBegin GL_TRIANGLES                

                glVertex3f 0.1 0.7 0.1                

                glVertex3f -0.7 -0.7 0.1                

                glVertex3f 0.7 -0.7 0.1        

        glEnd

}

 

pack [OGLwin .gl -refresh draw]

 

Output:

 

White Papers

Title Authors
TkOGL - Integrating Tcl and Open GL Joel Joyner
A Tk OpenGL Widget Claudio Esperanca
EasyOgl: Fast Prototyping Environment for 3D Multimedia Integration using Tcl/Tk and OpenGL Sidney Fels and Matt Yedlin

Reference Material

TkOGL Programming Reference Authors
TkOGL GL Commands GL Commands available in TkOGL. Reference document generated by SWIG
TkOGL GLU Commands GLU Commands available in TkOGL. Reference document generated by SWIG
Books Authors
"OpenGL SuperBible Second Edition" Richard S Wright Jr. and Michael Sweet
"Interactive Computer Graphics: A Top-Down Approach with OpenGL" Edward Angel
"Graphical Applications with Tcl & TK" Eric Foster-Johnson
"Tcl and the Tk Toolkit" John K. Ousterhout
Online Description
http://www.cevis.uni-bremen.de/~uwe/opengl/opengl.html OpenGL reference page
http://www.tcl.tk/man/tcl8.4/ Tcl/Tk reference page

 


Home | News | Download | Documentation | Multimedia | Related Links | Contact Info