Home

Tcl3D: Doing 3D with Tcl

image

Contents

1. SWIG generated Tcl interfaces Tcl Interface tcl3dUtil tcl3dOgl tcl3dOgIlExt tcl3dTogl C based Utilities Basic OpenGL Extended OpenGL OpenGL Widget tcl3dCg tcel3dSDL tcl3dFTGL Nvidia s Cg Joystick and CD Font Rendering tcl3dGI2ps tcl3dOde tcl3dDemouUtil OpenGL to PS PDF Physics Engine C utilities for demos 1 2 Modules overview This chapter gives you a short overview of the modules available in Tcl3D 1 2 1 tcl3dTogl Enhanced Tog widget This module is an enhanced version of the Tog 3 widget a Tk widget for displaying OpenGL graphics The following enhancements are currently implemented e Callback functions in Tcl e Better bitmap font support e Multisampling support e Swap Interval support A detailled description of this module can be found in chapter 4 1 1 2 2 tcel3dUtil Tcl3D utility library This module implements C C and Tcl utilities offering functionality needed for 3D programs It currently contains the following submodules e 3D vector and transformation matrix module e Information module e Color names module e Large data module tcl3dVector e Image utility module Tcl3D User Manual Version 0 3 2 February 2007 Page 3 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Screen capture module Timing module 3D model and shapes module Virtual trackball module A detailled description of
2. tcl13d demos VERSION zip Tcl3D demo sources tcl3d demoimgs VERSION zip Screenshots of all Tcl3D demo programs Starpacks tcl3dsh win32 VERSION zip Tcl3D Starpack for Windows tcl3dsh Linux VERSION zip Tcl3D Starpack for Linux tcl3dsh Darwin VERSION zip Tcl3D Starpack for Mac OS X tcl3dsh IRIX64 VERSION zip Tcl3D Starpack for SGI IRIX Binary packages tcl3d win32 VERSION zip DLL s of external libraries and Tcl3D package for Windows tc13d Linux VERSION zip DSO s of external libraries and Tcl3D package for Linux tc13d Darwin VERSION zip DSO s of external libraries and Tcl3D package for Mac OS X tcl3d IRIX64 VERSION zip DSO s of external libraries and Tcl3D package for SGI IRIX Sources tcl3d src VERSION zip Tcl3D source distribution tcl3d starpack VERSION zip Tcl3D sources for creating Starpacks The term VERSION is a template for the Tcl3D version number i e for the currently available version it must be replaced with 0 3 2 2 1 Installation of a binary distribution There are two possibilities to install a Tcl3D binary distribution onto your computer 2 1 1 Installation from a Tcl3D starpack The following prerequisites are needed when installing from a Tcl3D starpack e An OpenGL driver suitable for your graphic card recommend to download and install an actual OpenGL driver from the
3. return list texImg w h proc CreateTexture Load an image into a tcl3dVector set imgInfo LoadImage Wall bmp set imgData lindex S imgInfo 0 set imgWidth lindex S imgInfo 1 set imgHeight lindex SimgInfo 2 Create the texture identifiers glGenTextures 1 texture glBindTexture GL TEXTURE 2D texture get 0 glTexParameteri GL TEXTURE 2D GL TEXTURE MIN FILTER GL LINEAR glTexParameteri GL TEXTURE 2D GL TEXTURE MAG FILTER GL LINEAR glTexImage2D GL _TEXTURE_2D 0 3 SimgWidth S imgHeight 0 GL_RGBA GL_ UNSIGNED BYTE SimgData Delete the image data vector SimgData delete Example 2 Read an image from the OpenGL framebuffer and save it with the Img library proc SaveImg imgName set w toglWidth set h toglHeight set numChans 4 Tcl3D User Manual Version 0 3 2 February 2007 Page 29 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org set vec tcl3dVector GLubyte_ expr Sh SnumChans SfRexdoiseis 0 0 Se h upy REpA SP uS ronib pyte SSea ii set ph image create photo width w height h tcl3dVector2Photo vec ph w h numChans set fmt string range file extension imgName 1 end ph write imgName format fmt image delete phImg vec delete proc tclReshapeFunc toglwin wh set toglWidth w set toglHeight h The actual size of the Togl window toglWidth to
4. tcl3dHaveExtension Check if a given OpenGL extension is provided by the OpenGL implementation tcl3dHaveCg Check if the Cg library has been loaded successfully tcl3dHaveSDL Check if the SDL library has been loaded successfully tcl3dHaveFTGL Check if the FTGL library has been loaded successfully tcl3dHaveGl2ps Check if the GL2PS library has been loaded successfully tcl3dHaveOde Check if the ODE library has been loaded successfully tcl3dHaveVersion Check if a specific OpenGL version is available tcl3dGetVersions Query the OpenGL library with the keys GL_ VENDOR GL_RENDERER GL_VERSION GLU_VERSION and return the results as a list of key value pairs tcl3dGetExtensions Query the OpenGL library with the keys GL EXTENSIONS and GLU_EXTENSIONS and return the results as a list of key value pairs tcl3dGetStates Query all state variables of the OpenGL library and return the results as a list of sub lists Each sublist contains a flag indicating the sucess of the query the querying command used the key and the value s Note The functions glGetString and gluGetString as well as the corresponding high level functions tcl3dGetVersions and tcl3dGetExtensions only return correct values if a tcl3dTogl window has been created i e a rendering context has been established Examples The following code snippet shows how to call tcl3dGetVersions foreach glInfo tcl3dGetVersions puts lindex glInfo 0 lindex glI
5. createproc tclCreateFunc displayproc tclDisplayFunc reshapeproc tclReshapeFunc grid fr toglwin row 0 column 0 sticky news Note Option createproc is not effective when specified in the configure subcommand It has to be specified at widget creation time 4 2 tcl3dUtil Tcl3D utility library This module implements several utilities in C and Tcl offering functionality needed for 3D programs It currently contains the following submodules e 3D vector and transformation matrix module e Information module Tcl3D User Manual Version 0 3 2 February 2007 Page 22 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl Color names module Image utility module Screen capture module Timing module Virtual trackball module www tcl3d org Large data module tcl3dVector 3D model and shapes module Requirements for this module None all files are contained in the Tcl3D distribution The master SWIG file for wrapping the utility library is tel3dUtil i 4 2 1 3D vector and transformation matrix module This module provides miscellaneous 3D vector and 4x4 transformation matrix functions Implementation files tcl3dVecMath c tcl3dVecMath tcl Header files tcl3dVecMath h Wrapper files utili Tcl command Description tcel3dVec3f Print Print the contents of a 3D vector onto standard output tcl3dVec3fIdentity Fill a 3D ve
6. gt Starpack version of Tcl3D including demos and external libraries First shown at TclEurope 2006 gt New optional module tcl3dGI2ps wrapping the OpenGL To Postscript library Thanks to lan Gay for idea and first implementation gt New optional module tcl3dOde wrapping the Open Dynamics Engine Very alpha preview Windows only gt More NeHe tutorials added Lessons 19 21 2006 02 12 Bug fixes and enhancements gt Support for Mac OS X added Thanks to Daniel A Steffen for supplying Darwin patches and binaries New optional module tcl3dFTGL wrapping the OpenGL font rendering library FTGL based on freetype fonts Corrected and enhanced font handling under Windows in the tcl3dTogl widget No more private Tcl header files needed Added new font related demo programs tcl3dFont tcl tcl3dToglFonts tcl ftglTest tcl ftgIDemo tcl Added new SDL demo related to CD ROM handling cdplayer tcl Added some of NeHe s OpenGL tutorials If an optional library is not installed no error message is created New procedures to check existence of optional modules tcl3dHaveCg tcl3dHaveSDL tcl3dHaveFTGL Get information on Tcl3D subpackages with tcl3dGetPackagelnfo and tcl3dShowPackagelnfo Information program tcl3dInfo tcl enhanced to support commands and enums of SDL and FTGL modules Added new functionality to tcl3dUtil Simple scrollable Tk widgets for demo programs virtual trackball used in FTGLdemo tcl
7. Added new functionality to tcl3dUtil tcl3dVectorFromByteArray tcl3dVectorToByteArray Convert Tcl binary strings to tcl3dVectors and vice versa see demo bytearray tcl gt Bug fix in OglExt wrapping Parameters of type float and double were wrapped incorrectly VVV V V WV Vv Vv V WV 2006 01 07 Major rewrite and additional support of several new 3D libraries OpenGL extensions Cg shader SDL Gauge widgets Thanks to Victor G Bonilla for supplying this library Utility library Vv VVV WV Tcl3D User Manual Version 0 3 2 February 2007 Page 44 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org gt Renamed from tclogl to Tcl3D gt Created domain tcl3d org 2005 05 29 0 1 First version called tclog gt Introduced at the Tcl Europe 2005 conference gt Supported features include basic OpenGL wrapping A note for users of the first version 0 1 called tclogl Usage of tclogl is not recommended anymore The following Tcl procedures have different names in the newer versions It is recommended to update your scripts to the new naming scheme The following Tcl lines make your old scripts run with the new releases rename rename rename rename rename rename rename rename rename rename rename Vector tcl3dVector VectorPrint tcl3dVectorPrint VectorFromList tcl3dVec
8. tcl3dSDL 0 tcl3dFTGL 0 tcl3dGl2ps tc13d0de 0 0 0 0 tcl3dGauges tcl3dDemoUtil Legend Column Wrap Interface of module fully wrapped Interface of module partially wrapped 0 Module not yet wrapped Module not available for the platform Column Test Module extensively tested No errors known Module tested Minor errors known 0 Module in work Module not available for the platform Short summary The Windows and Linux ports are supported best and are regularly tested on different hardware combinations On IRIX every module except Cg which is not available for SGI has been wrapped and seems to be running fine but no extensive tests are made The OS X port is in it s first stage and needs another iteration of extensive testing 1 4 Getting started The easiest way to get started is using a Tcl3D starpack Starpacks for Windows Linux IRIX and Mac OS X Intel based can be downloaded from http www tcl3d org See chapter 2 for a detailled information about all available Tcl3D packages The only prerequisite needed for using the Tcl3D starpack distribution is an installed OpenGL driver Everything else even the Tcl interpreter is contained in the starpack The starpacks are distributed as a ZIP compressed file Unzipping this file creates a directory containing the starpack tcl3dsh OS VE
9. 2 Installation of a source distribution This chapter outlines the general process of compiling customizing and installing the Tcl3D package See the file Readme txt in the source code distribution for additional up to date information 2 2 1 Step 1 Prerequisites The following prerequisites are needed when using a TcI3D source package Tcl3D User Manual Version 0 3 2 February 2007 Page 10 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org e An OpenGL driver suitable for your graphic card recommend to download and install an actual OpenGL driver from the manufacturer of your graphic card especially if intending to write shader programs in GLSL or Cg e A Tcl Tk version greater or equal to 8 4 e The Img extension is needed to have access to various image formats which are used as OpenGL textures e For some demos the snack extension is used e To generate screenshots from the Tcl3D presentation the Twapi extension is needed on Windows therefore recommend to use an actual ActiveTcl distribution 17 which contains all of the above listed Tcl extensions To build the Tcl3D from source you also need the following tools installed and accessable from the command line Tool Version URL GNU make gt 3 79 http www gnu org SWIG gt 1 3 19 http www swig org Note e A binary version of SWIG version 1 3 24 for
10. Tcl3D utility library tcl3dOgl Wrapper for basic OpenGL functionality tcl3dOglExt Wrapper for enhanced OpenGL functionality tcl3dCg Wrapper for NVidia s Cg shading language tcl3dSDL Wrapper for the Simple DirectMedia Library tcl3dFTGL Wrapper for the OpenGL Font Rendering Library tcl3dGl2ps Wrapper for the OpenGL To Postscript Library tcl3dOde Wrapper for the Open Dynamics Engine tcl3dGauges Tcl3D package for displaying gauges tcl3dDemoUtil C C based utilities for demo applications 4 1 tcl3dTogl Enhanced Togl widget Tog 3 is a Tk widget with support to display OpenGL graphics The original version only supported issuing drawing commands in C To be usable from the Tcl level it has been extended with configuration options for specifying Tcl callback commands tcl3dTogl Requirements for this module None all files are contained in the Tcl3D distribution 4 1 1 Togl commands The following is a list of currently available Togl commands The commands changed or new in Tcl3D are marked bold and explained in detail below For a description of the other commands see the original Togl documentation configure render swapbuffers makecurrent postredisplay loadbitmapfont unloadbitmapfont Bitmap fonts Specifying bitmap fonts can be accomplished with the loadbitmapfont command The font can either be specified in XLFD format or Tk like with the following options family courier times weight medium bold s
11. code of tcl3dSphere is copyrighted by Paul Bourke The original code of tcl3dHelix is copyrighted by Dario Corno The original code of tcl3dArcBall is copyrighted by Tatewake com The original code of tcl3dTrackball is copyrighted by Gavin Bell et al The Tcl3D gauge library is copyrighted by Victor G Bonilla and distributed under the BSD license The original Togl widget is copyrighted by Brian Paul and Benjamin Bederson The modified Tcl3D version is copyrighted by Paul Obermeier and distributed under the BSD license The SWIG wrapper files and supporting Tcl files of all modules are copyrighted by Paul Obermeier and distributed under the BSD license See the homepages of the wrapped libraries for their license conditions 5 2 Programming hints Hint 1 Some OpenGL functions expect an integer or floating point value which is often given in C code examples with an enumeration as shown in the next example extern void glTexParameteri GLenum target GLenum pname GLint param It is called in C typically as follows glTexParameteri GL_ TEXTURE 2D GL TEXTURE WRAP _S GL REPEAT glTexParameteri GL_ TEXTURE 2D GL TEXTURE MAG FILTER GL NEAREST As the 3 parameter is not of type GLenum you have to specify the numerical value here glTexParameteri GL TEXTURE 2D GL TEXTURE WRAP S GL REPEAT glTexParameteri GL TEXTURE 2D GL TEXTURE MAG FILTER GL NEAREST If called with the enumeration name glTexParameter
12. driver GUI Under Linux you can set the environment variable _GL_ FSAA MODE to 1 4 1 3 A simple Tcl3D template A template for a TcI3D application looks like follows package require tcl3d proc tclDisplayFunc toglwin Clear color and depth buffer glClear expr GL COLOR BUFFER BIT GL DEPTH BUFFER BIT glLoadIdentity Reset the current modelview matrix glTranslatef 0 0 0 0 5 0 Transformations glRotatef xrot 1 0 0 0 0 0 glRotatef yrot 0 0 1 0 0 0 glRotatef zrot 0 0 0 0 1 0 drawGeometry Draw the actual geometry Stoglwin swapbuffers Swap front and back buffer proc tclCreateFune toglwin glShadeModel GL SMOOTH glClearColor 0 0 0 0 0 0 0 5 A glClearDepth 1 0 glEnable GL_DEPTH TEST Enable smooth shading Black background Depth buffer setup Enable depth testing th HOH proc tclReshapeFunc toglwin wh glViewport 0 0 w h Reset the current viewport glMatrixMode GL PROJECTION Select the projection matrix glLoadIdentity Reset the projection matrix Calculate the aspect ratio of the window gluPerspective 45 0 expr double w double h 0 1 100 0 glMatrixMode GL_MODELVIEW Select the modelview matrix glLoadIdentity Reset the modelview matrix frame fr pack fr expand 1 fill both Create a Togl widget with a depth buffer and doublebuffering enabled togl fr toglwin width 250 height 250 double true depth true
13. generate wrapper functions for allocating and freeing memory of any type This SWIG feature sarray functions has been extended and replaced with 2 new SWIG commands sbaseTypeVector for scalar types and complexTypeVector for complex types like structs It not only creates setter and getter functions for accessing single elements of the allocated memory but also adds functions to set ranges of the memory There are wrapper functions for these scalar types defined in file tel3dArrays i Array of is mapped to char char short short int int float float double double GLenum unsigned int GLboolean unsigned char GLbitfield unsigned int GLbyte signed char GLshort short GLint int GLsizei int GLubyte unsigned char GLushort unsigned short GLuint unsigned int GLfloat float GLclampf float GLdouble double GLclampd double GLchar char GLcharARB char The generated wrapper code looks like this Example shown for GLdouble static double new GLdouble int nelements return double calloc nelements sizeof double Tcl3D User Manual Version 0 3 2 February 2007 Page 26 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org static void delete GLdouble double ary free ary static double GLdouble getitem double ary int index return ary index static
14. point by a given matrix tcl3dMatfTransformVector Transform a 3D vector by a given matrix tel3dMatfMult Multiply two transformation matrices tcel3dMatfinvert Invert a transformation matrix tcl3dMatfTranspose Transpose a transformation matrix Tcl3D User Manual Version 0 3 2 February 2007 Page 23 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org See the test programs matmathtest tcl and vecmathtest tcl for examples on how to use these procedures Also take a look at the demo program og _fps_controls tcl for a real world example 4 2 2 Information module This module provides miscellaneous functions for querying OpenGL related information Implementation files tcl3dInfo tcl Header files None Wrapper files None Tcl command Description tcl3dHavePackage Check if a Tcl package is available in a given version tcl3dGetLibraryInfo Return the library version corresponding to supplied Tcl3D package name tcl3dGet PackageInfo Return a list of sub lists containing Tcl3D package information Each sub list contains the name of the Tcl3D sub package the availability flag 0 or 1 the sub package version as well as the version of the wrapped library tcl3dShowPackageInfo Display the version info returned by tcl3dGetPackageInfo in a toplevel window
15. specifier as consistent as the GL core library So one class of function parameters TYPE is handled differently with GLU functions Arguments of type TYPE are used both as input and output parameters in the C version In GLU 1 2 most functions use this type as input parameter Only two functions use this type as an output parameter So for GLU functions there is the exception that TYPE is considered an input parameter and therefore is wrapped as a Tcl list Input parameter TYPE GLU only void gluNurbsCurve GLUnurbs nobj GLint nknots GLfloat knot GLint stride GLfloat ctlarray GLint order GLenum type C declaration GLfloat curvePt 4 2 0 25 0 5 0 25 0 75 0 75 0 75 0 75 0 5 c GLfloat curveKnots 8 0 0 0 0 0 0 0 0 cxamps E P ec ee ero eo gluNurbsCurve theNurb 8 curveKnots 2 amp curvePt 0 0 4 GLU_MAP1 TRIM 2 set curvePt 0 25 0 5 0 25 0 75 0 75 0 75 0 75 0 5 set curveKnots 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 Tcl example gluNurbsCurve S theNurb 8 ScurveKnots 2 ScurvePt 4 GLU_MAP1 TRIM 2 The two aforementioned functions which provide output parameters with TYPE are gluProject and gluUnProject These are handled as a special case in the SWIG interface file glu i The 3 output parameters are given the keyword OUTPUT so SWIG handles them in a special way SWIG builds a list consisting of the normal function return value and all parameters marked with that keyw
16. 32_ PATH tel3dsh Linux 0 3 2 5 5 2 Starpack problem 2 Some of the external libraries need files for initialization ex the FTGL library needs the name of a TrueType font file to construct it s OpenGL commands This font file has to be on the real filesystem so that the FTGL library can find it and not in the virtual filesystem of the starpack Tcl3D supports a utility procedure tcl3dGetExtFile which you should use if intending to use a Tcl3D script depending on such a library in a Starpack See file tcl3dFile tcl in directory tcl3dUtil tclfiles for the code of the procedure and more inline comments A typical usage is shown in the following code segment set fontfile file join file dirname info script Vera ttf tcl3dGetExtFile is available only in versions 0 3 1 and up You may check availability of command first if running scripts with older Tcl3D versions if info proc tcl3dGetExtFile eq tcl3dGetExtFile Get the font file in a Starpack independent way set fontfile tcl3dGetExtFile S fontfile Tcl3D User Manual Version 0 3 2 February 2007 Page 41 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 6 Demo applications More than 100 Tcl3D applications for testing and demonstration purposes are currently available Most of these applications were converted from existing demonstration programs written in C C
17. Convert SDL CD status enumerations into a string representation See the demo programs contained in directory LibrarySpecificDemos tcI3dSDL for examples on how to use the SDL functions 4 7 tcl3dFTGL Wrapper for the OpenGL Font Rendering Library This module wraps the FTGL 20 library based on version 2 1 2 and adds some FTGL related utility procedures The FTGL library depends on the Freetype2 library 21 This is an optional module Requirements for this module The FTGL and Freetype2 library and header files Libraries and header files are included in distribution The master SWIG file for wrapping the OpenGL Font Rendering library is tel3dFTGL i Implementation files None Header files All files in subdirectory include Wrapper files ftgl i The wrapping for this module is based on the unmodified FTGL header files FTGL utility module Tcl command Description tcl3dFTGLGetVersion Get the version of the wrapped FTGL library See the demo programs contained in directory LibrarySpecificDemos tcl3dFTGL for examples on how to use the FTGL functions 4 8 tcl3dGl2ps Wrapper for the OpenGL To Postscript Library This module wraps Christophe Geuzaine s GL2PS 22 library based on version 1 3 2 and adds some GL2PS related utility procedures Note GI2PS does not support textures This is an optional module Tcl3D User Manual Version 0 3 2 February 2007 Page 36 o
18. Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Instead of editing the configuration file you may alternatively create a file called make private in the top level directory of Tcl3D and add lines according to your needs ifeq S MACHINE win32 INSTDIR F Programme poSoft TCLDIR F Programme Tcl endif ifeq S CONFIG mingw INSTDIR TCLDIR endif F Programme poSoft F Programme Tcl 2 2 3 Step 3 Customization The optional modules can be included or excluded from the comilation step by setting the following macros in file make wrap in the top level directory of the Tcl3D source tree Macro name Description Additional check file WRAP_OGLEXT Customize support for tcl3dOglExt OgIlExt glext h WRAP_CG Customize support for tcl3dCg Cg cg h WRAP SDL Customize support for tcl3dSDL include SDL h WRAP_FTGL Customize support for tcl83dFTGL include FTGL h WRAP _GL2PS Customize support for tcl3dGl2ps gl2ps h WRAP_ODE Customize support for tcl3dOde ode ode h Note Do not set a macro to 0 but comment the corresponding line i e undefine as shown in the following example WRAP FEATURE 1 enables the feature WRAP FEATURE 1 disables the feature Each Makefile of an optional module additionally checks for the existence of an important include file as listed in column Additional check file to enable e
19. IRIX is available from my private home page http www posoft de e Tcl3D is currently generated and tested with versions 1 3 24 and 1 3 29 These versions are recommended e See chapter 5 4 for known bugs with other SWIG versions Download and unzip the following distribution packages suitable for your operating system e tcl3d srce 0 3 2 zip e tcl3d 0S 0 3 2 zip e tcl3d demos 0 3 2 zip e tcl3d starpack 0 3 2 zip Example installation procedures Version 1 Tcl3D Basic OpenGL support no external libraries Needed tcl3d srce 0 3 2 zip Recommended tcl3d demos 0 3 2 zip Unzip tcl3d src 0 3 2 zip in a folder of your choice This creates a new folder tcl3d containing the sources Unzip tc13d demos 0 3 2 zip into the new folder tcl3d If only basic OGL support is needed comment all WRAP_ macros in file make wrap For extended OpenGL support leave the macro WRAP_OGLEXT uncommented See the chapter 2 2 3 Customization for details The presentation framework presentation tcl works but the texts are displayed as 2D bitmaps only Most OpenGL only demos should work Version 2 Tcl3D Complete OpenGL support plus optional external libraries Needed tcl3d srce 0 3 2 zip Needed tcl3d 0S 0 3 2 zip Recommended tcl3d demos 0 3 2 zip Unzip tcl3d src 0 3 2 zip in a folder of your choice This creates a new folder tcl3d containing the sources Unzip tc13d demos 0 3 2 zip into the new folder tcl3d Unzip tc13d OS 0 3 2 zip into a tempor
20. PE void glMaterialfv GLenum face GLenum pname const GLfloat params GLfloat mat_diffuse 0 7 0 7 0 7 1 0 C declaration C example glMaterialfv GL FRONT GL DIFFUSE mat diffuse Tel l set mat_diffuse 0 7 0 7 0 7 1 0 C exaAmpie glMaterialfv GL FRONT GL DIFFUSE mat diffuse Note e This type of parameter is typically used to specify small vectors 2D 3D and 4D as well as control points for NURBS e Unlike in the C version specifying data with the scalar version of a function ex glVertex3f is faster than the vector version ex gl Vertex3 fv in Tcl e Tcl lists given as parameters to a Tcl3D function have to be flat i e they are not allowed to contain sublists When working with lists of lists you have to flatten the list before supplying it as an input parameter to a Tcl3D function One way to do this is shown in the example below set ctrlpoints 4 0 4 0 0 0 2 0 4 0 0 0 2 0 4 0 0 0 4 0 4 0 0 0 0 0 glMap1f GL MAP1 VERTEX 3 0 0 1 0 3 4 join S ctrlpoints Tcl3D User Manual Version 0 3 2 February 2007 Page 16 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org The mapping of const void pointers is handled by SWIG standard typemaps Constant void pointers as function input parameter must be given as a pointer to a contiguous piece of memory of appropriate size Inpu
21. PrtSc into the Windows clipboard tcl3dWindow2Img Copy the contents of the top level window Alt PrtSc into a photo image Windows only tcl3dWindow2File Copy the contents of the top level window Alt PrtSc into a photo image and save the image to a file Windows only Tcl3D User Manual Version 0 3 2 February 2007 Page 30 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org See the demo program presentation tc l for an example on how to use these procedures to save screenshots of all available Tcl3D demos by right clicking on the demo name 4 2 7 Timing module This module provides functions for timing purposes Implementation files tcl3dStopWatch c Header files Wrapper files tcl3dStopWatch h utili The tcl3dStopWatch files implement a stop watch with the following commands Tcl command Description tcl3dNewSwatch Create a new stop watch and return it s identifier tcl3dDeleteSwatch Delete an existing stop watch tcl3dstopSwatch Stop a running stop watch tcel3dStartSwatch Start a stop watch tcl3dResetSwatch Reset a stop watch i e set the time to zero seconds tcl3dLookupSwatch Lookup a stop watch and return the elapsed seconds See the demo program spheres tcl for an example on how to use these procedures to measure the rendering frame rate 4 2 8 3D Model and shape
22. RSION Distributions for Unix systems contain an additional shell script tcl3dsh OS VERSION sh which should be used for starting the Tcl3D starpack Tcl3D User Manual Version 0 3 2 February 2007 Page 6 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org After starting the starpack a toplevel Tk window labeled Tc13D as well as a console window labeled Tc13D Console should appear similar to starting a wish shell The console window should contain the following two message lines as well as a tcl3d prompt tcl3d gt Typing pres in the console window starts the Tcl3D presentation showing an introductionary animation as shown in the screenshot below The available key and mouse bindings are shown in the console window R Tcl3D intro AS Orought to you oN Paul Obermei er Selg i elajn x Information Tcl3D intro Tcl3D packages OpenGL information OpenGL extensions Cg profiles Installation J Install Tcl packages Install Tcl3D demos Install external libraries Binding Action Key Escape Exit the program Key Left Move text to the left Key Right Move text to the right Key i Increase distance from viewer Key d Decrease distance from viewer Key Up Increase speed Key Down Decrease speed Key plus Rotate text Key minus Rotate text other direction Key space Set speed of
23. Tcl3D Doing 3D with Tcl www tcl3d org Tcl3D Doing 3D with Tcl DIN TRO TON as sictirsasietntircanienninrenniecwncenncta ive ainai einan anasan sebaa a se satsa aiara ruunan Erain 2 1 1 Architecture OveVieW iisisesccay cehcucsit desvcaay de vceas abviabedavveast dabaiaaydavieast dpa denedik d hEr 2 1 2 Modules OVEIVIOW ccrececcierhes sith oie aaae a ac coar ied aE A a Eha eae N ENEA 3 1 3 Supported PlAMOMMS vciicatniacaicintscavedaincardiaiasanniatecaidiniscatebeisearaiais aatkcaraiavecatniatacatelaneex 6 1 4 Getting started oi ccaciecsesivasedtncxasauavavasiGanaetaubeay EE EEEL r EEEE anand AAEE EEEa A KRERET 6 2 INSTALLATION sisssiestasetina sda cass anain aa na aa a ses RE a Sa a Eaa a a Eaa NAE 9 2 1 Installation of a binary distribution cccccceeeeeeeeeeeeneeeeeeeeeeeeeeeeaaaeeeeeeeeeseeeeeneeeeeeees 9 2 2 Installation of a source distribution eseeeeeeeeee eenen eeen eeen eeen nenene 10 2 3 Extending Tel Bee en ee a eee eee ee ere rere peer eee iaaii da aid 14 3 WRAPPING IN DE DAUD isiiciescesnctiercsnnetcecmiaciidasentianmnenddimansmindaetiabenimialeiomneiaeues 15 3 1 Wrapping description ee 15 3 2 Wrapping reference Card ccccccccccccccecceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeesenenegs 19 4 MODULES IN DETAIL nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnan n nanne ennnen ennnen eneen 20 4 1 tcl3dTogl Enhanced Togl widget 2 2 2 20 cc cccicicaescetscaen
24. ady for using Tcl3D from standard Tcl by starting a tclsh or wish program and issuing the following command package require tcl3d Alternatively you can extract the 3 installation folders with one of the following methods e Start the Tcl3D starpack and issue the command inst in the console e Start the Tcl3D starpack with command line parameter inst Both steps will copy the 3 above described package folders into the directory containing the starpack 2 1 2 Installation from a binary package The following prerequisites are needed when using a TcI3D binary package e An OpenGL driver suitable for your graphic card recommend to download and install an actual OpenGL driver from the manufacturer of your graphic card especially if intending to write shader programs in GLSL or Cg e A Tcl Tk version greater or equal to 8 4 e The Img extension is needed to have access to various image formats which are used as OpenGL textures e For some demos the snack extension is used e To generate screenshots from the Tcl3D presentation the Twapi extension is needed on Windows therefore recommend to use an actual ActiveTcl distribution 17 which contains all of the above listed Tcl extensions Download and unzip the following distribution packages suitable for your operating system e tcl3d 0S 0 3 2 zip e tcl3d demos 0 3 2 zip Then copy the resulting folders into the appropriate directories as described in the previous chapter 2
25. all this procedure from the reshape callback tcl3dArcBallClick Update start vector and prepare for dragging tcl3dArcBallDrag Update end vector and get rotation as Quaternion See the NeHe demo program Lesson48 tcl for an example on how to use the ArcBall procedures 4 3 tcl3dOgl Wrapper for basic OpenGL functionality This module wraps OpenGL functionality based on OpenGL Version 1 1 as well as the GLU library functions based on Version 1 2 This is due to the fact that Windows still does not support newer versions of OpenGL OpenGL features defined in newer versions have to be accessed via the OpenGL extension mechanism on Windows The shapes of the GLUT library box sphere cylinder teapot with a GLUT compatible syntax are supplied here too Requirements for this module An OpenGL 1 1 compatible library OpenGL header files are contained in the Tcl3D distribution The master SWIG file for wrapping the basic OpenGL library is tel3dOgl i Basic OpenGL library Implementation files tcl3dOgI Util tcl Header files gl h glu h Wrapper files gl i glu i The wrapping for this module is based on the unmodified header files gl h and glu h The following commands are implemented in file te 3dOgI Util tcl Tcl command Description tcl3d0glGetVersion Get the version of the wrapped OpenGL library glMultiDrawElements Procedure to implement the OpenGL function glMultiDrawElements tcl3dGetGlErr
26. ameters Tcl command Description tcl3dVector Create a new Tcl3D Vector by calling the memory allocation routine new_TYPE and create a new Tcl procedure See example below Tcl3D User Manual Version 0 3 2 February 2007 Page 27 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org tcl3dVectorPrint Print the contents of a TclI3D Vector onto standard output tcl3dVectorFromArgs Create a new Tcl3D Vector from given aruments tcl3dVectorFromList Create a new Tcl3D Vector from given Tcl list tcl3dVvectorFromString Create a new Tcl3D Vector from given Tcl string Very slow tcl3dVvectorFromByteArray Create a new Tcl3D Vector from given Tcl binary string tcl3dVvectorFromPhoto Create a new Tcl3D Vector containing the data of a Tk photo image See next chapter for detailled description tcl3dVectorToList Copy the contents of a Tcl3D Vector into a Tcl list tcl3dVvectorToString Copy the contents of a Tcl3D Vector into a string Very slow tcl3dvectorToByteArray Copy the contents of a Tcl3D Vector into a Tcl binary string Note e The tcl3dFromString and tcl3dVectorToString commands can be replaced with the corresponding ByteArray commands which are much faster e For functions converting photos into vectors and vice versa see the next chapter about image manipulation The tcl3dVector command cre
27. ary folder Then copy the dynamic libraries contained in subfolder extlibs OS into a directory which is listed in your PATH environment variable Windows or your LD_LIBRARY_PATH environment variable Unix Tcl3D User Manual Version 0 3 2 February 2007 Page 11 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www ftcl3d org If you want to build the te 3dCg module you have to download the Cg toolkit version 1 5 0015 from 18 After installation copy all the Cg header files into the tel3dCg Cg directory These files are not included because of license issues The dynamic libraries of Cg are included in the Tcl3D distribution package tc13d 0S 0 3 2 zip If you want to wrap only a sub set of the supported optional modules edit the make wrap file appropriately See the chapter 2 2 3 Customization for details Version 3 Tcl3D Star Tcl3D Basic or TclI3D Complete with Starpack support Needed Installation of Version 1 or 2 Needed tcl3d starpack 0 3 2 zip Perform the steps as described for Version 1 or 2 Additionally copy the folder extlibs contained in distribution package tc13d 0S 0 3 2 zip into the source code folder tcel3d Then unzip tcl3d starpack 0 3 2 zip into the source code folder tcl3d Note The starpack distribution package contains Tclkits for all supported operating systems as well as supporting Tcl packages needed for the Tcl3D demonstration programs 2 2 2 St
28. ates a new Tcl procedure with the following subcommands which wrap the low level vector access functions described above Subcommand Description get Get vector element at a given index TYPE_getitem set Set vector element at a given index to supplied value TYPE _setitem setvec Set range of vector elements to supplied value TYPE_setarray addvec Add supplied value to a range of vector elements TYPE_addarray mulvec Muliply supplied value to a range of vector elements TYPE _mularray delete Delete a tcl3dVector delete TYPE The following example shows the usage of the tcl13dVector command set ind 23 set vec tcl3dVector GLfloat 123 Create Vector of size 123 GLfloats Svec set Sind 1017 0 Set element at index 23 to 1017 0 set x Svec get ind Get element at index 23 vec addvec 33 2 10 Add 33 to ten elements starting at index 2 Svec delete Free the allocated memory Note Indices start at zero See the demo program bytearray tcl and vecmanip tcl for examples on how to use the ByteArray procedures for generating textures in Tcl 4 2 5 Image utility module This module provides access to photo images as supplied by Tk The Img extension is recommended to have access to lots of image formats Implementation files tkphoto i Header files None Wrapper files tkphoto i Tcl3D User Manual Version 0 3 2 February 2007 Page 28 of 46 Copyright 2005 2007 b
29. cncntsaanseesczeneanncanssavansatsabsecnases 20 4 2 tcl3dUtil Tel3D utility library 22s cece tteeaiacctedeccasieadedseise cske teedacaneniathedecttchndakaniieetaldante 22 4 3 tcl3dOgl Wrapper for basic OpenGL functionality snnnnnnannnnnneeeeeeeee eer eeeereeeeeeeee 33 4 4 tcl3dOglExt Wrapper for enhanced OpenGL functionality c ccccccceceeeeeeeeeeeeeees 34 4 5 tcl3dCg Wrapper for NVidia s Cg shading language cccceeeeeeeeeeeeeeeeeeeeeeteeeees 35 4 6 tcl3dSDL Wrapper for the Simple DirectMedia Library cccccccccceceeeeeeeeeeeeeeeeees 35 4 7 tcl3dFTGL Wrapper for the OpenGL Font Rendering Library ccccceceeeeeeeeees 36 4 8 tcl3dGl2ps Wrapper for the OpenGL To Postscript Library ccccccccceceeeeeeeeeeeees 36 4 9 tcl3dOde Wrapper for the Open Dynamics Engine ccceccccecceeeeeeeeeeeeeeeeeeeeeee 37 4 10 tcl3dGauges Tcl3D package for displaying QAUGES eeeeeeeeeeeeeeeeeeeeettteeeeeeees 37 4 11 tcl3dDemoUtil C C based utilities for demo applications 0 0 0 0 eeeeeeees 38 5 MISCELLANEOUS TCL3D INFORMATION cccccccceeseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeseees 39 5 1 License IMPOR AMON seiucamnedsasGansi laser aaa iaaa ARE RERE RE aa EEE 39 5 2 Programming FIRMS sscsevesesceceested seeeseusaduestecadeestucaduestecsvusubudaduesbeducueubucsduebeduvuubucadeenadse 39 5 3 Open ISSUBS ins eee a e e ae e aae aa aE E 40 5 4 KNOWN atte de at
30. ctor with 0 0 0 0 0 0 tcl3dVec3f Copy Copy a 3D vector tcl3dVec3fLength Calculate the length of a 3D vector tcl3dVec3 Normalize Normalize a 3D vector tcl3dVec3 Distance Calculate the distance between two 3D vectors tcl3dVec3 DotProduct Calculate the dot product of two 3D vectors tcel3dVec3fCrossProduct Calculate the cross product of two 3D vectors tcl3dVec3 fAdd Add two 3D vectors tcel3dVec3fSubtract Subtract two 3D vectors tcel3dVec3fScale Scale a 3D vector by a scalar value Tcl command Description tcel3dMatfPrint Print the contents of a matrix onto standard output tcl3dMatfidentity Build the identity transformation matrix tcl3dMatfCopy Copy a transformation matrix tcl3dMatfTranslatev Build a translation matrix based on a 3D vector tcl3dMatfTranslate Build a translation matrix based on 3 scalar values tcl3dMatfRotate Build a rotation matrix based on angle and axis tcl3dMatfRotatexX Build a rotation matrix based on angle around x axis tcl3dMatfRotateY Build a rotation matrix based on angle around y axis tcl3dMatfRotateZ Build a rotation matrix based on angle around z axis tcl3dMatfScalev Build a scale matrix based on a 3D vector tcel3dMatfScale Build a scale matrix based on 3 scalar values tcl3dMatfTransformPoint Transform a
31. displayproc displayproc Displayproc tclDisplayFunc oe oe A AnH oP o9 Callback procedures To be usable from the Tcl level it has been extended to support 3 new configuration options for specifying Tcl callback procedures createproc TclCommandName Called when a new widget is created reshapeproc TclCommandName Called when the widget s size is changed displayproc TclCommandName Called when the widget s content needs to be redrawn Default settings are createproc createproc Createproc displayproc displayproc Displayproc reshapeproc reshapeproc Reshapeproc Display options swapinterval Enable disable synchronization to vertical blank signal multisamplebuffers Enable disable the multisample buffer multisamplesamples Set the number of multisamples Default settings are swapinterval swapInterval SwapInterval 1 1 multisamplebuffers multisampleBuffers MultisampleBuffers 0 0 multisamplesamples multisampleSamples MultisampleSamples 2 2 Note Multisampling was not supported by the Togl widget till version 0 3 2 If working with older version of Tcl3D you may enabling multisampling outside of Tcl3D as follows Tcl3D User Manual Version 0 3 2 February 2007 Page 21 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org With NVidia cards you can enable multisampling under Windows via the NVidia
32. dule implements the following commands Tcl command Description tcl3dTbInit Call this initialization procedure before any other trackball procedure tcl3dTbReshape Call this procedure from the reshape callback tcl3dTbMatrix Get the trackball matrix rotation tcl3dTbStartMotion Begin trackball movement tcl3dTbStopMotion Stop trackball movement tcl3dTbMotion Call this procedure from the motion callback tcl3dTbAnimate Call with parameter 1 or GL_TRUE if you want the trackball to continue spinning after the mouse button has been released Call with parameter 0 or GL_ FALSE if you want the trackball to stop spinning after the mouse button has been released See the demo program ftg Demo tcl for an example on how to use the trackball procedures 4 2 10 Virtual ArcBall module This module provides functions for emulating an ArcBall which is the same as a trackball Implementation files tcl3dArcBall c Header files tcl3dArcBall h Wrapper files utili Tcl3D User Manual Version 0 3 2 February 2007 Page 32 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org The ArcBall module implements the following commands Tcl command Description tcl3dNewArcBall Create new ArcBall with given width and height tcl3dDeleteArcBall Delete an ArcBall tcl3dSetArcBallBounds Update mouse bounds for ArcBall C
33. e i The wrapping for this module is based on the unmodified ODE header files ODE utility module Tcl command Description tcl3d0deGetVersion Get the version of the wrapped ODE library See the demo programs contained in directory LibrarySpecificDemos tcl3Ode for examples on how to use the ODE functions 4 10 tcl3dGauges Tcl3D package for displaying gauges This package implements the following gauges airspeed altimeter compass tiltmeter This is an optional module Tcl3D User Manual Version 0 3 2 February 2007 Page 37 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Requirements for this module None all files are contained in the Tcl3D distribution The gauge package has been implemented by Victor G Bonilla See the demo programs gaugedemo tcl and gaugetest tcl for examples on how to use the gauges 4 11 tcl3dDemouUtil C C based utilities for demo applications This package implements several C C based utility functions for some of the demo applications This is an optional module Requirements for this module None all files are contained in the Tcl3D distribution The master SWIG file for wrapping the demo utility library is tel3dDemouUtil i The following submodules are contained in this module Name tcl3dOgliLogo Implementation files tcl3dOglLogo c Header files tcl3dOg iLogo h Wrapper files d
34. ed in the OpenGL core as well as Windows specific extensions The files of this logical building block are contained in the same directory as the basic OpenGL wrapper files for practial compilation reasons This is an optional module Requirements for this module An OpenGL compatible library OpenGL header files are contained in the Tcl3D distribution To have access to all wrapped features the OpenGL library should support Version 2 0 The master SWIG file for wrapping the enhanced OpenGL library is tcl3dOgI i Implementation files See subdirectory OglExt Header files glext h glprocs h Wrapper files glext i wglext i The wrapping for OpenGL functions greater 1 1 and the OpenGL extensions is defined in file glext i and based on the header file glext h This header file is part of Og Ext 24 an OpenGL extension library from the research center caesar It has been slightly modified to fit the Tcl3D needs The wrapping of Windows specific OpenGL functions is defined in file wglext i and based on the header file glprocs h from Intel s GLsdk 25 library The GLsdk is an extension library similar to the OglExt library It has been stripped down to only use the Windows specific OpenGL functions Tcl3D User Manual Version 0 3 2 February 2007 Page 34 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org If using functions from this module be sure to add a call to tcl3dIni
35. emoutil i tcl3dOglLogo implements an animated 3 dimensional OpenGL logo It is used in demo animlogo tel in directory LibrarySpecificDemos tcl3dOgl Name tcl3dReadRedBooklmg Implementation files tcl3dReadRedBooklmg c Header files tcl3dReadRedBooklmg h Wrapper files demoutil i tcl3dReadRedBooklmg implements a parser for the simple image file format used in some of the RedBook demos It is used in demos colormatrix tcl colortable tcl convolution tcl histogram tcl and minmax tcl in directory TutorialsAndBooks RedBook Name tcl3dHeightmap Implementation files heightmap i tcl3dHeightMap tcl Header files None Wrapper files heightmap i tcl3dHeightmap implements a photo image to heightmap converter It is used in NeHe demo Lesson45 tcl in directory TutorialsAndBooks NeHe Tcl3D User Manual Version 0 3 2 February 2007 Page 38 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 5 Miscellaneous Tcl3D information This chapter contains various information about Tcl3D 5 1 License information The Tcl3D utility library files see below for exceptions are copyrighted by Paul Obermeier and distributed under the BSD license The following files of the Tcl3D utility library have differing copyrights The original Wavefront parser code is copyrighted by Nate Robins The original GLUT shape code is copyrighted by Mark Kilgard The original
36. eneee esate en canese es ea eces dade cteceeae aAa nan cteiaaaaceei dad etedeeaaeeeta nAeeeeheaeeeusaace 40 5 5 Sta pack internals winssinsinsuhiteidtieuhinniauiredtauiindiauirentingied 40 6 DEMO APPLICATIONS vsisexcxesscecscesdiecdvesscersiesssesduetscenstendd endustsceneissaansdueticenetenddendeesaienedeias 42 T RELEASE NOUS sciccciicieinierasscieeieieonsiieeienaneiniansieeeneeds 43 EG oll Sl G 2 a ee ee ee 46 Tcl3D User Manual Version 0 3 2 February 2007 Page 1 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 1 Introduction Tcl3D enables the 3D functionality of OpenGL and various other portable 3D libraries at the Tcl scripting level It s main design requirement is to wrap existing 3D libraries without modification of their header files and with minimal manual code writing The Tcl API should be a direct mapping of the C C based library API s with a natural mapping of C types to according Tcl types This is accomplished with SWIG 12 the Simplified Wrapper and Interface Generator Tcl3D is based on ideas of Roger E Critchlow who formerly created an OpenGL Tcl binding called Frustum 2 1 1 Architecture overview The Tcl3D package currently consists of the following building blocks also called modules throughout the manual Tcl3D core modules tcl3dTogl Enhanced Togl widget a Tk widget for displaying OpenGL conte
37. ep 2 Configuration Before compiling edit the appropriate config_ file to fit your platform compiler combination Operating system Compiler Configuration file Windows Visual C 6 0 7 1 8 0 config _win32 Windows CygWin gcc config _cygwin Windows MinGW gcc config _msys Linux gcc config Linux Mac OS X gcc config Darwin SGI IRIX 6 5 gcc MIPS Pro 7 3 config_IRIX64 Note For Unix systems the name after the underscore is the name derived from the Unix command uname The following lines in the config_ files may be edited WITH_DEBUG If you don t want debug information remove ALL characters after the equal sign INSTDIR Set to your prefered installation directory TCLDIR Set to where your Tcl installation is TCLMINOR Set to your installed Tcl version Examples Compile with debugging information The Tcl installation is located in usr local We install the Tcl3D package into the same location as the Tcl distribution The installed Tcl version is 8 4 WITH DEBUG 1 INSTDIR usr local TCLDIR usr local TCLMINOR 4 Compile without debugging information The Tcl installation is located in C Programme Tcl We install the TclI3D package into a separate directory The installed Tcl version is 8 4 WITH DEBUG INSTDIR C Programme Tcl TCLDIR C Programme poSoft TCLMINOR 4 Tcl3D User Manual Version 0 3 2 February 2007 Page 12 of 46
38. es The Cg types are handled accordingly GLenum as function input parameter can be supplied as numerical value or as name Tcl3D User Manual Version 0 3 2 February 2007 Page 15 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Input parameter GLenum C declaration void glEnable GLenum cap C example glEnable GL BLEND glEnable GL_BLEND Tcl example glEnable GL_ BLEND GLbitfield as function input parameter can be supplied as numerical value or as name Note A combination of bit masks has to be specified as a numerical value like this glClear expr GL_ COLOR BUFFER_BIT GL_ DEPTH BUFFER_BIT Input parameter GLbitfield C declaration void glClear GLbitfield mask C example glClear GL COLOR BUFFER BIT glClear GL COLOR BUFFER BIT Tel example glClear GL COLOR BUFFER BIT GLboolean as function input parameter can be supplied as numerical value or as name Input parameter GLboolean C declaration void glEdgeFlag GLboolean flag C example glEdgeFlag GL_TRUE glEdgeFlag GL_TRUE glEdgeFlag GL_TRUE Tcl example 3 1 2 Pointer input parameters The mapping of const TYPE pointers is handled in file tel3dPointer i Constant pointers as function input parameter must be supplied as a Tcl list Input parameter const TYPE SIZE const TY
39. f 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Requirements for this module None all files are contained in the Tcl3D distribution The master SWIG file for wrapping the Simple DirectMedia library is tel3dG 2ps i Implementation files g 2ps c tcl3dG 2psUtil tcl Header files gl2ps h Wrapper files gl2ps i The wrapping for this module is based on the unmodified GL2PS implementation and header files GI2ps utility module Tcl command Description tcl3dGl2psGetVersion Get the version of the wrapped GL2PS library tcl3dGl2psCreatePdf Create a PDF file from current Togl window content See NeHe demo Lesson02 tc l or the benchmarking demo sphere tcl in directory LibrarySpecificDemos tcl3dOgI for an example on how to use the GL2PS functions for PDF export 4 9 tcl3dOde Wrapper for the Open Dynamics Engine This module wraps the ODE 23 library based on version 0 7 and adds some ODE related utility procedures Note This module is still work in progress It s interface may change in the future This is an optional module Requirements for this module The ODE library and header files Libraries and header files are included in distribution The master SWIG file for wrapping the Open Dynamics Engine library is tel3dOde i Implementation files None Header files All files in subdirectory ode Wrapper files od
40. found on the web A detailed list of all demos is available online on the Tcl3D homepage at http www tcl3d org demos or in the Tcl3D Demo Manual The Tcl3D demo applications are divided into 3 categories e Category Tutorials and books contains scripts which have been converted from C C to Tcl3D coming from the following sources OpenGL Red Book 8 NeHe tutorials 4 Kevin Harris CodeSampler web site 5 Vahid Kazemi s GameProgrammer page 6 e Category Library specific demos contains scripts showing features specific to the wrapped library e Category Tcl3D specific demos contains scripts demonstrating and testing Tcl3D specific features The next figure shows an excerpt from the demo hierarchy Tcl3D Demo Hierarchy i Jo ox Categories LibrarySpecificDemos Tcl3DSpeciticD emos TutorialsAndBooks Tye Bx AAEE LibrarySpecificDemos teiue TutorialsAndBooks Demo scripts CodeS ampler GameProgrammer bytearray tcl NeHe imaViewer tcl tel3dinfo tel Hedi ook vectormanip tcl i i Li ileo olx ilee olx ilo alx iea alx v CodeS ampler GameProgrammer NeHe RedBook Demo scripts Demo scripts Demo scripts Data s ogl_benchmark_sphere t GL_Blending tel Lesson01 tel Demo scripts ogl_fps_controls tcl GL_Envmap tcl Lesson02 tel aapoly tcl N ogl_glslang_simple_vs2p GL_Font tel Lesson03 tcl aapolyStride tcl ogl_point_sprites tcl GL_Lighting tcl Lesson04 tcl aargb tcl ogl_skinning tel GL_Moti
41. glHeight which is needed in command SaveImg can be saved in a global variable when the reshape callback is executed See the NeHe demo program Lesson41 tcl or any demo using textures for examples on how to use photo utilities 4 2 6 Screen capture module This module implements functions for capturing window contents into an image file or the clipboard Note All of the functionality requires the help of the Img extension Some of the functionality requires the help of the Twapi extension and is therefore available only on Windows Implementation files tcl3dCapture tcl Header files None Wrapper files None In file tecl3dCapture tcl the following Tcl procedures are implemented Tcl command Description tcl3dWidget2Img Copy contents of a widget and all of its sub widgets into a photo image tcl3dWidget2File Copy contents of a widget and all of its sub widgets into a photo image and save the image to a file tcl3dCanvas2Img Copy the contents of a Tk canvas into a photo image tcl3dCanvas2File Copy the contents of a Tk canvas into a photo image and save the image to a file tcl3dClipboard2Img Copy the contents of the Windows clipboard into a photo image tcl3dClipboard2File Copy the contents of the Windows clipboard into a photo image and save the image to a file tcl3dImg2Clipboard Copy a photo into the Windows clipboard tcl3dWindow2Clipboard Copy the contents of the top level window Alt
42. i GL TEXTURE 2D GL TEXTURE WRAP S GL REPEAT you will get an error message like this expected integer but got GL_REPEAT Hint 2 Most OpenGL examples written in C use the immediate mode As Tcl is a scripted language and each OpenGL call has to go through the wrapper interface it s almost always a bad idea in terms of speed to translate these examples one by one Using display lists or vertex arrays does not add much complexity to your Tcl3D program but enhances performance significantly Try the Spheres tcl or og _benchmark_sphere tcl demo for an example how display lists or vertex arrays can speed up your TclI3D application Tcl3D User Manual Version 0 3 2 February 2007 Page 39 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Hint 3 Do not use global variables GL_VERSION_X_Y ex info exists GL_VERSION_1_3 to check the OpenGL version supported on your computer This does not work because these variables are defined in the range 1_1 till 2 0 in Tcl3D Use the utility function tcl3dHaveExtension instead 5 3 Open issues e 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 e There is currently no possibility to specify a color map for OpenGL indexed mode As color maps depend on the underlying windowing system thi
43. il 1 0 3 2 tcl3dftgl 0 FTGL library not wrapped tcl3dgauges 1 0 3 2 tcl3dgl2ps 0 gl2ps library not wrapped tcl3dode 0 ODE library not wrapped tcl3dogl 1 0 3 2 tcl3dsdl 0 SDL library not wrapped tel3dtogl 1 0 3 2 tcl3dutil 1 0 3 2 Version Tc 3D Complete should print out the following lines when calling tcl13dGet PackageInfo tcl3dcg 1 0 3 2 1 5 0015 tcl3ddemoutil 1 tcl3dftgl 1 0 tcl3dgauges 1 tcl3dgl2ps 1 322 tcl3dode 1 0 3 2 0 7 0 tcl3dogl 1 0 3 2 tcl3dsdl 1 0 3 2 1 2 9 tcel3dtogl 1 0 3 2 tcl3dutil 1 0 3 2 2 3 Extending Tcl3D 2 3 1 Extending with a Tcl utility 3 QO mmnm mnnm 2 3 2 Extending with a C C utility 2 3 3 Extending with a newer version of an external library 2 3 4 Extending with a new external library Tcl3D User Manual Version 0 3 2 February 2007 Page 14 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 3 Wrapping in detail This chapter explains how parameters and return values of the C and C based library functions are mapped to Tcl command parameters and return values The intention of the wrapping mechanism was to be as close to the C interface and use Tcl standard types wherever possible e C functions are mapped to Tcl commands e Cconstants are mapped to Tcl global variables e Some C e
44. lant regular italic size PixelSize Examples Stoglwin loadbitmapfont courier bold r 10 Stoglwin loadbitmapfont family fixed size 12 weight medium slant regular See the tcl3dToglFonts tcl and tcl3dFont tcl demos for more examples on how to use fonts with Togl Tcl3D User Manual Version 0 3 2 February 2007 Page 20 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 4 1 2 Togl options The following is a list of currently available Togl options The options changed or new in Tcl3D are marked bold and explained in detail below For a description of the other options see the original Tog documentation height width setgrid rgba redsize greensize bluesize double depth depthsize accum accumredsize accumgreensize accumbluesize accumalphasize alpha alphasize stencil stencilsize auxbuffers privatecmap overlay stereo cursor time sharelist sharecontext ident indirect pixelformat swapinterval multisamplebuffers multisamplesamples createproc displayproc reshapeproc These configuration options behave like standard Tcl options and can be queried as such package require tcl3d or just package require tcl3dtogl ods 2 togl t t configure height height Height 400 400 displayproc displayproc Displayproc t configure displayproc tclDisplayFunc t configure displayproc
45. manufacturer of your graphic card especially if intending to write shader programs in GLSL or Cg Download unzip and start a Tcl3D starpack presentation as described in chapter 1 4 In the right menu pane you will see 3 buttons in the Installation and Information menu These allow you to extract the Tcl3D packages the external libraries and the demo programs onto the file system so you can use TclI3D from tclsh or wish Tcl3D User Manual Version 0 3 2 February 2007 Copyright 2005 2007 by Paul Obermeier All rights reserved Page 9 of 46 Tcl3D Doing 3D with Tcl www tcl3d org e The Tcl3D package folder tc 3d0 3 2 should be copied into the library section of your Tcl installation ex C Tcllib If write access to this Tcl directory is not permitted you can copy the tcl3d0 3 2 directory somewhere else eg C mytcl3d or home user mytcl3d To have Tcl look for packages in this location you must set the TCLLIBPATH environment variable with the above specified directory name as value Note that on Windows the path must be written with slashes not backslashes set TCLLIBPATH C mytcl3d e The files contained in the external libraries folder extlibs should be copied into a directory which is listed in your PATH environment variable Windows or your LD_LIBRARY_PATH environment variable Unix e The demonstration programs folder demos can be copied to any convenient place of your file system Now you are re
46. mode specified glmList Generates and returns a display list for the model using the mode Tcl3D User Manual Version 0 3 2 February 2007 Page 31 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org specified glmWeld Eliminate weld vectors that are within an epsilon of each other See the demo program gaugedemo tcl for an example on how to use these procedures The tcl3dShapes files implement a sphere based on an algorithm found at Paul Bourke s excellent pages 10 as well as a cube and a helix based on algorithms found in the NeHe tutorials 23 and 36 4 Tcl command Description tcl3dCube Draw a textured cube with given center and size tcl3dHelix Draw a helix with given center radius and number of twists tcl3dSphere Draw a sphere with given radius precision See NeHe demo program Lesson23 tcl for an example on how to use tc13dCube See NeHe demo program Lesson36 tcl for an example on how to use tc13dHelix See demo program ogl_benchmark_sphere tcl for an example on how to use tc13dSphere Note The standard GLUT shapes are implemented in module tcl3dOgl see chapter 4 3 4 2 9 Virtual trackball module This module provides functions for emulating a trackball Implementation files tcl3dTrackball c tcl3dTrackball tcl Header files tcl3dTrackball h Wrapper files utili The trackball mo
47. module wraps the SDL 19 library based on version 1 2 9 and adds some SDL related utility procedures Currently only the functions related to joystick and CD ROM handling have been wrapped and tested This is an optional module A detailled description of this module can be found in chapter 4 6 1 2 7 tcl3dFTGL Wrapper for the OpenGL Font Rendering Library This module wraps the FTGL 20 library based on version 2 1 2 and adds some FTGL related utility procedures Tcl3D User Manual Version 0 3 2 February 2007 Page 4 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org The following font types are available e Bitmap font 2D Pixmap font 2D Outline font Polygon font Texture font Extruded font This is an optional module A detailled description of this module can be found in chapter 4 7 1 2 8 tcl3dGl2ps Wrapper for the OpenGL To Postscript Library This module wraps the GL2PS 22 library based on version 1 3 2 and adds some GL2PS related utility procedures GL2PS is a C library providing high quality vector output PostScript PDF SVG for any OpenGL application This is an optional module A detailled description of this module can be found in chapter 4 8 1 2 9 tcl3dOde Wrapper for the Open Dynamics Engine This module wraps the OpenSource physics engine ODE 23 based on version 0 7 and adds some ODE related utility procedures This is an
48. nfo 1 GL_VENDOR NVIDIA Corporation GL_RENDERER GeForce FX Go5600 AGP SSE2 Tcl3D User Manual Version 0 3 2 February 2007 Page 24 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org GL VERSION 1 4 0 GLU_VERSION 1 2 2 0 Microsoft Corporation The following code snippet shows how to call tcl3dGetExtensions foreach glInfo tcl3dGetExtensions puts lindex glInfo 0 foreach ext lsort lindex glInfo 1 puts tS ext GL_EXTENSIONS GL_ARB depth texture GL_ARB fragment program GL_ARB imaging GLU_EXTENSIONS GL_EXT_bgra The following code snippet shows how to call tcl3dGetStates foreach glState tcl3dGetStates set msgStr lindex glState 2 lrange glState 3 end if lindex glState 0 0 set tag Unsupported else set tag append msgStr Stag puts SmsgStr GL_VERTEX ARRAY SIZE 4 GL_VERTEX ARRAY TYPE 5126 GL_VERTEX ARRAY STRIDE 0 GL_VERTEX ARRAY POINTER Unsupported GL_NORMAL ARRAY 0 GL_ NORMAL ARRAY TYPE 5126 See the demo program tcl3dinfo tcl for other examples on how to use these procedures 4 2 3 Color names module This module provides miscellaneous OpenGL related functions Implementation files tcl3dColors tcl Header files None Wrapper files None Tcl command Description tcl3dGetColorNames Return a list of all supported Tcl col
49. nt tcl3d Util Tcl3D utility library math functions shapes stop watch et al tcl3dOgl Wrapper for basic OpenGL functionality GL Version 1 1 GLU Version 1 2 Tcl3D optional modules tcl3dOglExt Wrapper for enhanced OpenGL functionality GL Version 1 2 through 2 0 and OpenGL extensions tcl3dCg Wrapper for NVidia s Cg shading language tcl3dSDL Wrapper for the Simple DirectMedia Library tcl3dFTGL Wrapper for the OpenGL Font Rendering library tcl3dGl2ps Wrapper for the OpenGL To Postscript library tcl3dOde Wrapper for the Open Dynamics Engine tcl3dGauges_ Tcl3D package for displaying gauges tcl3dDemouUtil C C based utility functions for some of the demo applications Each module is implemented as a separate Tcl package similar to the Tcl standard library Tcllib All TcI3D subpackages can be loaded with a single package require tcl3d tcl3dcg tcl3dDemoutil tcl3dFTGL tcl3dGauges Cotelsdelzps F glutShapes tel tclsdode f oglmisc tel Cotclsdogl pkalndex tel ead tcl3dogl dll tcl3dTog tel3d util pkgIndex tcl Tcl3D User Manual Version 0 3 2 February 2007 Page 2 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org The next figure shows the currently available modules of Tcl3D The Tcl3D Modules Tcl3D Demos and Applications tcl3dUtil tcl3dGauges Tcl based Utilities Tcl Extension Package
50. numerations are mapped to Tcl global variables and are inserted into a Tcl hash table for lookup by name 3 1 Wrapping description Conventions used in this chapter e Every type of parameter is explained with a typical example from the OpenGL wrapping e The notation TYPE stands for any scalar value char int float enum etc as well as inherited scalar types like GLboolean GLint GLfloat etc It is not used for type void or GLvoid e The notation struct stands for any C struct e The decision how to map C to Tcl types was mainly inspired to fit the needs of the OpenGL library best The same conventions are used for the optional modules too 3 1 1 Scalar input parameters The mapping of most scalar types is handled by SWIG standard typemaps Scalar types as function input parameter must be supplied as numerical value Input parameter TYPE C declaration void glTranslatef GLfloat x GLfloat y GLfloat z glTranslatef 1 0 2 0 3 0 glTranslatef x y Z glTranslatef 1 0 2 0 3 0 glTranslatef x Sy z C example Tcl example The mapping of the following enumerations is handled differently see file tcl3dConstHash i They can be specified either as numerical value like the other scalar types or additionally as a name identical to the enumeration name e GLboolean GLenum GLbitfield CGenum CGGLenum CGprofile CGtype CGresource e cCGerror The mapping is explained using the 3 OpenGL typ
51. omepage http www tcl3d org 15 Tcl3D page on the Tclers Wiki http wiki tcl tk 15278 16 Tcl3D discussion page on the Tclers Wiki http wiki tcl tk 16057 17 Tcl download http www activestate com 18 Cg download http developer nvidia com object cg_toolkit html 19 SDL download http www libsdl org 20 FTGL download http nomepages paradise net nz henryj code index html 21 Freetype download http www freetype org 22 GL2PS download http www geuz org gl2ps 23 ODE download http www ode org 24 OglExt Julius Caesar http www julius caesar de index php OgIExt 25 GLsdk library http oss sgi com projects ogl sample sdk html 26 OpenGL Extension Registry http Awww opengl org registry 27 Starpack Wiki page http wiki tcl tk 3663 Tcl3D User Manual Version 0 3 2 February 2007 Page 46 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved
52. onblur tcl Lesson05 tcl accanti tcl ogl_vertex_displacement GL_Primitives tel Lesson06 tcl accpersp tcl Tcl3D User Manual Version 0 3 2 February 2007 Copyright 2005 2007 by Paul Obermeier All rights reserved Page 42 of 46 Tcl3D Doing 3D with Tcl www tcl3d org 7 Release notes This chapter shows the release and feature history of Tcl3D both graphically and in text form Tcl3D Version 0 1 Released 2005 05 29 as TclOgl Basic OpenGL wrapping Tog widget with Tcl callbacks Tcl3D Demos and Applications tel3dUtil i Tol based Utilities SWIG generated Tcl interfaces H Tcl Interface tel3dUtil tcl3dOgl tcl3dTog C based Utilities Basic OpenGL OpenGL Widget Tcl3D Version 0 2 Released 2006 01 07 Major rewrite and support of new libraries OpenGL 2 0 OpenGL extensions Cg SDL gauges Domain created Tcl3D Demos and Applications tcl3dUtil tel3dGauges ___ Tel based Utilities __ Tel Extension Package SWIG generated Tcl interfaces TchInterface C tel3dUtil tcl3dOgl tel3dOglExt tcl3dTogl C based Utilities Basic OpenGL Extended OpenGL OpenGL Widget i tel3dCg tcl3dSDL Nvidia s Cg Joystick Tcl3D Version 0 3 Released 2006 02 12 Enhanced font handling in Togl Library FTGL added Mac OS X support supplied by Daniel Steffen Tcl3D Demos and Applications tcl3dUtil s tei3dGauges Tcl based Utilities Tcl Extension Package SWIG generated Tcl interfaces Tcl Interface
53. ontaining the Starpack Copy them to the filesystem if necessary set _tcl3dExecDir file dirname starkit topdir set tcl3dD11lList glob nocomplain dir file join starkit topdir extlibs info sharedlibextension foreach starkitName tcl3dDllList set osName file join _tcl3dExecDir file tail S starkitName if file exists osName set retVal catch file copy force starkitName tcl3dExecDir puts Copying DLL starkitName to directory _ tcl3dExecDir if retVal 0 error Error copying DLL starkitName to directory tcl3dExecDir Tcl3D User Manual Version 0 3 2 February 2007 Page 40 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org This aforementioned solution seems to be the best possible solution today but has the following two disadvantages e Windows user will typically place the Starpack onto the desktop Starting the Starpack inflates the desktop with lots of DLL s e On Linux Unix the current directory typically is not included in the LD_LIBRARY_PATH variable That s why the starpacks are distributed in it s own folder and the Unix distributions come with an additional start shell script tc13dsh OS VERSION sh bin sh Startup script for tcl3dsh the Tcl3D Starpack LD LIBRARY PATH LD LIBRARY PATH LD LIBRARYN32_PATH LD_LIBRARYN32_ PATH export LD_LIBRARY_PATH export LD LIBRARYN
54. optional module Note This module is still work in progress It s interface may change in the future A detailled description of this module can be found in chapter 4 9 1 2 10 tcl3dGauges Tcl3D package for displaying gauges This package implements the following gauges as a pure Tcl package airspeed altimeter compass tiltmeter This is an optional module A detailled description of this module can be found in chapter 4 10 1 2 11 tcl8dDemouUtil C C based utilities for demo applications This package implements several C C based utility functions for some of the demo applications This is an optional module A detailled description of this module can be found in chapter 4 11 Tcl3D User Manual Version 0 3 2 February 2007 Page 5 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 1 3 Supported platforms The following table gives an overview which modules are available on the supported operating systems It also tries to give an indication on the quality of the module Windows 32 bit Linux 32 bit Mac OS X Intel IRIX 6 5 n32 Module Wrap Test Wrap Test Wrap Test Wrap Test tcl3dTogl tel3duUtil tcl3do0gl tcl3d0glExt tcl3dCcg
55. or GLfloat 2 lGetFloatv GL LINE WIDTH GRANULARITY Svalues Tcl example set vec tcl3dVector GLubyte expr w Sh 3 glReadPixels 0 0 w h GL RGB GL UNSIGNED BYTE Svec 3 1 4 Function return values The mapping of return values is handled by the SWIG standard typemaps Scalar return values are returned as the numerical value Pointer to structs are returned with the standard SWIG mechanism of encoding the pointer in an ASCII string Tcl3D User Manual Version 0 3 2 February 2007 Page 17 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Function return TYPE STRUCT GLuint glGenLists GLsizei range C declaration GLUnurbs gluNewNurbsRenderer void GLuint sphereList glGenLists 1 C example GLUnurbsObj theNurb gluNewNurbsRenderer gluNurbsProperty theNurb GLU SAMPLING TOLERANCE 25 0 set sphereList glGenLists 1 Tcl example set theNurb gluNewNurbsRenderer gluNurbsProperty theNurb GLU SAMPLING TOLERANCE 25 0 The next lines show an example of SWIG s pointer encoding set theNurb gluNewNurbsRenderer puts StheNurb _10fa1500_ p GLUnurbs The returned name can only be used in functions expecting a pointer to the appropriate struct 3 1 5 Exceptions from the standard rules The GLU library as specified in header file glu h does not provide an API that is using the const
56. or Procedure to find out if an OpenGL error has been occurred GLUT shapes library Implementation files glutShapes c glutTeapot c glutShapes tcl Header files glutShapes h Wrapper files tcl3dOgI i The shapes library consists of the C files glutTeapot c for the teapot glutShapes c for all other shapes and the common header file glutShapes h and the Tcl file glutShapes tcl Tcl3D User Manual Version 0 3 2 February 2007 Page 33 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org The GLUT shape objects are available under identical names for porting test and demonstration programs to Tcl3D These shapes are used extensively in the examples of the OpenGL redbook 1 See there for a description of the functions and its parameters Solid shapes Wire shapes glutSolidCone glutWireCone glutSolidCube glutWireCube glutSolidDodecahedron glutWireDodecahedron glutSolidIcosahedron glutWireIcosahedron glutSolidOctahedron glutWireOctahedron glutSolidSphere glutWireSphere glutSolidTeapot glutWireTeapot glutSolidTetrahedron glutWireTetrahedron glutSolidTorus glutWireTorus All supported GLUT shapes Demo glutShapes tc 4 4 tcl3dOgliExt Wrapper for enhanced OpenGL functionality This module wraps OpenGL functionality based on versions 1 2 till 2 0 lots of OpenGL extensions not contain
57. or names tcl3dFindColorName Check if supplied color name is a valid Tcl color name tcl3dName2rgb Convert a Tcl color specification into the corresponding OpenGL representation OpenGL colors are returned as a list of 3 unsigned bytes r g b tcl3dName2rgbf Convert a color specification into the corresponding OpenGL representation OpenGL colors are returned as a list of 3 floats in the range 0 1 rgb Tcl3D User Manual Version 0 3 2 February 2007 Page 25 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org tcl3dName2rgba Convert a color specification into the corresponding OpenGL representation OpenGL colors are returned as a list of 4 unsigned bytes rgba tcl3dName2rgbaf Convert a color specification into the corresponding OpenGL representation OpenGL colors are returned as a list of 4 floats in the range 0 1 rgba See the test program colorNames tcl for examples on how to use these procedures 4 2 4 Large data module This module provides miscellaneous functions for handling large data like images used for textures and vertex arrays Implementation files tcl3dVector tcl Header files None Wrapper files tcl3dArrays i bytearray i Low level access As stated in chapter 3 1 2 some of the OpenGL functions need a pointer to a contiguous block of allocated memory SWIG already provides a feature to automatically
58. ord This list will be the return value of the corresponding Tcl command Definition in glu h Redefinition in SWIG interface file glu i extern GLint gluUnProject GLint gluUnProject GLdouble winx GLdouble winY GLdouble winx GLdouble winY GLdouble winZ GLdouble winZ Tcl3D User Manual Version 0 3 2 February 2007 Page 18 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org const GLdouble model const GLdouble model const GLdouble proj const GLdouble proj const GLint view const GLint view GLdouble objxX GLdouble OUTPUT GLdouble objY GLdouble OUTPUT GLdouble objZ GLdouble OUTPUT Example usage see Redbook example unproject tcl for complete code glGetIntegerv GL VIEWPORT Sviewport glGetDoublev GL MODELVIEW MATRIX Smvmatrix glGetDoublev GL PROJECTION MATRIX Sprojmatrix set viewList tcl3dVectorToList viewport 4 set mvList tcl3dVectorToList Smvmatrix 16 set projList tcl3dVectorToList Sprojmatrix 16 set realy expr Sviewport get 3 Sy 1 set winList gluUnProject x S realy 0 0 mvList S projList viewList puts gluUnProject return value lindex winList 0 puts format World coords at z 0 0 are f f f lindex S winList 1 lindex SwinList 2 lindex SwinList 3 Note The above listed exceptions are only valid for the GLU library The optional modules have no
59. port Unification of demo applications and presentation framework New module tcl3dDemoUtil for C C based utility functions needed by some of the demos for speed issues More NeHe tutorials added Lessons 14 22 24 26 28 33 36 37 Nine demos from www GameProgrammer org added Updated Tcl3D manual Created separate demo reference Added support to capture screenshots Module tcl3dCapture Tcl3D User Manual Version 0 3 2 February 2007 Page 43 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org Added new functionality to tcl3dUtil ArcBall emulation Added windowing system specifics SwapInterval Multisampling to the tcl3dTogl widget Added support for Visual Studio 2003 7 1 and 2005 8 0 Enhanced tcl3dVector functionality e Utility functions for manipulation of image data stored in tcl3dVectors tcl3dVectorCopy tcl3dVectorCopyChannel tcl3dVectorManip tcl3dVectorManipChannel e tcl3dVector member functions for content independent manipulation setvec addvec mulvec gt tcl3dOde now uses ODE version 0 7 and is available for Windows Linux Mac OS X and IRIX Wrapper still in alpha version and not complete gt tcl3dGl2ps now uses GL2PS version 1 3 2 gt tcl3dCg now uses Cg version 1 5 0015 The 1 4 versions of Cg did not work with OS X on Intel platforms VV VV 2006 06 19 0 3 1 Starpack support for Tcl3D
60. rammer page e Tcl3D specific demos contains scripts demonstrating and testing Tcl3D specific features Some notes about the demos contained in the Starpack Depending on your operating system graphics card and driver some of the programs may raise an error message or will not work properly As the demos contained within the Starpack were written to be standalone programs no error recovery was implemented The programs typically just quit This is why you may get a confirmation window from time to time asking you if you want to quit the show In most cases you may proceed with other demos but be warned that strange effects may occur Tcl3D User Manual Version 0 3 2 February 2007 Page 8 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 2 Installation Precompiled packages for Windows Linux Intel based Mac OS X and IRIX the source code of the Tcl3D package as well as test and demonstration programs can be retrieved from the download section of the TclI3D home page 14 Please report problems or errors to info tcl3d org The following distribution packages are currently available Which packages are needed depends on the proposed usage See the next chapters for detailed information Documents Tcl3D Manual VERSION pdf Tcl3D user manual this document Tc13D DemoRef VERSION pdf Tcl3D demo programs reference Demos
61. s feature must be handled by the Tog widget 5 4 Known bugs e The tiltmeter widget from the tcl3dGauge package is not working correctly with Tcl versions less than 8 4 7 because of a bug in the namespace implementation e 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 1 As Tcl only supports signed integers some depth values are incorrectly transferred into the Tcl commands e SWIG versions up to 1 3 24 had an annoying but not critical bug in the Tcl library file swigtcl8 swg Please check if your version has a line printf Searching s n key in function SWIG_Tcl_GetConstant and delete this line if existent swigtcl8 swg can be found in usr lib swig1 3 tcl or usr share swig VERSION tcl on Linux or in the lib tcI subdirectory of your SWIG Windows installation e SWIG version 1 3 21 as delivered with SUSE 9 3 does not correctly wrap the ODE library 5 5 Starpack internals For an introduction to Tclkits Starkits and Starpacks see Jean Claude Wippler s homepage at http www equi4 com 5 5 1 Starpack problem 1 If shipping external libraries with your Starpack you have to copy them to the file system before they can be used Best place is the directory containing the Starpack Check if all necessary external libraries exists in the directory c
62. s module This module provides functions for reading 3D models from files and creating basic shapes Implementation files tcl3dModel c tcl3dModelFmtObj c tcl3dShapes c Header files Wrapper files tcl3dModel h tcl3dModelFmtObj h tcl3dShapes h util i The tcl3dModel and tcl3dModelFmtObj files provide a parser for reading model files in Alias Wavefront format The code to read and draw the models is a modified version of the parser from Nate Robin s OpenGL tutorial 7 Tcl command Description glmUnitize Unitize a model by translating it to the origin and scaling it to fit in a unit cube around the origin glmDimensions Calculates the dimensions width height depth of a model glmScale Scales a model by a given amount glmReverseWinding Reverse the polygon winding for all polygons in this model glmFacetNormals Generates facet normals for a model glmVertexNormals Generates smooth vertex normals for a model glmLinearTexture Generates texture coordinates according to a linear projection of the texture map glmSpheremapTexture Generates texture coordinates according to a spherical projection of the texture map gimDelete Deletes a GLMmodel structure glmReadOBJ Reads a model description from a Wavefront OBJ file glmWriteOBJ Writes a model description in Wavefront OBJ format to a file gimDraw Renders the model to the current OpenGL context using the
63. t been analysed in depth regarding the constness of parameters 3 2 Wrapping reference card e The notation TYPE stands for any scalar value char int float etc as well as inherited scalar types like GLboolean GLint GLfloat etc It is not used for type void or GLvoid e The notation STRUCT stands for any C struct C parameter type Tcl parameter type Input parameter TYPE Numerical value GLboolean Numerical value or name of constant GLenum Numerical value or name of constant GLbitfield Numerical value or name of constant CGenum Numerical value or name of constant cGGLenum Numerical value or name of constant CGprofile Numerical value or name of constant CGtype Numerical value or name of constant CGresource Numerical value or name of constant CGerror Numerical value or name of constant const TYPE SIZE Tcl list const TYPE Tcl list const void tcl3dVector Output parameter TYPE tcl3dVector void tcl3dVector Return value TYPE Numerical value STRUCT SWIG encoded pointer to struct Tcl3D User Manual Version 0 3 2 February 2007 Page 19 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 4 Modules in detail This chapter explains in detail the different modules Tcl3D is currently built upon e tcl3dTogl Enhanced Togl widget tcl3dUtil
64. t in the create callback This initialization is necessary due to a bug in the Og Ext library See the demo program extensions tcl for an example on how to use OpenGL extensions 4 5 tcl3dCg Wrapper for NVidia s Cg shading language This module wraps NVidia s Cg 18 library based on version 1 5 0015 and adds some Cg related utility procedures This is an optional module Requirements for this module The Cg library and header files Libraries are included in distribution The master SWIG file for wrapping the Cg library is tel3dCg i Implementation files tcl3dCgUtil tcl Header files All files in subdirectory Cg Wrapper files cg i The wrapping for this module is based on the unmodified Cg header files Cg utility module Tcl command Description tcl3dCgGetVersion Get the version of the wrapped Cg library tcl3dGetCgError Check if a Cg related error has occured tcl3dGetCgProfileList Get a list of Cg profile names tcl3dFindCgProfile Find the first profile supported by the Cg implementation from the supplied profile names tcl3dFindCgProfileByNum Find a profile name by it s numerical value tcl3dPrint ProgramInfo Print the Cg program information onto standard output See the demo programs contained in directory LibrarySpecificDemos tcl3dCg for examples on how to use the Cg functions 4 6 tcl3dSDL Wrapper for the Simple DirectMedia Library This module wraps
65. t parameter const void SIZE const void C decl ti void glVertexPointer GLint size GLenum type eciaration GLsizei stride const GLvoid ptr static GLint vertices 25 25 100 3255 175 25 C example 175 325 250 25 325 325 glVertexPointer 2 GL_INT 0 vertices set vertices tcl3dVectorFromArgs GLint 25 25 100 325 175 25 Tcl example 175 325 250 25 325 325 glVertexPointer 2 GL_INT 0 vertices Note e The allocation of usable memory can be accomplished with the use of the tcl3dVector command which is described in chapter 4 2 e This type of parameter is typically used to supply image data or vertex arrays See also the description of the image utility module in chapter 4 2 3 1 3 Output parameters The mapping of non constant pointers is handled by the SWIG standard typemaps Non constant pointers as function output parameter must be given as a pointer to a contiguous piece of memory of appropriate size tcl3dvector See note above Output parameter TYPE SIZE void SIZE TYPE void void glGetFloatv GLenum pname GLfloat params C declaration void glReadPixels GLint x GLint y GLsizei width GLsizei height GLenum format GLenum type GLvoid pixels GLfloat values 2 glGetFloatv GL LINE WIDTH GRANULARITY values C example GLubyte vec malloc w h 3 glReadPixels 0 0 w h GL_RGB GL_UNSIGNED BYTE vec s g et values tcl3dVect
66. tcl3dUtil tel3dOgl tcl3dOglExt tcl3dTogl C based Utilitie Basic OpenGL Extended OpenGL OpenGL Widget Better font handling telsdCg e tel3dSDL tel3dFTGL tcl3dFTG Nvidia s Cg Joystick and CD _ Font Rendering Tcl3D Version 0 3 1 Released 2006 06 16 Support for GL2PS and ODE alpha added Starpack versions Tcl3D Demos and Applications tel3dUtil tol3dGauges Tcl based Utilities Tcl Extension Package SWIG generated Tcl interfaces TokInterface tel3dUtil telsdogl tel3dOglExt C based Util Basic OpenGL Extended OpenGL telsasDL tel3dFTGL Joystick and CD__ Font Rendering tcl3dGi2ps tel3dOde OpenGL to PS PDF _ Physics Engine tcl3dTogl OpenGL Widget Tcl3D Version 0 3 2 Released 2007 02 25 Demo cleanup and first official Mac OS X support Windowing system specifics incorporated into Tog widget New module tcl3dDemouUtil Tcl3D Demos and Applications tcl3dUtil tcl3dGauges Tcl based Utilities Tcl Extension Package SWIG generated Tcl interfaces Tcl Interface tel3dUtil tcl3dOg tel3dOglExt tcl3dTogl C based Utilities Basic OpenGL Extended OpenGL OpenGL Widget tcl3dCg tcl3dSDL tcl3dFTGL Nvidia s Cg Joystick and CD Font Rendering tcl3dGI2ps tcl3dOde tcl3dDemoUtil OpenGL to PS PDF Physics Engine C utilities for demos Date Version Release information 2007 02 25 0 3 2 41 45 48 document Vv VV V VW Demo cleanup and first official Mac OS X sup
67. text to zero Key r Reset speed and position of text Mouse 1 Start animation Tcl3D User Manual Version 0 3 2 February 2007 Copyright 2005 2007 by Paul Obermeier All rights reserved Page 7 of 46 Tcl3D Doing 3D with Tcl www tcl3d org Mouse 2 Stop animation The presentation can be started alternatively by using pres as a command line parameter to the Tcl3D starpack Description of the Tcl3D starpack The Starpack tcl3dsh can be used as e astandalone executable like wish with builtin Tcl3D e atest and presentation program for Tcl3D e aninstaller for the Tcl3D specific libraries the external libraries and demo programs The Tcl3D presentation is divided into 3 sections e Information and installation e Help and documentation e Demos and tutorials The information menu gives you access to different types of information OpenGL TclI3D which are shown as animated OpenGL text More detailed information can be obtained by using the tcl3dInfo tcl script located in the demos directory in category Tcl3DSpecific The demo and tutorials menu has lots of sample programs divided into 3 categories e Library specific demos contains scripts showing features specific to the wrapped library e Tutorials and books contains scripts which have been converted from C to Tcl3D coming from the following sources OpenGL Red Book NeHe tutorials Kevin Harris CodeSampler web site Vahid Kazemi s GameProg
68. the SDL 19 library based on version 1 2 9 and adds some SDL related utility procedures Currently only the functions related to joystick and CD ROM handling have been wrapped and tested This is an optional module Requirements for this module The SDL library and header files Libraries and header files are included in distribution The master SWIG file for wrapping the Simple DirectMedia library is tel3dSDL i Implementation files None Header files All files in subdirectory include Wrapper files sdl i The wrapping for this module is based on the unmodified SDL header files Tcl3D User Manual Version 0 3 2 February 2007 Page 35 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org SDL utility module Tcl command Description tcl3dSDLGet Version Get the version of the wrapped SDL library tcl3dSDLGet FocusName Convert a SDL focus state bitfield into a string representation tcl3dSDLGetButtonName Convert a SDL button state bitfield into a string representation tcl3dsDLGetHatName Convert SDL hat related enumerations into a string representation tcl3dSDLGetEventName Convert SDL event related enumerations into a string representation tcl3dSDLFrames2MSF Convert CD frames into minutes seconds frames tcl3dSDLGetTrackTypeName Convert SDL CD track type enumerations into a string representation tcl3dSDLGetCdStatusName
69. this module can be found in chapter 4 2 1 2 3 tcl3dOgl Wrapper for basic OpenGL functionality This module wraps OpenGL functionality based on OpenGL Version 1 1 as well as the GLU library functions based on Version 1 2 This is due to the fact that Windows still does not support newer versions of OpenGL OpenGL features defined in newer versions have to be accessed via the OpenGL extension mechanism on Windows Standard shapes box sphere cylinder teapot with a GLUT compatible syntax are supplied here too A detailled description of this module can be found in chapter 4 3 1 2 4 tcl3dOglExt Wrapper for enhanced OpenGL functionality This module wraps OpenGL functionality based on versions 1 2 till 2 0 lots of OpenGL extensions not contained in the OpenGL core as well as Windows specific extensions It is implemented with the help of the Og Ext 24 library The files of this module are contained in the same directory as the basic OpenGL wrapper files for practial compilation reasons This is an optional module A detailled description of this module can be found in chapter 4 4 1 2 5 tcl3dCg Wrapper for NVidia s Cg shading language This module wraps NVidia s Cg 18 shader library based on version 1 5 0015 and adds some Cg related utility procedures This is an optional module A detailled description of this module can be found in chapter 4 5 1 2 6 tcl3dSDL Wrapper for the Simple DirectMedia Library This
70. torFromList VectorFromArgs tcl3dVectorFromArgs VectorFromString tcl3dVectorFromString VectorToString tcl3dVectorToString VectorToList tcl3dVectorToList CharToNum tcl3dCharToNum Photo2Vector tcl3dPhoto2Vector Vector2Photo tcl3dVector2Photo PhotoChans tcl3dPhotoChans Tcl3D User Manual Version 0 3 2 February 2007 Page 45 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org 8 References 1 Woo Neider Davis OpenGL Programming Guide Addison Wesley The Redbook 2 Roger E Critchlow s Frustum http www elf org pub frustum01 zip 3 Togl page at SourceForge http sourceforge net projects togl 4 NeHe s tutorials http nehe gamedev net 5 Kevin Harris code samples http Awww codesampler com oglsrc htm 6 Vahid Kazemi s GameProgrammer page http www gameprogrammer org 7 Nate Robins OpenGL tutorials http Awww xmission com nate tutors html 8 The Redbook sources http www opengl redbook com source 9 OpenGL GLUT demos http www opengl org resources code samples glut_examples demos demos html 10 Paul Bourke s textured sphere http local wasp uwa edu au pbourke texture spheremap 11 OpenGL Wiki page http wiki tcl tk 2237 12 SWIG Simplified Wrapper and Interface Generator http www swig org 13 Paul Obermeier s Portable Software http www posoft de 14 Tcl3D h
71. void GLdouble_ setitem double ary int index double value ary index value static void GLdouble setarray double ary double value int startIndex int len int i int endIndex startIndex len for i startIndex i lt endIndex i ary i value static void GLdouble addarray double ary double value int startIndex int len int i int endIndex startIndex len for i startIndex i lt endIndex i ary i double value static void GLdouble mularray double ary double value int startIndex int len int i int endIndex startIndex len for i startIndex i lt endIndex i ary i double value static double GLdouble_ind double ary int incr return ary incr These low level functions are typically not used directly They are accessible via the Tcl command tcl3dVector with the exception of the TYPE_ind functions An example for the usage of GLfloat_ind for optimized access to vectors can be found in NeHe demo Lesson37 tcl File bytearray i provides the implementation and wrapper definitions to convert Tcl binary strings ByteArrays into Tcl3D Vectors tcl3dByteArray2Vector and vice versa tcl3dVector2ByteArray High level access The file tcel3dVector tc contains additional Tcl commands for encapsulation of these low level accessor functions See the Tcl implementation file for a detailed explanation of the available procedures and its par
72. xtension support for Tcl3D 2 2 4 Step 4 Compilation and installation The following commands should compile and install the Tcl3D package gt gmake gt gmake install The make process prints out lines about the success of wrapping optional modules Tcl3D built with Cg support Tcl3D built without ODE support The starpack is not generated by default If you installed the starpack distribution package you have to go into the directory starpack and call make there Note To test the generated starpack copy it into a temporary directory and start it from there First installation tests Start a telsh or wish shell and type package require tcl3d Use the procedures tcl3dShowPackageInfo for a graphical package information or tcl3dGet PackageInfo for textual package information Tcl3D User Manual Version 0 3 2 February 2007 Page 13 of 46 Copyright 2005 2007 by Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org If these procedures fails you may try the low level information supplied in the Tcl array __tcel3dPkgInfo gt parray __tcl3dPkgInfo __tcel3dPkgInfo tcl3dcg avail 0 __tcel3dPkgInfo tcl3dcg version Cg library not wrapped __tcl3dPkgInfo tcl3ddemoutil avail 1 __tcel3dPkgInfo tcl3ddemoutil version 0 3 2 Version Tcl3D Basic should print out the following lines when calling tcl3dGetPackageInfo tcl3dcg 0 Cg library not wrapped tcl3ddemout
73. y Paul Obermeier All rights reserved Tcl3D Doing 3D with Tcl www tcl3d org In file tkphoto i the following C functions are implemented and wrapped to provide access to the Tk photo image functionality Tcl command Description tcl3dPhotoChans Return the number of channels of a Tk photo tcl3dPhoto2vector Copy a Tk photo into a tc13dVector in OpenGL raw image format The tcl3dVector must have been allocated with the approriate size and type tcl3dvector2Photo Copy from OpenGL raw image format into a Tk photo The photo image must have been initialized with the appropriate size and type tcl3dvectorFromPhoto Create a new Tcl3D Vector containing the image data of a Tk photo image Only GL_UNSIGNED_ BYTE currently supported Example 1 Read an image into a Tk photo and use it as a texture map Note Texture map images must have width and height that are powers of 2 set texture tcl3dVector GLuint 1 Memory for 1 texture proc LoadImage imgName set retVal catch set phImg image create photo file imgName err1 if retval 0 error Error reading image S imgName Serr1 else set numChans tcl3dPhotoChans phImg if numChans 3 amp amp SnumChans 4 error Error Only 3 or 4 channels allowed SnumChans supplied set w image width phImg set h image height phImg set texImg tcl3dVectorFromPhoto phImg numChans image delete phImg

Download Pdf Manuals

image

Related Search

Related Contents

東京都自転車安全利用推進計画 東 京 都    DF5310 English user manual 20110315  Istruzioni per l`uso e l`installazione Instructions for  Wireless Card - 123SecurityProducts.com  PH8HF、 PH8HFF 流通形ホルダ  Aperio Online Mechanical Installation Manual  Janome 2222 Instruction Manual  ワイヤレスハンディスキャナー  (8 mai) Une mère c`est la source de notre vie C`est notre ouverture s  

Copyright © All rights reserved.
Failed to retrieve file