Purpose: to provide a collection point of information about the use of [Tcl/Tk] and the OpenGL 3D graphics libraries. ---- http://purl.org/net/tcl-faq/part2.html ---- 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) at the Tcl scripting level. It comes with lots of demo programs. More info and images can be found at http://www.tcl3d.org ---- [AM] (9 september 2003) 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: * GLU - the standard OpenGL utilities library (several more complex objects, higher-level routines and texture mapping) * GLX - a library to interact with the [X] Window system * AUX - a library that you can use interact with the MS [Windows] system (comes from the so-called Red Book, may not be restricted to MS Windows) 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. Other features: * Texture maps can be comfortably stretched onto an arbitrary surface * Lighting can be taken care of * Hidden lines and surfaces are automatically removed from the drawing 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: * They determine the lighting properties (you need them to get a real 3D look) * The length of these vectors must be 1, because they also determine the brightness. A thing I only found out by experimentation :( ---- [GWM] Sep 2004 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. My own technique using the OpenSceneGraph (http://www.openscenegraph.org) is to set up Tcl/Tk from the C++ coding without the call to Tk_MainLoop but calling every frame: 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: * update scene * draw scene * HANDLE TCL/TK // above - loops until all Tcl/Tk events handled endLoop 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. ---- 12feb04 [jcw] - I've built a stubs-enabled version of Tkogl 1.1 for Windows, it's available at [http://www.equi4.com/pub/etc/Tkogl.dll]. 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 [http://groups.google.com/groups?threadm=2XfWb.63457%24GE5.1969109%40weber.videotron.net&group%3Dcomp.lang.tcl]. ---- [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. ---- [PO] 07/27/2005: DKF references the [tclogl] package, which now has its own Wiki page. [DKF] 6/6/2005: Looking through the open issues outlined at [http://www.t-ide.com/tcl2005e/10_Doing3DWithTcl.pdf.gz] I see a fair few that can actually be dealt with smartly, and others that we can surely help with (issues in bold): * '''GLU callbacks are currently not supported. This implies, that tesselation does not work, because this functionality relies heavily on the usage of C callback functions.''' What would be needed to support these callbacks? * '''There is currently no possibility to specify a color map for OpenGL indexed mode. As color maps depend on the underlying windowing system, this feature should be handled by the Togl widget.''' * '''Picking with depth values does not work correctly, as depth is returned as an unsigned int, mapping the internal floating-point depth values [[0.0 .. 1.0]] to the range [[0 .. 2**32 –1]]. As Tcl only supports signed integers, some depth values are incorrectly transferred into the Tcl commands.''' Actually, you can easily describe a 32-bit unsigned value as a wide integer, and from 8.5 onwards Tcl has support for integers of arbitrary precision. * '''The handling of Tcl errors inside of Togl callbacks could be improved.''' * '''To evaluate the Tcl callbacks, Tcl_Eval is currently used, which does not compile the script into bytecode. Use the object-interface instead.''' This will help a lot with speed issues, especially if no substitutions are performed. If you have to perform substitutions, the fastest way to handle the script is if you restrict it to a command invokation and then pre-parse it into a list of words which you stash in an array; then you can substitute Tcl_Obj pointers directly and invoke Tcl_EvalObjv() to execute the command. This is ''very'' fast. ---- http://purl.org/net/tcl-faq/part4.html ---- 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:ekki@prakinf.tu-ilmenau.de (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:matsu@users.sourceforge.net 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:feedback@radonlabs.de 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:ihsu@Glue.umd.edu (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:bellenot@math.fsu.edu (S. F. Bellenot) mailto:zduan@math.fsu.edu (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:kochevar@sdsc.edu (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:ekki@prakinf.tu-ilmenau.de (Ekkehard 'Ekki' Beier) mailto:wicht@prakinf.tu-ilmenau.de (TIGER mailing list) To join the TIGER mailing list mailto:tiger@prakinf.tu-ilmenau.de send a "subscribe TIGER mailing list" to mailto:ekki@prakinf.tu-ilmenau.de . ---- http://purl.org/net/tcl-faq/part5.html ---- 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:info@easterngraphics.com 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:mam@uni-muenster.de mailto:gloth@ESCHER.UNI-MUENSTER.DE (Tobias Gloth) [iVRS] 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:webmaster@vrs3d.org mailto:doellner@hpi.uni-potsdam.de (Juergen Doellner) mailto:oliver.kersting@hpi.uni-potsdam.de (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:mmccool@cgl.UWaterloo.CA (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:wicht@EasternGraphics.com (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:esperanc@cos.ufrj.br 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:dwallach@cs.princeton.edu (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.procplace.com/pub/tcl/sorted/packages-8.0/devel/tksm1.3.tar.gz Description: A Mesa/OpenGL 3D modeling widget extension for Tcl 7.[45]/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:ihsu@eng.umd.edu (Irving Hsu) (???) What: Togl Where: http://Togl.sourceforge.net/ http://www.mesa3d.org/brianp/Togl.html http://www.ssec.wisc.edu/%7Ebrianp/Togl.html (404 not found 2004/05/25) http://www.cs.unm.edu/%7Ebederson/Togl.html (404 not found 2004/05/25) http://www.informatik.uni-rostock.de/%7Erschultz/togl.html ftp://iris.ssec.wisc.edu/pub/misc/Togl-1.5.tar.gz ftp://iris.ssec.wisc.edu/pub/Mesa/misc/Togl-1.4.tar.gz ftp://ftp.gwdg.de/pub/linux/tux/x/MesaGL/misc/ http://www.ssec.wisc.edu/%7Ebrianp/Mesa.html http://www.elf.org/pub/frustum01.zip Description: Togl allows OpenGL or Mesa to render graphics into a special Tk canvas. It is based on Ben Bederson's OGLTK widget, but adds color-index mode support, support for requesting stencil, accumulation alpha buffers, etc., multiple OpenGL drawing widgets, and OpenGL extension testing. Version 1.6b2 is said to be on the gwdg site. Frustum is a TOGL widget hacked to run scripts packaged with a SWIG wrapper for OpenGL, GLU and a few additional extensions. Updated: 02/2000 Contact: mailto:brianp@ssec.wisc.edu (Brian Paul) 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: dropfred@users.sourceforge.net What: Visualization Toolkit (VTk) Where: http://www.vtk.org/ http://www.acns.com/%7Evtk/ http://www.kitware.com/vtkhtml/vtkData/subscribe.html http://www.hds.utc.fr/%7Ebarre/vtk/ 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). Version 4.2.6 is currently available. Updated: 03/2004 Contact: mailto:martink@cs.rpi.edu (Kenneth M Martin) ---- [Category Graphics] | [Category 3D Graphics]