1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
|
<html>
<!-- vi:set sw=2: -->
<!--
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
Copyright (C) 2005-2008 Greg Couch
See the LICENSE file for copyright details.
-->
<head>
<title>Togl Tcl API</title>
</head>
<body>
<script language="javascript" src="header.js"></script>
<script language="javascript">
NavigationBar();
</script>
<h1 align="center">Togl Tcl API</h1>
<h2>Contents</h2>
<ul>
<li><a href="#tclfuncs">Togl Tcl command</a>
<li><a href="#toglfuncs">Togl widget commands</a>
<ul>
<li><a href="#configuration">Configuration Commands</a>
<li><a href="#extensions">Extensions Command</a>
<li><a href="#rendering">Rendering Commands</a>
<li><a href="#image">Image Commands</a>
<li><a href="#font">Font Commands</a>
<li><a href="#overlay">Overlay Commands</a>
<li><a href="#stereo cmds">OpenGL (Stereo) Commands</a>
</ul>
<li><a href="#options">Togl configuration options</a>
<ul>
<li><a href="#drawing">Drawing callbacks</a>
<li><a href="#geometry">Geometry Options</a>
<li><a href="#timer">Timer Options</a>
<li><a href="#stereo options">Stereo Options</a>
<li><a href="#miscellaneous">Miscellaneous Options</a>
<li><a href="#pixelformat">Pixel Format Options</a>
</ul>
</ul>
<hr>
<h2><a name="tclfuncs">Togl Tcl command</a></h2>
<p>
The togl command creates a new Tk widget, a Tcl command,
whose name is <var>pathName</var>.
This command may be used to invoke various operations on the widget.
<blockquote>
<code>togl <var>pathName</var> [<a href="#options">options</a>]</code>
</blockquote>
If no options are given, a 400 by 400 pixel RGB window is created.
This command may be used to invoke various operations on the widget.
<h2><a name="toglfuncs">Togl widget commands</a></h2>
The following commands are possible for an existing togl widget:
<h3><a name="configuration">Configuration commands</a></h3>
<dl>
<dt><code><var>pathName</var> cget <var>-option</var></code>
<dd>
Return current value of given configuration option.
</dl>
<dl>
<dt>
<code><var>pathName</var> configure</code><br>
<code><var>pathName</var> configure <var>-option</var></code>
<dd>
If no <var>option</var> is given,
then return information about
all configuration <a href="#options">options</a>.
Otherwise,
return configuration information for given <var>option</var>.
All configuration information consists of five values:
the configuration option name,
the option database name,
the option database class,
the default value,
and the current value.
</dl>
<dl>
<dt><code><var>pathName</var> configure <var>-option</var> <var>value</var></code>
<dd>
Reconfigure a Togl widget.
<var>option</var> may be any one of the options listed below.
</dl>
<dl>
<dt><code><var>pathName</var> contexttag</code>
<dd>
Returns an integer that represents the context tag.
All Togl widgets with the same context tag share display lists.
</dl>
<h3><a name="extensions">Extensions command</a></h3>
<dl>
<dt><code><var>pathName</var> extensions</code>
<dd>
Returns a list of OpenGL extensions available. For example:
<blockquote><code><pre>
if {[lsearch [<i>pathName</i> extensions] GL_EXT_bgra] != -1]} {
....
}
</pre></code></blockquote>
would check if the GL_EXT_bgra extension were supported.
</dl>
<h3><a name="rendering">Rendering commands</a></h3>
<dl>
<dt><code><var>pathName</var> postredisplay</code>
<dd>
Cause the displaycommand callback to be called
the next time the event loop is idle.
</dl>
<dl>
<dt><code><var>pathName</var> render</code>
<dd>
Causes the displaycommand callback to be called for <var>pathName</var>.
</dl>
<dl>
<dt><code><var>pathName</var> swapbuffers</code>
<dd>
Causes front/back buffers to be swapped if in double buffer mode.
And flushs the OpenGL command buffer if in single buffer mode.
(So this is appropriate to call after every frame is drawn.)
</dl>
<dl>
<dt><code><var>pathName</var> makecurrent</code>
<dd>
Make the widget specified by <var>pathName</var> and its OpenGL context
the current ones.
This is implicitly called before any callback command is invoked.
</dl>
<h3><a name="image">Image commands</a></h3>
<dl>
<dt><code><var>pathName</var> takephoto <var>imagename</var></code>
<dd>
Copy the contents of the togl window into the given Tk photo image.
Transparency values are copied and should be fully opaque for windows
without alpha bitplanes.
</dl>
<h3><a name="font">Font commands</a></h3>
<p>
These functions provide an interface to the simple bitmap font capabilities
that every OpenGL implementation provides.
Better font support is found in other packages, <i>e.g.</i>,
<a href="http://www.tcl3d.org/">Tcl3D</a>
or with different <a href="capi.html#font">C APIs</a>.
<dl>
<dt><code><var>pathName</var> loadbitmapfont <var>font</var></code>
<dd>
<var>font</var> can be any of font descriptions listed in the Tk
<a href="http://www.tcl.tk/man/tcl8.4/TkCmd/font.htm#M13">font</a> command.
It returns a togl font object.
</dl>
<dl>
<dt><code><var>pathName</var> unloadbitmapfont <var>toglfont</var></code>
<dd>
Releases the OpenGL resources needed by the <var>toglfont</var>.
</dl>
<dl>
<dt><code><var>pathName</var> write <var>toglfont</var> [-pos <var>xyzw</var>] [-color <var>rgba</var>] <var>string</var></code>
<dd>
Write the given <var>string</var> in the given <var>toglfont</var>,
optionally at a particular position, <var>xyzw</var>
and color, <var>rgba</var>.
<var>xyzw</var> is either a 2, 3, or 4 element list of numbers.
<var>rgba</var> is either a 3 or 4 element list of numbers.
</dl>
<h3><a name="overlay">Overlay Commands</a></h3>
<dl>
<dt><code><var>pathName</var> uselayer <var>layer</var></code>
<dd>
This is a variation on the <code>makecurrent</code> command
that makes the overlay OpenGL context current
if <var>layer</var> is 2
and makes the normal OpenGL context current
if <var>layer</var> is 1.
</dl>
<dl>
<dt><code><var>pathName</var> showoverlay</code>
<dd>
Turn on drawing in the overlay planes.
</dl>
<dl>
<dt><code><var>pathName</var> hideoverlay</code>
<dd>
Turn off drawing in the overlay planes.
</dl>
<dl>
<dt><code><var>pathName</var> postredisplayoverlay</code>
<dd>
Cause the overlay OpenGL context to be redrawn the next time
the Tcl event loop is idle.
</dl>
<dl>
<dt><code><var>pathName</var> renderoverlay</code>
<dd>
Causes the overlaydisplaycommand callback to be called for <var>pathName</var>.
</dl>
<dl>
<dt><code><var>pathName</var> existsoverlay</code>
<dd>
Return true if togl widget has overlay planes.
</dl>
<dl>
<dt><code><var>pathName</var> ismappedoverlay</code>
<dd>
Return true if overlay planes are shown.
</dl>
<dl>
<dt><code><var>pathName</var> getoverlaytransparentvalue</code>
<dd>
Return overlay plane's transparent pixel value.
</dl>
<h3><a name="stereo cmds">OpenGL (Stereo) Commands</a></h3>
These commands exist to support stereo rendering.
Just replace select OpenGL calls with the Togl versions
and stereo rendering will magically work. And don't forget
to update the <a href="#stereo options">stereo options</a>.
<dl>
<dt><code><var>pathName</var> drawbuffer <var>mode</var></code>
<dd>
Replaces calls to glDrawBuffer.
The mode is an integer.
</dl>
<dl>
<dt><code><var>pathName</var> clear <var>mask</var></code>
<dd>
Replaces calls to glClear.
The mask is an integer.
</dl>
<dl>
<dt><code><var>pathName</var> frustum <var>left right bottom top near far</var></code>
<dd>
Replaces calls to glFrustum.
</dl>
<dl>
<dt><code><var>pathName</var> ortho <var>left right bottom top near far</var></code>
<dd>
Replaces calls to glOrtho.
</dl>
<dl>
<dt><code><var>pathName</var> numeyes</code>
<dd>
Returns numbers of eyes — basically,
2 for stereo views and 1 for all others,
except some stereo views only need one eye from OpenGL.
</dl>
<h2><a name="options">Togl configuration options</a></h2>
Togl's configuration options can be separated into several categories:
geometry, pixel format, and other.
The pixel format related options can only be set at widget creation time.
The other options can be changed dynamically
by the <code><var>pathName</var> configure</code> command (see above).
<h3><a name="drawing">Drawing callbacks</a></h3>
<table border="0">
<thead>
<tr valign="top">
<th>Option</th>
<th>Default</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td><code>-createcommand</code></td>
<td align="center">{}</td>
<td>
Can be abbreviated <code>-create</code>.
</td>
</tr>
<tr valign="top">
<td><code>-displaycommand</code></td>
<td align="center">{}</td>
<td>
Can be abbreviated <code>-display</code>.
</td>
</tr>
<tr valign="top">
<td><code>-reshapecommand</code></td>
<td align="center">{}</td>
<td>
Can be abbreviated <code>-reshape</code>.
</td>
</tr>
<tr valign="top">
<td><code>-destroycommand</code></td>
<td align="center">{}</td>
<td>
Can be abbreviated <code>-destroy</code>.
</td>
</tr>
<tr valign="top">
<td><code>-overlaydisplaycommand</code></td>
<td align="center">{}</td>
<td>
Can be abbreviated <code>-overlaydisplay</code>.
</td>
</tr>
</tbody>
</table>
<h3><a name="geometry">Geometry Options</a></h3>
<table border="0">
<thead>
<tr valign="top">
<th>Option</th>
<th>Default</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td><code>-width</code></td>
<td align="center">400</td>
<td>
Set width of widget in pixels.
It may have any of the forms accepted by <b>Tk_GetPixels</b>.
</td>
</tr>
<tr valign="top">
<td><code>-height</code></td>
<td align="center">400</td>
<td>
Set height of widget in pixels.
It may have any of the forms accepted by <b>Tk_GetPixels</b>(3).
</td>
</tr>
<tr valign="top">
<td><code>-setgrid</code></td>
<td align="center">0</td>
<td>
Turn on gridded geometry management for togl widget's toplevel
window and specify the geometry of the grid.
See the manual pages for Tk's <b>wm</b>(n) and <b>Tk_SetGrid</b>(3)
for more information.
Unlike the <b>text</b> widget,
the same value is used for both width and height increments.
</td>
</tr>
</tbody>
</table>
<h3><a name="timer">Timer Options</a></h3>
<table>
<thead>
<tr valign="top">
<th>Option</th>
<th>Default</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td><code>-time</code></td>
<td align="center">1</td>
<td>
Specifies the interval, in milliseconds, for
calling the timer callback function which
was registered with -timercommand.</td>
</tr>
<tr valign="top">
<td><code>-timercommand</code></td>
<td align="center">{}</td>
<td>
Can be abbreviated <code>-timer</code>.
</td>
</tr>
</tbody>
</table>
<h3><a name="stereo options">Stereo Options</a></h3>
<table>
<thead>
<tr valign="top">
<th>Option</th>
<th>Default</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td><code>-eyeseparation</code></td>
<td align="center">2.0</td>
<td>
Set the distance between the eyes in viewing coordinates.
</td>
</tr>
<tr valign="top">
<td><code>-convergence</code></td>
<td align="center">30.0</td>
<td>
Set the distance to the screen from the eye in viewing coordinates
(the distance at which the eyes converge).
</td>
</tr>
</tbody>
</table>
<blockquote>
You'd think these values would be given in physical units,
but there's no single right way to convert to viewing coordinates
from physical units.
So if you're willing to use Tk's idea of the horizontal size of a
window in millimeters (not always correct),
you could convert the average eye separation of 63 mm
to your viewing coordinates, and use that value as the eye separation.
</blockquote>
<h3><a name="miscellaneous">Miscellaneous Options</a></h3>
<table>
<thead>
<tr valign="top">
<th>Option</th>
<th>Default</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td><code>-cursor</code></td>
<td align="center">""</td>
<td>
Set the cursor in the widget window.
</td>
</tr>
<tr valign="top">
<td><code>-swapinterval</code></td>
<td align="center">1</td>
<td>
Set the minimum swap interval measure in video frame periods.
The default is 1 for for non-tearing artifacts
when swapping buffers.
Use a value of 0 when benchmarking frame rates.
</td>
</tr>
<tr valign="top">
<td><code>-ident</code></td>
<td align="center">""</td>
<td>
A user identification string. This is used match widgets
for the <code>-sharecontext</code>
and the <code>-sharelist</code> options (see below).
This is also useful in your callback functions
to determine which Togl widget is the caller.
</td>
</tr>
</tbody>
</table>
<h3><a name="pixelformat">Pixel Format Options</a></h3>
The following options can only be given when the togl widget is created
— that is, unlike other options,
the togl widget can not be reconfigured with different values
for the following options after it is created.
<table border="0">
<thead>
<tr valign="top">
<th>Option</th>
<th>Default</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td><code>-rgba</code></td>
<td align="center">true</td>
<td>If true, use RGB(A) mode, otherwise use Color Index mode.</td>
</tr>
<tr valign="top">
<td><code>-redsize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in red component.</td>
</tr>
<tr valign="top">
<td nowrap="1"><code>-greensize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in green component.</td>
</tr>
<tr valign="top">
<td><code>-bluesize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in blue component.</td>
</tr>
<tr valign="top">
<td><code>-alpha</code></td>
<td align="center">1</td>
<td>
If true and <code>-rgba</code> is true, request an alpha channel.
</td>
</tr>
<tr valign="top">
<td><code>-alphasize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in alpha component.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-double</code></td>
<td align="center">false</td>
<td>
If true, request a double-buffered window, otherwise
request a single-buffered window.
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-depth</code></td>
<td align="center">false</td>
<td>If true, request a depth buffer.</td>
</tr>
<tr valign="top">
<td><code>-depthsize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in depth buffer.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-accum</code></td>
<td align="center">false</td>
<td>If true, request an accumulation buffer.</td>
</tr>
<tr valign="top">
<td><code>-accumredsize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in accumulation buffer red component.</td>
</tr>
<tr valign="top">
<td nowrap="1"><code>-accumgreensize</code></td>
<td align="center">1</td>
<td>
Minimum number of bits in accumulation buffer green component.
</td>
</tr>
<tr valign="top">
<td><code>-accumbluesize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in accumulation buffer blue component.</td>
</tr>
<tr valign="top">
<td><code>-accumalphasize</code></td>
<td align="center">1</td>
<td>
Minimum number of bits in accumulation buffer alpha component.
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-stencil</code></td>
<td align="center">false</td>
<td>If true, request a stencil buffer.</td>
</tr>
<tr valign="top">
<td><code>-stencilsize</code></td>
<td align="center">1</td>
<td>Minimum number of bits in stencil component.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-auxbuffers</code></td>
<td align="center">0</td>
<td>Desired number of auxiliary buffers.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-privatecmap</code></td>
<td align="center">false</td>
<td>
Only applicable in color index mode.
If false, use a shared read-only colormap.
If true, use a private read/write colormap.
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-overlay</code></td>
<td align="center">false</td>
<td>If true, request overlay planes.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr valign="top">
<td><code>-stereo</code></td>
<td align="center">mode</td>
<td>
See the <a href="stereo.html">stereo</a> information
for details about the various modes.
Stereo parameters are changed with the
<a href="#stereo options">stereo options</a>.
<p>
When using a non-native stereo mode, the OpenGL
<code>glDrawBuffer</code>, <code>glClear</code>,
<code>glFrustum</code>, and <code>glOrtho</code> calls
must be replaced with the Togl
<a href="#stereo cmds">Tcl</a> or
<a href="capi.html#stereo">C</a> versions.
</td>
</tr>
<tr><td colspan="3" height="0"> </td></tr>
<tr valign="top">
<td><code>-indirect</code></td>
<td align="center">false</td>
<td>
If present, request an indirect rendering context.
A direct rendering context is normally requested.
<em>Only significant on Unix/X11.</em>
</td>
</tr>
<tr valign="top">
<td><code>-sharelist</code></td>
<td align="center">""</td>
<td>
Name of an existing Togl widget with which to share display lists.
If it is not possible to share contexts between the two togl
widgets (depends on the graphics driver
and the particular formats), it fails.
</td>
</tr>
<tr valign="top">
<td><code>-sharecontext</code></td>
<td align="center">""</td>
<td>
Name of an existing Togl widget with which to
share the OpenGL context.
<i>Note: all other pixel format options are ignored.</i>
</td>
</tr>
<tr valign="top">
<td><code>-pixelformat</code></td>
<td align="center">0</td>
<td>
Set the pixel format to the (platform-dependent) given value.
This is a backdoor into choosing a particular pixel format
that was determined by other means.
</td>
</tr>
</tbody>
</table>
<hr>
Hosted by <a href="http://sourceforge.net/">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" align="middle"/>
</a>
</body>
</html>
|