Version 1 of tclogl

Updated 2005-07-27 20:38:26

Paul Obermeier 2005/07/27

Tclogl offers the 3D functionality of OpenGL at the Tcl scripting level. Tclogl is an improved and enhanced OpenGL binding based on the work done with Frustum by Roger E Critchlow.


http://www.poSoft.de/images/teapots.png

http://www.poSoft.de/images/texture_tclogl.png


Tclogl uses SWIG and it’s extended typemap features to generate a consistent mapping between OpenGL C functions and equivalent Tcl commands without changing the OpenGL header files. Currently the OpenGL core functions defined in gl.h and the OpenGL utility functions defined in glu.h can be wrapped into a Tcl package. It has been tested on Windows, Linux and IRIX.

It uses a slightly modified version of Togl to display the 3D contents.

For a detailed description of the implementation and usage of tclogl, see the paper held at the Fifth European Tcl/Tk Users Meeting.

The paper, sources (tclogl and modified Togl), demos (all OpenGL redbook C examples rewritten in Tcl), screenshots and binaries for Windows can be downloaded from my homepage at http://www.poSoft.de


A minimal "Hello, World" 3D application drawing a white rectangle looks like this:

 # hello.tcl

 package require tclogl
 package require Togl

 proc tclDisplayFunc { toglwin } {
     glClear GL_COLOR_BUFFER_BIT

     # draw white polygon (rectangle) with corners at
     # (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)  
     glColor3f 1.0 1.0 1.0
     glBegin GL_POLYGON
         glVertex3f 0.25 0.25 0.0
         glVertex3f 0.75 0.25 0.0
         glVertex3f 0.75 0.75 0.0
         glVertex3f 0.25 0.75 0.0
     glEnd
     glFlush
 }

 proc tclCreateFunc { toglwin } {
     # select clearing color
     glClearColor 0.0 0.0 0.0 0.0

     # initialize viewing values
     glMatrixMode GL_PROJECTION
     glLoadIdentity
     glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0
 }

 proc tclReshapeFunc { toglwin w h } {
     $toglwin postredisplay
 }

 frame .fr
 pack .fr -expand 1 -fill both
 togl .fr.toglwin -width 250 -height 250 -double false \
                  -createproc tclCreateFunc \
                  -displayproc tclDisplayFunc \
                  -reshapeproc tclReshapeFunc
 grid .fr.toglwin -row 0 -column 0 -sticky news

 bind . <Key-Escape> "exit"

[ Category Graphics | Category 3D Graphics ]