Updated 2013-09-14 13:12:33 by paul

This page is intended for discussion about Tcl3D.

RT notes, 13Jan2006, tclogl has been renamed to tcl3d and now lives at [1]. I installed on win2000 and tried a number of demos successfully. One snag was that the main package require failed on my system due to missing dependent dlls for
    package require tcl3dcg
    package require tcl3dsdl

Fixed by adding the catch wrappers around these two commands. Nice and pretty extensive package!

PO 2006/01/15 If you do not have Cg and SDL installed, either use the patch above or use the Tcl3D-Lite distribution.

I'm currently working on a better way of detecting the availability of dependent libraries.

PO 2006/03/05 Above problem has been resolved. Try new version 0.3.

ramsan: I have been looking at the package (maybe not too deeply), and I did not find any reference to fonts and text. Does the package have any ability to define which fonts to use, font size, print text, encodings and international characters and get sizes info (the width and height that needs a given text in the screen)?

PO 2006/01/16 The Togl widget has built-in support for bitmap fonts, but Togl had problems displaying fonts on Windows, because it relied on Tk internal structures. I'm currently fixing this. A bug-fix release will hopefully be available next weekend. Here is a snapshot of my font test (and selection) tool.

RT 2006/01/16 - I see your font test shows anti-alias for Tk but not for Togl/tcl3d. Will anti-alias be caller-controlled in tcl3d?

PO 2006/03/05 - Antialiasing can be done in Version 0.3, when using the FTGL library. See the demo program ftglDemo.tcl.

ramsan 2006/02/11 - Is the font demo available in the tcl3d distribution? I could not find it in the web page and I could not find any command in the documentation related to font and text handling.

PO 2006/03/05 - It's available in Version 0.3.

I (ChrisL) am trying to get tcl3d built on OS X, but am out of my depth. I've downloaded and built swig in preparation, and made what I believe to be sensible edits to config_Darwin, but now I'm stuck. Has anybody successfully built tcl3d on a Mac?

DAS - He made binaries for Mac OS X Tiger and a diff of OS X changes, which are not available anymore. Note that while the tcl3dSDL binary is statically linked with SDL, the tcl3dCg binary requires Cg.framework from nvidia to be installed.

Most of the demos that I tried work ok, except for a few that use features that my old nvidia 4mx card does not support; it would be useful to have some testing by folks with macs with more modern graphics cards...

Also still available at that same location are a patch for the original tclogl 0.1 and binaries for Mac OS X Panther of tclogl 0.1 and the enhanced Togl 1.7 (which built out of the box on OS X]).

ChrisL : I just tried your tcl3d_darwin_0.2.tgz, but had problems:
    Library not loaded: /System/Library/Frameworks/Cg.framework/Cg

which is a framework I don't have. Do I need a different build for my ATi powered Mini? Any chance you could walk me through the build process? I'll investigate further when there isn't a slow VNC link between me and my Mac.

DAS - As mentioned above, you need to download and install Cg.framework from nvidia: [2], this is also explained in the tcl3d Readme... As for the build process, once the patch is applied, just build like on other platforms, as detailed in the tcl3d Readme.

PO 2006/06/19 - Mac OS X versions are available on the Tcl3D home page http://www.tcl3d.org. Thanks to DAS.

[Synic] 2006-12-24 - The Mac OS X port seems awfully slow on my PPC Mini -- 10x slower than my desktop PC which uses the same video card (ATI Radeon 9200) -- just testing 20 animated flat panes. It flies on Windows and Linux (despite my using the GNU Radeon kernel driver for X11 rather than the proprietory one). Any ideas what might be causing the sluggishness? Would installing this Cg.framework from nVidia do anything to fix it?

[Synic] 2007-01-22 - Okay, I've learned a bit more. Nope, the Cg.framework probably wouldn't do anything useful for performance. The problem is Mac OS X's drivers for the PPC Mac Mini (which uses the ATI Radeon 9200) don't support hardware acceleration in OpenGL. OpenGL is software rendered. GL_VENDOR=Apple, GL_RENDERER=Generic, GL_VERSION=1.1 Apple-1.1, GLU_VERSION=1.3 MacOSX. The latest drivers direct from www.ati.com don't add hardware acceleration either. Very unimpressed.

PO 2007/02/25 - Please try the new 0.3.2 release. If the graphics context, Togl wants to have, is not supported 100 percent, then the software renderer was choosen. I have changed this behaviour to have hardware accelerated OpenGL in any case. Tested on a MacBook.

[Synic] 2007-02-26 - Unfortunately, I can't try out the binary release (it's labelled as being for Intel Mac only, mine's PPC). I had a go at compiling from source and got stuck at this part:
 make -C tcl3dSDL all
 g++ -dynamiclib -Wl,-single_module -fno-common -o tcl3dSDL.dylib \
     tcl3dSDL_wrap.o \
     /Library/Frameworks/Tk.framework/libtkstub8.4.a \
     /Library/Frameworks/Tcl.framework/libtclstub8.4.a \
     -L../extlibs/Darwin -lSDL -framework OpenGL -framework AGL \
     -framework ApplicationServices
 /usr/bin/libtool: can't locate file for: -lSDL
 /usr/bin/libtool: file: -lSDL is not an object file (not allowed in a library)

Just in case, I tried port install libsdl libsdl_mixer libsdl_ttf libsdl_soundbut it didn't make any difference.

PO 2007/02/27 - You might try one of the following choices:

1. If you don't need the optional modules (SDL, FTGL, ...), just build the Tcl3D-Basic version. See chapter 2.2 and 2.4 of the manual. You more or less just have to edit the file make.wrap.

2. The libraries for the optional modules are expected to be in folder tcl3d/extlibs/Darwin by default. Otherwise you have to add -framework XXX to macro SYSLIBS in file config_Darwin.

Simple question: The extlibs_win32_0.3.zip includes "The SDL and FTGL DLL's" but there is nothing in the archive or in the manual that says where to put the files. So, where should they go?

Apparently in the system32 directory or any directory contained in your Path variable.

PO 2006/06/19 - The new version 0.3.1 now comes with Starpack versions of Tcl3D, which include all necessary external libraries.

What are the poTcllib and poTklib required by demos/redbook14/StartProgs.tcl?

PO 2006/06/19 - These are my private Tcl and Tk libs. StartProgs.tcl is just a left-over test program used for comparing the C and Tcl versions during development and should not be part of the distribution. Sorry.

IDG Apr 18 2006: One thing not provided by tcl3d is hardcopy output. To provide this, I have wrapped Christophe Guezaine's gl2ps package. Binary extensions for win32, linux32 and linux64 can be found in http://www.sfu.ca/~gay/tclgl2ps.zip.

PO 2006/06/19 - I have included the GL2PS library into the standard Tcl3D distribution starting at version 0.3.1. Thanks, Ian for idea and first implementation.

JBR The download at tcl3d.org does not contain the ODE bindings. Are these released yet?

PO 2007/02/25 - The new release 0.3.2 now includes an ODE wrapper for Windows, Linux, SGI and Mac OS X (Intel based). It still is very alpha, only basic features are wrapped. ODE heavily relies on callbacks. This will be one of the next tasks to do.

PO 2007/04/27 - A bug in release 0.3.2 with left-over bgerror calls in module tcl3dGauges has been found recently.

As this is a Tcl-only module, it's easy to fix:

1. If you don't need this module, just remove the directory tcl3dGauges.

2. Or edit the following files and remove the bgerror procedure:
   airspeed.tcl altimeter.tcl compass.tcl tiltmeter.tcl

PO 2007/06/20 - Problem report

Problem: Build process stops when environment variable DISPLAY is not set or access to DISPLAY is denied.

Synopsis: This is due to the script createStateList.tcl, which converts the ASCII representation of the OpenGL state variables into Tcl package code. The state list is created in a boots-trapping process, which needs to have a valid OpenGL context established. Therefore a Togl window has to be opened and this window needs acess to the DISPLAY.

Workaround: Replace the last line in tcl3dUtil/Makefile:
   $(TCLSH) createStateList.tcl glSpec$(DSEP)glSpec20.txt $@ > glSpec.out

with:
   echo "proc tcl3dGetStateList {} { return {} }" > tcl3dStateList.tcl

Note the tab as first character of the line.

Solution: Bootstrap process will be removed in future Tcl3D version and replaced by a pre-built tcl3dStateList.tcl file.

PO 2007/06/20 - Feature request

There has been a request for Mac OS X universal binaries of Tcl3D. As I am not a specialist with OS X, could somebody jump in here?

[Synic] 2007-07-14: The docs at http://developer.apple.com/technotes/tn2005/tn2137.html may help with this.

[Synic] 2007-08-09 - I've just tried the game I'm writing using Tcl3D on Windows 98 (through vmWare). First up, well done: It runs with no errors or bombing! Version 0.3.2 seems to be slow on this platform too, though I'm not sure how much of that is Tcl3D's fault or how much is due to vmWare and/or the OS instance's OpenGL driver support.

Just thought you might like the feedback :-)

PO 2007/08/09 - VmWare does not support 3D acceleration inside a virtual machine (yet). You can see, that it runs without "real" 3D by looking at the bottom line of the screenshot below (GDI generic). I typically start the Tcl3D Starpack inside a Win98 VM before releasing a new version and run some of the demos.

PO 2009/08/22 - For those still interested in Win98 support: Starting with version 0.4.1, the Windows binaries available at the Tcl3D homepage are created with Visual Studio 2005 (due to the new tcl3dOsg module) and do not work on Windows 98 anymore (but work on Windows 7). If compiled with Visual Studio 2003, Tcl3D 0.4.1 still runs on Windows 98.

[jamling] - 2009-09-09 11:21:33

Jamling 9/9/2009 Color index mode.

I try to use Tcl3D in color index mode. In 'togl' I use the option '-rgba false', then I set the color with the 'glIndex*' command. But, Is there an equivalent command to 'glutSetColor'. How setup the color-lookup table?

PO 2009/09/11 - As stated in chapter 5.2 of the manual, Tcl3D does not support color index mode. As color index mode is a deprecated feature of OpenGL 3.X, there are no plans to implement it in Tcl3D.

Note, that the effects of color index mode might be achieved by the use of 1D texture maps or shaders.

arezey 23/11/2009 22:24: Hey, is it possible to use the selection buffer in Tcl3D? I googled up a tutorial which contains the following code:
    //Calculate select buffer capacity and allocate data if necessary
    int capacity = getObjectCount()*4*getNameStackDepth();      //Each object take in maximium : 4 * name stack depth
    IntBuffer selectBuffer = BufferUtil.newIntBuffer(capacity);

    //Send select buffer to OpenGl and use select mode to track object hits
    gl.glSelectBuffer(selectBuffer.capacity(), selectBuffer);
    gl.glRenderMode(GL.GL_SELECT);

The code - especially the newIntBuffer part - seems like something not available in Tcl (though I only can code the hello world program in C so I don't know), any other way to get the capacity? Or other workarounds to get the selection? It's quite critical to a project I'm cooking here...

The only other way I can see would be to go through all the polygons which would include the cursor coordinates (though I don't know how to check if a point is inside a triangle or a quad) and check what's nearest. That's a last resort to me though..

PO 2009/11/23

Typing glSelectBuffer in the search field at http://www.tcl3d.org/html/demos.html finds 3 Tcl3D demos from the OpenGL RedBook using that command.

Integer arrays usable for glSelectBuffer can be created like this:
    set selectBuffer [tcl3dVector GLuint 512]

nscerqueira 2009/11/23

It would be interesting to have a molecular viewer using tcl3d. Similar things are available with vtk. See http://vizisaw.dubmun.com/tcl/tcl_part2.html Can it be done with tcl3d? It would be a nice and useful example.

PO 2009/11/26

What is done on above citied vtk page, can also be done with Tcl3D. The molecule description in PDB format is converted with an external program into Wavefront obj format and then read in. Wavefront obj files can be read with Tcl3D, too.

Looking around for PDB files on the web, gave me an idea for a nice little new Tcl3D Demo of the Month. Here is a screenshot of my first attempt. The final version will be available as December 2009 demo.

PO 2009/11/28

Tcl3D based molecule viewer reading the molecule description from PDB files is now available as December DotM.

The PDB parser supports the ATOM, HETATM and CONECT keywords. Possible extensions would be implementing the parser as a Tcl package and returning the molecule description as a dictionary.


nscerqueira - 2009-12-08 18:48:55

Hello.

I am having problems in the instalation of tcl3d in macOs (intel). I have defined the variables in the .bash_profile:
     export TCLLIBPATH=/System/Library/Tcl
     export DYLD_LIBRARY_PATH=/Users/nuno/Downloads/tcl3dsh-Darwin-0.4.1/extlibs:$DYLD_LIBRARY_PATH

I have moved the directory tcl3d to the /System/Library/Tcl directory

but while I am running any demo, or the molecule.tcl (previous example), it gives me the following error: bus error.

tcleval - 2009-12-11 Hi, how can I select and 3D object with tcl3d? in the pdb example, how could I select a sphere (atom)?

AMG 2010-06-18: I was using apply to directly embed code into the -createproc togl argument, but it turns out this only works when the script is very short. Here's why:
static void tcl3dCreateProc (struct Togl *togl) {
    if (togl->createCallback) {
        char cmd[256];
        /* Maximum length of Tcl procedure name is 200. */
        sprintf (cmd, "%.*s %s", 200, togl->createCallback,
                                      Tk_PathName (togl->TkWin));
        if (Tcl_Eval (Togl_Interp(togl), cmd) != TCL_OK) {
            free (togl->createCallback);
            togl->createCallback = NULL;
            Tcl_BackgroundError (Togl_Interp(togl));
        }
    }
}

Example code that fails ("missing close-brace"):
togl .togl -createproc [list apply [list toglwin #[string repeat x 184]]]

Example code that works:
togl .togl -createproc [list apply [list toglwin #[string repeat x 183]]]

Example code that CRASHES THE INTERPRETER:
togl .[string repeat x 54] -createproc [list apply [list toglwin #[string repeat x 183]]]

Example code that treats the widget name as executable script:
togl {.togl;error moo} -createproc puts

I suggest rewriting this code (and the code for the other -*proc option handlers) to use DString [3]. For an example, see TraceCommandProc() [4]. You could also use the deprecated Tcl_VarEval() function [5] (e.g, see TkpDisplayScale() [6]).

One question you have to ask is whether the value of -createproc is intended as a command prefix or a script prefix. Right now it's a script prefix, meaning that a space and an extra word get appended, and the result is eval'ed. (By the way, this is quite vulnerable to injection attacks.) If you want it to be a command prefix, use Tcl_EvalObjv() instead, and everything will be much simpler. The argument to -createproc will be a list instead of a script, but of course it could still be a script packaged into an [apply] invocation, which is precisely what I wanted.

For now, I will have to put my code in procs, as per the original design of togl. :^(

PO 2010-06-21 Thanks for reminding me on that ugly sprintf-hack from my very first Tcl3D work. I put it onto my TODO list for Togl related tasks.

AMG 2010-06-18: gluProject [7] and gluUnProject [8] are very clumsy to use in Tcl3D. To get the viewport bounds and the modelview and projection matrices, it's usually necessary to do glGetIntegerv [9] and glGetDoublev [10]. This produces Tcl3D vectors, which are tcl3dVectors (SWIG arrays) and not Tcl lists. So far, so good. The problem is in passing these to gluProject and gluUnProject, which take the viewport, modelview, and projection arguments as Tcl lists. Therefore conversion must take place. Converting from a tcl3dVector to a Tcl list is a very slow operation; it must be done in a for loop, one element at a time. Compounding the problem, the inverse conversion gets done internally when gluProject and gluUnProject actually get called. All this adds up to quite a big waste of time and code. I would like a way to pass the tcl3dVectors directly to gluProject and gluUnProject, as if they took "const void *". I'm not entirely sure how to go about doing this, though. I guess you can make wrappers that actually take "const void *" arguments.

PO 2010-06-21 There are utility functions tcl3dOglGetViewport and tcl3dOglGetDoubleState to get the necessary values as Tcl lists ready for gluProject and gluUnProject. See the unproject.tcl demo in the RedBook examples.

Of course these are not very fast. So I have implemented two new functions gluProjectVec and gluUnProjectVec, which use your "const void *" idea. These will be part of the upcoming new version. If you send me a mail, I can send you the changed glu.i file in advance.

PO 2010-07-31 Functions now available as tcl3dOglProject and tcl3dOglUnProject in Tcl3D 0.4.3.

AMG: Thanks! Unfortunately, I won't be able to make use of it in my current project, since one of my constraints is to use only binaries already publicly available for download. If not for Tcl and Tcl3d, I'd be in big trouble. :^)

Also I suggest implementing type-specialized tcl3dVectorToList in C, perhaps as an extra subcommand for the tcl3dVector object. I'm not sure if it should be able to return subranges or if it would be hard-coded to return the entire list. I don't think it can know the list length without being told, so nothing's stopping the user from asking for fewer elements than actually exist. Add a starting index parameter and you're the rest of the way there.

I've been using gluProject and gluUnProject fairly heavily, and I simply accept the performance hit. I'm not doing animation; the display only updates in response to GUI events.

PO 2010-06-21 This is a feature of my TODO list since quite some time, but with lowest priority. For 4-element vectors and 16-element matrices the standard tcl3dVectorToList function is normally fast enough. Other tcl3dVectors are typically textures, which are converted to Tk photo images by a specialized C function.

AMG: It makes sense that this be low-priority. But every once in a while you might want to do an easy task, as a finger exercise perhaps, so maybe you might bang this one out when you want to take a break from solving the hard problems.

AMG: Right now I'm fighting with drawing non-ASCII characters in FTGL. All I want is a degree sign "°", but it shows up as A-circumflex followed by degree sign. Probably each byte of the UTF-8-encoded string is being treated as a separate character.

PO 2010-07-31 Degree sign should now work with new FTGL version in Tcl3D 0.4.3.

ABU 2010-07-20 Loading large images

Loading large images (2000x2000 pixels) in a texture on my PC may take from 1 to 2 seconds. This is unacceptable because the UserInterface does not respond during this long operation. I wonder if there's a way for loading a texture in some async-way, maybe with the help of a new thread.

PO 2011-10-03 Installed the Windows 8 Preview in a virtual machine today, downloaded the latest Tcl3D starpack (0.5.0), and voila, it ran without problems.


IDG Has anyone else had problems on Linux, running on Mesa 8.0? I get segfaults when the .so attempts to load. No problems on same system with Mesa 7.10.