Purpose: to provide a collection point of information about the use of Tcl/Tk and the OpenGL 3D graphics libraries.
100. While not directly supporting Tcl, the WWW page at http://WWW.thp.Uni-Duisburg.DE/Ygl/ReadMe.html describes an X11 version of a simulation of SGI's GL under X11. You might try this with the Tcl/Tk OpenGL interfaces.
Zinc is an impressive achievement that will interest OpenGL students. Only 2D.
Tk3D has (among other things) an OpenGL widget. Unfortunately, the open-source version only supports Unix/linux. (That's easy to fix, though, for someone who knows openGL on Windows. Any takers?)
Tcl3D enables the 3D functionality of OpenGL and other 3D-related libraries (Cg, SDL, FTGL, GL2PS, ODE, OpenSceneGraph) at the Tcl scripting level. It comes with lots of demo programs. More info and images can be found at http://www.tcl3d.org
The Tcl3D website has a reference page [1 ] of all supported OpenGL core and extension functions. It also shows, which functions have been deprecated with OpenGL 3.X.
The function and extension names support direct links to the official references on http://www.opengl.org .
AM 2008-09-09: This is a short summary of my limited wisdom regarding OpenGL:
First of all, OpenGL defines a platform-independent API for drawing objects in two or three dimensions. However, it does not define a platform-independent way to specify the window in which to draw and it specfications only include very basic objects (no circles for instance). For this reason a number of auxiliary libraries exist:
Needless to say that the GLX and AUX libraries have nothing in common, except their goal. This means that a program that uses OpenGL will have to cope with all the relevant platforms itself - though only as far as window interaction is concerned.
A further complication, especially when dealing with older X Window dispalys, is that OpenGL requires a special extension to work with OpenGL: GLX (normally a command "glXinfo" exists to inform you about the status of your X display). On MS Windows platforms, such an extension is not necessary - most computers running MS Windows have support for OpenGL, as this is a very popular platform for implementing games.
There is an alternative: the MESA library. It has the same API as the OpenGL libraries that rely on the hardware and software support, but it does not use anything special. As a consequence it is (much? noticeably?) slower.
(I have recently tried to use a very simple OpenGL program - a minimal example from the man pages - on different machines, but failed in most cases, except on an SGI workstation. The reason is unclear to me, but it does make me a bit scared - alas! All these problems were caused in one of the calls to X Window routines: some gave a coredump, some produced X errors)
Perhaps a word or two on the programming model:
The 2D and 3D graphics is mostly handled by specifying what you want. For instance:
glColor3d( 1.0, 0.0, 0.5 ) ; /* Make the next objects purple (RGB) */ glBegin( GL_POLYGON ) ; /* Start a polygon definition */ glVertex3f( x, y, z ) ; /* Define the first vertex */ glVertex3f( x, y, z+1 ) ; /* Define the second vertex */ glVertex3f( x, y+1, z+1 ) ; /* Define the third vertex */ glEnd() ; /* Complete the definition and draw it */
This type of code is found in the drawing routine that is called when the window containing the OpenGL picture needs refreshing. All kinds of shortcuts exist (making a display list for instance or use one of the utilities to make a more complex object), but this is the basis.
OpenGL relies heavily on matrix manipulation to move, rotate and scale the objects to be drawn:
glRotatef( 90.0, 1.0, 0.0, 0.0 ) ; /* Rotate the next objects over 90 degrees around the x-axis */ glTranslatef( 0.0, 1.0, 0.0 ) ; /* Translate the next objects over a distance 1 in the y-direction */
The combination of such transformations is stored as a single operation on all the subsequent objects (by using so-called homogeneous coordinates, the translation is turned into a linear transformation too, a fourth coordinate is introduced which has the value 1 for all objects).
So an important part of OpenGL programming is the manipulation of these linear transformations.
The largest drawback of OpenGL, as far as the graphics is concerned, is that you need to have a fair understanding of low-level stuff to create a decent looking picture. But it certainly works!
Note: Something that was rather unclear in the Red Book (the standard book for starting OpenGL programmers) is the role of normal vectors to a surface. These are very important:
GWM 2004-09: NB the transforms are not essential to OpenGL - you can program a scene with the coordinates alone. Matrices make moving the objects relative to each other (anyone want a car race where the cars cannot move?) easier. Matrices also provide the perspective distortion applied when the scene is drawn, and the effective 'eye' or camera position.
Also normals (as complained about above) are transformed by any transform matrix resulting in non-unit normals if a scaling is applied. There is a setting to ensure that normals are re-set to unity, but this adds some processing overhead. Only use this if scaling is part of your transformation.
do while (Tcl_DoOneEvent(TCL_DONT_WAIT )); // doOneEvent returns 0 if no events were handled.
OSG is a real time simulation program, it follows the common block diagram: Start - read files, initialise view, events etc.
Loop until end:
The handle tcl/tk events is placed in the Loop, usually I place this after draw has started as there are likely to be unused CPU cycles while the graphics is rendering. (OSG supplies nice things like Stereo, frustum culling, lazy state sorting, access to GLSL etc and is fast method of doing OpenGL. It is a little less suited to developing a graphical editor as objects are display listed for speed, making editing a single vertex position slower.)
I have also used TkOGL though this was jerky while a window was resized.
jcw 2004-02-12: I've built a stubs-enabled version of Tkogl 1.1 for Windows, it's available at [3 ]. A small trick was needed to work around the fact that TkWinChildProc() is not in the stubs table. See also these posts on comp.lang.tcl [2 ].
TV: I combined a C program with openGL/Mesa graphics, in this case under windows, but the principles would work under other OS-es: Maze in openGL om windows navigation controlled by Tcl/Tk
By using a socket (or pipe) connection, the interactions with the tcl script can be seperately programmed, and possibly run on a seperate machine, leaving the primary graphics engine free.
What: GENERIC 3D Kernel Where: ftp://metallica.prakinf.tu-ilmenau.de/pub/PROJECTS/GENERIC/g1.5.unix.tar.gz ftp://metallica.prakinf.tu-ilmenau.de/pub/PROJECTS/GENERIC/g1.5.dos.tar.gz Description: A generic 3D graphics kernel which can be used to implement one's own system by derivation from the generic. Provides device drivers for a lot of graphics system, including Tk 3.6/4.0. Includes an OpenGL Tk widget. See some of the following for examples of use of GENERIC: http://www.inf.tu-dresden.de/%7Ecn1/gx.html http://metallica.prakinf.tu-ilmenau.de/egr.htm http://metallica.prakinf.tu-ilmenau.de/GOOD.html Contact: mailto:[email protected] (send subject of subscribe GENERIC mailing list) What: GRacer Where: http://gracer.sourceforge.net/ Description: 3D Motor sports simulator. Requires Tcl/Tk and OpenGL. Currently at version 0.1.5. Updated: 05/2000 Contact: mailto:[email protected] What: Nebula Device Where: http://www.radonlabs.de/ Description: Free multi-platform game engine running under Linux and Windows. Uses OpenGL and/or Direct3D for rendering and Tcl/Tk for scripting. C++ objects can be browsed and manipulated at runtime. Currently at version 2003-09-03. Updated: 09/2003 Contact: mailto:[email protected] What: OpenSpace Where: http://www.isr.umd.edu/%7Eihsu/ospace.html Description: A discrete-event modeling and simulation package for developing autonomous agents. It is designed to support contruction of distributed, interactive, multi-user, 3D shared environments, using VRML as the shape description language and OpenGL/Mesa as the rendering engine. Requires TkSM (see http://www.isr.umd.edu/%7Eihsu/tksm.html , Tk 7.4/Tk 4.0 or newer, and OpenGL. Contact: mailto:[email protected] (Irving Shang-Yi Hsu) What: polymer Where: http://www.math.fsu.edu/%7Ezduan/computer/ http://www.ssec.wisc.edu/%7Ebrianp/Togl.html http://www.cs.unm.edu/%7Ebederson/Togl.html http://www.ssec.wisc.edu/%7Ebrianp/homepage1.html ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM http://www.shelly.core.de/ http://www.libtiff.org/ Description: Polymer Visualization System, written in Tcl/Tk. Requires Togl and OpenGL or Mesa. The system has been built only on Sun SPARCs running Solaris 2.4/2.5.1 using Tcl7.6/Tk4.2 and Togl 1.2. Both Sun's OpenGL and Mesa-1.2.8 have been used. It also uses the tiff lib. Updated: 10/1999 Contact: mailto:[email protected] (S. F. Bellenot) mailto:[email protected] (Z.-H. Duan) What: Tecate Where: ftp://ftp.sdsc.edu/pub/sdsc/graphics/tecate/tecate.tar.gz Description: As described in Dr. Dobbs Journal, July 1997, Tecate is an extension of Tcl providing commands to interact with 3-D objects. Based on the OpenGL/Mesa library, Tecate provides the ability to create scriptable 3D browser applications. Updated: 08/1997 Contact: mailto:[email protected] (Peter D. Kochevar) What: TIGER Where: ftp://metallica.prakinf.tu-ilmenau.de/pub/PROJECTS/TIGER1.0/tiger1.0.tar.gz http://metallica.prakinf.tu-ilmenau.de/egr/tiger.htm Description: Tcl-based Interpretative Graphics EnviRonment is a tool for programming OpenGL. It has a Tcl extension for OpenGL 1.0, with integration of the Tk widget set, extensibile TIGER kernel, a Tk editor/soft debugger (in development), and a course for students to learn OpenGL. Depends on Tcl 7.3. Runs on Irix, SunOS, AIX, Linux, NetBSD, HPUX. Not for professional or commercial usage without registration. Send the line "subscribe TIGER mailing list" to join the TIGER mailing list. Contact: mailto:[email protected] (Ekkehard 'Ekki' Beier) mailto:[email protected] (TIGER mailing list) To join the TIGER mailing list mailto:[email protected] send a "subscribe TIGER mailing list" to mailto:[email protected] .
What: EGR TIGER Where: http://www.easterngraphics.com/products/tiger/ Description: Tcl based Interpretative Graphics EnviRonment (TIGER) is a tool for interpretative graphics programming, providing a one to one binding for OpenGL 1.0. Updated: 04/1999 Contact: mailto:[email protected] What: MAM/VRS (deprecated, see VRS below) Where: http://wwwmath.uni-muenster.de/%7Emam/ http://wwwmath.uni-muenster.de/informatik/u/mam/IMAM/imam.htm Description: Library for animated interactive 3D graphics, written in C++. Works on Unix (Linux, Solaris, Irix) and Windows 95/98/NT. Produces output for OpenGL/Mesa, POVRay, RenderMan, VRML. Provides Xt (Motif/Lesstif/Athena), Qt, Tcl/Tk, MFC and GTk bindings. iMAM has a variety of interactive elements. Covered by GNU LGPL. Currently at version 2.2 Alpha. Updated: 06/2000 Contact: mailto:[email protected] mailto:[email protected] (Tobias Gloth)
What: iVRS (sucessor to MAM/VRS, see above). Where: http://www.vrs3d.org/ Description: Library for animated interactive 3D graphics, written in C++. Works on Unix (Linux, Solaris, Irix) and Windows 95/98/NT. Produces output for OpenGL/Mesa, POVRay, RenderMan, VRML. Provides Xt (Motif/Lesstif/Athena), Qt, Tcl/Tk, MFC and GTk bindings. iMAM has a variety of interactive elements. Covered by GNU LGPL. Currently at version 3.3. Updated: 07/2004 Contact: mailto:[email protected] mailto:[email protected] (Juergen Doellner) mailto:[email protected] (Oliver Kersting) What: OpenGL context Tk widget Where: ftp://cgl.uwaterloo.ca/pub/cs488/supplied.july.95.tar.gz Description: Tk widget that maintains an OpenGL context. Updated: Contact: mailto:[email protected] (Michael D. McCool) What: OpenGL Tk output widget Where: ftp://ftp.EasternGraphics.com/pub/egr/tkopengl/tkopengl1.0.tar.gz Description: This Tk opengl widget allows integration of windows, having three-dimensional graphics output produced by OpenGl, into Tk applications. It is available for Unix and Windows platforms. Updated: 06/1997 Contact: mailto:[email protected] (Frank Wicht) What: TkOGL Where: http://tcltk.free.fr/tkogl/ http://aquarius.lcg.ufrj.br/%7Eesperanc/tkogl.html ??? http://aquarius.lcg.ufrj.br/%7Eesperanc/tkoglpaper.html http://www.usenix.org/publications/library/proceedings/tcl97/full_papers/esperanca/esperanca_html/ http://citeseer.nj.nec.com/esperanca97tk.html http://www.purl.org/net/bonnet/pub/TkOGL.zip http://hct.ece.ubc.ca/research/tkogl/ http://w3.impa.br/~nando/publ/3dv/ Description: Prelim release of a Tk OpenGL binding. Tested under Linux with Mesa and on RS6000/AIX 3.2.5 with IBM OpenGL and Meta. Requires Tcl/Tk. [[Are all these references to the same extension?]] Updated: 09/2003 Contact: mailto:[email protected] What: Tkoglx Where: ftp://linc.cis.upenn.edu/pub/ioi/tkoglx.tar.gz ftp://ftp.cs.princeton.edu/pub/people/dwallach/tkoglx-1.1.tar.gz Description: Experimental extension to support a small subset of Open GL. Use tkGLX if you need everything. The one from princeton supports Tk 4.0 and supports all possible visuals available from OpenGL. Updated: Contact: mailto:[email protected] (Dan Wallach) What: TkSM Where: http://www.isr.umd.edu/%7Eihsu/tksm.html (???) http://www.isr.umd.edu/%7Eihsu/tksm1.3.tar.gz http://www.mirror.ac.uk/sites/sunsite.unc.edu/pub/Linux/devel/lang/tcl/tksm1.3.tgz http://www.isr.umd.edu/%7Eihsu/ospace.html ftp://ftp.tcl.tk/pub/tcl/mirror/ftp.procplace.com/sorted/packages-8.0/devel/tksm1.3.tar.gz Description: A Mesa/OpenGL 3D modeling widget extension for Tcl 7./Tk. This provides no direct access to OpenGl routines. Includes VRML support, line and point models, material and normal bindings on a per-vertex basis. The umd files appear to be gone, but are present on the linux mirror site. The ospace page is a discrete-event modeling and simulation package for autonomous agents. It requires TkSM. Updated: 11/2000 Contact: mailto:[email protected] (Irving Hsu) (???) What: Togl Where: http://Togl.sourceforge.net/ http://sourceforge.net/project/showfiles.php?group_id=519 Description: Togl allows for OpenGL rendering into a Tk widget. It is based on Ben Bederson's OGLTK widget, but adds stereo rendering, color-index mode support, support for requesting stencil, accumulation alpha buffers, etc., multiple OpenGL drawing widgets, and OpenGL extension testing. Togl works on Microsoft Windows, Mac OS X, and Linux/Unix X11. Release 2.1 will add multisampling and pbuffer support. Updated: 02/2008 Contact: mailto:[email protected] (Greg Couch) What: Frustum Where: http://www.elf.org/pub/frustum01.zip Description: Frustum is a TOGL 1.5 widget hacked to run scripts packaged with a SWIG wrapper for OpenGL, GLU and a few additional extensions. Updated: 02/2000 What: Tom Where: http://sourceforge.net/projects/om2t http://perso.club-internet.fr/dropfred/index_en.html Description: Tom is an OpenGL wrapper for Tcl / Tk. About 90 % of OpenGL functionalities implemented, plus some GLUT functions. Both Linux and Windows supported. Updated: 03/2004 Contact: [email protected] What: Visualization Toolkit (VTk) Where: http://www.vtk.org/ http://kitware.com/vtk/index.html http://kitware.com/profile/press/?vtkug5.0-2006 Description: An object-oriented 3D visualization system written in C++ with full bindings for Tcl/Tk, Java and Python. It has rendering support for OpenGL, Starbase, GL, XGL, and X. It will run on UNIX, Windows96 and WindowsNT. This is the code from the Prentice Hall book "The Visualization Toolkit, an Object-Oriented Approach to 3D Graphics" (ISBN 013199837-4). Current version is 5.0.2 Updated: 07-Sep-2006 Contact: mailto:[email protected] (Kenneth M Martin)
Gdhe is a tool for 3D visualization of robotics applications.
It is totally programmable using the Tcl/Tk scripting language. It uses the OpenGL library to display the 3D primitives.
GDHE allows to build a 3D representation of the geometrical model of an environment and make it change with time. In order to achieve this, GDHE acts as a server that receives requests from a set of client processes. These requests describe the evolution of the model. Clients can be either modules that control a real system and that send data about the state of this system or simulation processes producing a simulated state of a virtual system.
OpenGL with C and Tcl/Tk : a simple widget from scratch (updated 2017 - supports Windows and Linux X11)
The Tcl-FAQ provided related information in its time.