GiD_OpenGL register|unregister|registercondition|unregistercondition|draw|drawtext|project|unproject|get|doscrzoffset|drawentity|font|pgfont

This command is a Tcl wrapper of some OpenGL functions. It allows to use OpenGL commands directly from GiD-Tcl.

For example, for C/C++ is used:





For GiD-Tcl must use:

GiD_OpenGL draw -begin lines

GiD_OpenGL draw -vertex [list $x1 $y1 $z1]

GiD_OpenGL draw -vertex [list $x2 $y2 $z2]

GiD_OpenGL draw -end

The standard syntax must be changed according to these rules: - OpenGL constants: "GL" prefix and underscore character '_' must be removed; the command must be written in lowercase.


GL_COLOR_MATERIAL -> colormaterial

- OpenGL functions: "GL" prefix must be removed and the command written in lowercase. Pass parameters as list, without using parentheses ()


glBegin(GL_LINES) -> glbegin lines

The subcommand "GiD_OpenGL draw" provides access to standard OpenGL commands, but other "GiD_OpenGL" special GiD subcommands also exists:

  • register <tclfunc> Register a Tcl procedure to be invoked automatically when redrawing the scene. It returns a handle to unregister.


proc MyRedrawProcedure { } { ...body... }

set id [GiD_OpenGL register MyRedrawProcedure]

  • unregister <handle> Unregister a procedure previously registered with register.


GiD_OpenGL unregister $id

  • registercondition <tclfunc> <condition> Register a Tcl procedure to be invoked automatically when redrawing the specified condition.

The tcl funcion must have this prototype:

proc xxx { condition use entity_id values } {


return 1


The supplied parameters are:

condition :the condition name, defined in the .cnd file of the problemtype


entity_id: the integer number that identity the entity where the condition is applied. The kind of entity is known because it is declared in the

definition of the condition in the .cnd, depending if the current state is geometry or mesh

values: a list of the field's values applied to this entity. The amount of values must match the amount of fields of the condition definition.

The return value of this procedure is important:

return 0: then the standard representation of the condition is also invoked after the procedure

return 1: the stardard representation of the condition is avoided.

  • unregistercondition <condition> Unregister a procedure previously registered with registercondition.

  • draw <-cmd args -cmd args> This is the most important subcommand, it calls standard OpenGL commands. See the list of supported OpenGL functions.

  • drawtext <text> ?–check_non_latin? Draw a text more easily than using standard OpenGL commands (draw in the current 2D location, see rasterpos OpenGL command).

If -check_non_latin flag is provided, then the text is checked to detect non-latin characters, like a Japanese string, to be drawn properly (otherwise it is considered as a latin string). The flag must be provided only if <text> could potentially be non-latin, like translated strings. In case of numbers for example it is unneeded (more efficient without the extra check)


GiD_OpenGL draw -rasterpos [list $x $y $z]

GiD_OpenGL drawtext "hello world"

  • drawentity ?-mode normal|filled? point|line|surface|volume|node|element|dimension <id list> To draw an internal GiD preprocess entity.


GiD_OpenGL drawentity -mode filled surface {1 5 6}

For elements it is possible to draw only a face, specifying items of element_id and face_id, whith face_id a number from 1 to the number of faces of the element.


GiD_OpenGL drawentity -mode filled element {{1 1} {5 1} {6 3}}

  • project <x y z> Given three world coordinates, this returns the corresponding three window coordinates.

  • unproject <x y z> Given three window coordinates, this returns the corresponding three world coordinates.

  • get modelviewmatrix|projectionmatrix|viewport

return a list of values:

modelviewmatrix: 16 doubles

projectionmatrix: 16 doubles

viewport: 4 integers

  • doscrzoffset <boolean> Special trick to avoid the lines on surfaces hidden by the surfaces.

  • font push <font_name font_size>|pop|measure <text>|current|metrics ?-ascent|-descent|-linespace|-fixed?

push sets the current OpenGL font, pop restores the previous one

measure <text> returns the amount of space in pixels to display this <text>

current returns a list with the current font name and size

metrics returns a list with current font metrics information: -ascent -descent and -linespace in pixels, -fixed is 1 if all characters have equal size


GiD_OpenGL font push {"Times New Roman" 18}

set with [GiD_OpenGL measure "hello world"]

GiD_OpenGL drawtext "hello world"

GiD_OpenGL pop

  • pgfont pushfont <font_type>|popfont|print <text>|dimensions <text>|foreground <red> <green> <blue> <alpha>|background <red> <green> <blue> <alpha>

Similar to font but using pgfonts

font types: defaultfont, axisfont, legendfont, labelfont, graphfont, asianfont, tkdrawoglfont, pmfont

List of supported OpenGL functions:

accum alphafunc begin bindtexture blendfunc call calllist clear clearaccum clearcolor cleardepth clearstencil clipplane color colormask colormaterial copypixels cullface deletelists deletetextures depthfunc depthmask dfactorBlendTable disable drawbuffer drawpixels edgeflag enable end endlist evalcoord1 evalcoord2 evalmesh1 evalmesh2 finish flush fog frontface frustum genlists gentextures getstring hint hintModeTable initnames light lightmodel linestipple linewidth loadidentity loadmatrix loadname lookat map1 map2 mapgrid1 mapgrid2 material matrixmode modeColorMatTable multmatrix newlist newListTable normal opStencilTable opStencilTable ortho perspective pickmatrix pixeltransfer pixelzoom pointsize polygonmode popattrib popmatrix popname pushattrib pushmatrix pushname rasterpos readbuffer readpixels rect rendermode rotate scale scissor selectbuffer shademodel stencilfunc stencilmask stencilop texcoord texenv texgen teximage1d teximage2d texparameter translate vertex viewport

List of special non OpenGL standard functions:


List of supported OpenGL constants:

accum accumbuffer accumbufferbit add alphatest always allattrib allattribbits ambient ambientanddiffuse autonormal aux0 aux1 aux2 aux3 back backleft backright blend bluebias bluescale ccw clamp clipplane0 clipplane1 clipplane2 clipplane3 clipplane4 clipplane5 colorbuffer colorbufferbit colorindex colormaterial compile compileandexecute constantattenuation cullface current currentbit cw decal decr depthbuffer depthbufferbit depthtest diffuse dither dstalpha dstcolor enable enablebit emission equal eval evalbit exp exp2 extensions eyelinear eyeplane feedback fill flat fog fogbit fogcolor fogdensity fogend fogmode fogstart front frontandback frontleft frontright gequal greater greenbias greenscale hint hintbit incr invert keep left lequal less light0 light1 light2 light3 light4 light5 light6 light7 lighting lightingbit lightmodelambient lightmodellocalviewer lightmodeltwoside line linebit linear linearattenuation lineloop lines linesmooth linestipple linestrip list listbit load map1color4 map1normal map1texturecoord1 map1texturecoord2 map1texturecoord3 map1texturecoord4 map1vertex3 map1vertex4 map2color4 map2normal map2texturecoord1 map2texturecoord2 map2texturecoord3 map2texturecoord4 map2vertex3 map2vertex4 modelview modulate mult nearest never none normalize notequal objectlinear objectplane one oneminusdstalpha oneminusdstcolor oneminussrcalpha oneminussrccolor packalignment packlsbfirst packrowlength packskippixels packskiprows packswapbytes pixelmode pixelmodebit point pointbit points polygon polygonbit polygonoffsetfill polygonstipple polygonstipplebit position projection q quadraticattenuation quads quadstrip r redbias redscale render renderer repeat replace return right s scissor scissorbit select shininess smooth specular spheremap spotcutoff spotdirecion spotexponent srcalpha srcalphasaturate srccolor stenciltest stencilbuffer stencilbufferbit t texture texture1d texture2d texturebit texturebordercolor textureenv textureenvcolor textureenvmode texturegenmode texturegens texturegent texturemagfilter textureminfilter texturewraps texturewrapt transform transformbit triangles trianglefan trianglestrip unpackalignment unpacklsbfirst unpackrowlength unpackskippixels unpackskiprows unpackswapbytes vendor version viewport viewportbit zero

You can find more information about standard OpenGL functions in a guide to OpenGL.