1 <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
7 <meta name="Author" content="John F. Fay">
9 <meta name="GENERATOR" content="Mozilla/4.77 [en] (Windows NT 5.0; U) [Netscape]">
10 <title>FREEGLUT Application Program Interface</title>
16 <h1> The Open-Source</h1>
19 <h1> OpenGL Utility Toolkit</h1>
22 <h1> (<i>freeglut</i> 2.0.0)</h1>
25 <h1> Application Programming Interface</h1>
34 <h2> The <i>freeglut</i> Programming Consortium</h2>
42 OpenGL is a trademark of Silicon Graphics, Inc. X Window System is a trademark
43 of X Consortium, Inc. Spaceball is a registered trademark of Spatial
45 The authors have taken care in preparation of this documentation but make
46 no expressed or implied warranty of any kind and assumes no responsibility
47 for errors or omissions. No liability is assumed for incidental or consequential
48 damages in connection with or arising from the use of information or programs
49 contained herein. <br>
52 <h1> 1.0 <a name="Contents"></a>
54 1.0 <a href="#Contents">Contents</a>
56 <p>2.0 <a href="#Introduction">Introduction</a>
59 <p>3.0 <a href="#Background">Background</a>
62 <blockquote>3.1 Design Philosophy <br>
63 3.2 Conventions <br>
64 3.3 Terminology <br>
65 3.4 Differences from GLUT 3.7</blockquote>
68 4.0 <a href="#Initialization">Initialization Functions</a>
71 <blockquote>4.1 glutInit <br>
72 4.2 glutInitWindowPosition, glutInitWindowSize <br>
73 4.3 glutInitDisplayMode <br>
74 4.4 glutInitDisplayString</blockquote>
77 5.0 <a href="#EventProcessing">Event Processing Functions</a>
80 <blockquote>5.1 glutMainLoop <br>
81 5.2 glutMainLoopEvent <br>
82 5.3 glutLeaveMainLoop</blockquote>
85 6.0 <a href="#Window">Window Functions</a>
88 <blockquote>6.1 glutCreateWindow <br>
89 6.2 glutCreateSubwindow <br>
90 6.3 glutDestroyWindow <br>
91 6.4 glutSetWindow, glutGetWindow <br>
92 6.5 glutSetWindowTitle, glutSetIconTitle <br>
93 6.6 glutReshapeWindow <br>
94 6.7 glutPositionWindow <br>
95 6.8 glutShowWindow, glutHideWindow, glutIconifyWindow <br>
96 6.9 glutPushWindow, glutPopWindow <br>
97 6.10 glutFullScreen</blockquote>
100 7.0 <a href="#Display">Display Functions</a>
103 <blockquote>7.1 glutPostRedisplay <br>
104 7.2 glutPostWindowRedisplay <br>
105 7.3 glutSwapBuffers</blockquote>
108 8.0 <a href="#MouseCursor">Mouse Cursor Functions</a>
111 <blockquote>8.1 glutSetCursor <br>
112 8.2 glutWarpPointer</blockquote>
115 9.0 <a href="#Overlay">Overlay Functions</a>
118 <blockquote>9.1 glutEstablishOverlay <br>
119 9.2 glutRemoveOverlay <br>
120 9.3 glutUseLayer <br>
121 9.4 glutPostOverlayRedisplay <br>
122 9.5 glutPostWindowOverlayRedisplay <br>
123 9.6 glutShowOverlay, glutHideOverlay</blockquote>
126 10.0 <a href="#Menu">Menu Functions</a>
129 <blockquote>10.1 glutCreateMenu <br>
130 10.2 glutDestroyMenu <br>
131 10.3 glutGetMenu, glutSetMenu <br>
132 10.4 glutAddMenuEntry <br>
133 10.5 glutAddSubMenu <br>
134 10.6 glutChangeToMenuEntry <br>
135 10.7 glutChangeToSubMenu <br>
136 10.8 glutRemoveMenuItem <br>
137 10.9 glutAttachMenu, glutDetachMenu</blockquote>
140 11.0 <a href="#GlobalCallback">Global Callback Registration Functions</a>
143 <blockquote>11.1 glutTimerFunc <br>
144 11.2 glutIdleFunc</blockquote>
147 12.0 <a href="#WindowCallback">Window-Specific Callback Registration
151 <blockquote>12.1 glutDisplayFunc <br>
152 12.2 glutOverlayDisplayFunc <br>
153 12.3 glutReshapeFunc <br>
154 12.4 glutCloseFunc <br>
155 12.5 glutKeyboardFunc <br>
156 12.6 glutSpecialFunc <br>
157 12.7 glutKeyboardUpFunc <br>
158 12.8 glutSpecialUpFunc <br>
159 12.9 glutMouseFunc <br>
160 12.10 glutMotionFunc, glutPassiveMotionFunc <br>
161 12.11 glutVisibilityFunc <br>
162 12.12 glutEntryFunc <br>
163 12.13 glutJoystickFunc <br>
164 12.14 glutSpaceballMotionFunc <br>
165 12.15 glutSpaceballRotateFunc <br>
166 12.16 glutSpaceballButtonFunc <br>
167 12.17 glutButtonBoxFunc <br>
168 12.18 glutDialsFunc <br>
169 12.19 glutTabletMotionFunc <br>
170 12.20 glutTabletButtonFunc
171 <p>12.21 glutMenuStatusFunc <br>
172 12.22 glutWindowStatusFunc</p>
176 13.0 <a href="#StateSetting">State Setting and Retrieval Functions</a>
179 <blockquote>13.1 glutSetOption <br>
180 13.2 glutGet <br>
181 13.3 glutDeviceGet <br>
182 13.4 glutGetModifiers <br>
183 13.5 glutLayerGet <br>
184 13.6 glutExtensionSupported<br>
185 13.7 glutGetProcAddress<br>
189 14.0 <a href="#FontRendering">Font Rendering Functions</a>
192 <blockquote>14.1 glutBitmapCharacter <br>
193 14.2 glutBitmapString <br>
194 14.3 glutBitmapWidth <br>
195 14.4 glutBitmapLength <br>
196 14.5 glutBitmapHeight <br>
197 14.6 glutStrokeCharacter <br>
198 14.7 glutStrokeString <br>
199 14.8 glutStrokeWidth <br>
200 14.9 glutStrokeLength <br>
201 14.10 glutStrokeHeight</blockquote>
204 15.0 <a href="#GeometricObject">Geometric Object Rendering Functions</a>
207 <blockquote>15.1 glutWireSphere, glutSolidSphere
209 15.2 glutWireTorus, glutSolidTorus <br>
210 15.3 glutWireCone, glutSolidCone <br>
211 15.4 glutWireCube, glutSolidCube <br>
212 15.5 glutWireTetrahedron, glutSolidTetrahedron <br>
213 15.6 glutWireOctahedron, glutSolidOctahedron <br>
214 15.7 glutWireDodecahedron, glutSolidDodecahedron <br>
215 15.8 glutWireIcosahedron, glutSolidIcosahedron <br>
216 15.9 glutWireRhombicDodecahedron, glutSolidRhombicDodecahedron <br>
217 15.10 glutWireTeapot, glutSolidTeapot</blockquote>
220 16.0 <a href="#GameMode">Game Mode Functions</a>
223 <blockquote>16.1 glutGameModeString <br>
224 16.2 glutEnterGameMode, glutLeaveGameMode <br>
225 16.3 glutGameModeGet</blockquote>
228 17.0 <a href="#VideoResize">Video Resize Functions</a>
231 <blockquote>17.1 glutVideoResizeGet <br>
232 17.2 glutSetupVideoResizing, glutStopVideoResizing <br>
233 17.3 glutVideoResize <br>
234 17.4 glutVideoPan</blockquote>
237 18.0 <a href="#ColorMap">Color Map Functions</a>
240 <blockquote>18.1 glutSetColor, glutGetColor
242 18.2 glutCopyColormap</blockquote>
245 19.0 <a href="#Miscellaneous">Miscellaneous Functions</a>
248 <blockquote>19.1 glutIgnoreKeyRepeat,
249 glutSetKeyRepeat <br>
250 19.2 glutForceJoystickFunc <br>
251 19.3 glutReportErrors</blockquote>
254 20.0 <a href="#UsageNotes">Usage Notes</a>
257 <p>21.0 <a href="#ImplementationNotes">
258 Implementation Notes</a>
261 <p>22.0 <a href="#GLUT_State">GLUT
265 <p>23.0 <a href="#Freeglut.h_Header">
266 "freeglut.h" Header File</a>
269 <p>24.0 <a href="#References">References</a>
272 <p>25.0 <a href="#Index">Index</a>
277 <h1> 2.0 <a name="Introduction"></a>
280 <h1> 3.0 <a name="Background"></a>
282 The OpenGL programming world owes a tremendous debt to Mr. Mark J. Kilgard
283 for writing the OpenGL Utility Toolkit, or GLUT. The GLUT library
284 of functions allows an application programmer to create, control, and manipulate
285 windows independent of what operating system the program is running on.
286 By hiding the dependency on the operating system from the application programmer,
287 he allowed people to write truly portable OpenGL applications.
289 <p> Mr. Kilgard copyrighted
290 his library and gave it a rather unusual license. Under his license,
291 people are allowed freely to copy and distribute the libraries and the source
292 code, but they are not allowed to modify it. For a long time this did
293 not matter because the GLUT library worked so well and because Mr. Kilgard
294 was releasing updates on a regular basis. But with the passage of time,
295 people started wanting some slightly different behaviours in their windowing
296 system. When Mr. Kilgard stopped supporting the GLUT library in 1999,
297 having moved on to bigger and better things, this started to become a problem.
300 <p> In December 1999,
301 Mr. Pawel Olzsta started work on an open-source clone of the GLUT library.
302 This open-source clone, which does not use any of the GLUT source code, has
303 evolved into the present <i>freeglut</i> library. This documentation
304 specifies the application program interface to the <i>freeglut</i> library.
307 <h2> 3.1 Design Philosophy</h2>
309 <h2> 3.2 Conventions</h2>
311 <h2> 3.3 Terminology</h2>
313 <h2> 3.4 Differences from GLUT 3.7</h2>
314 Since the <i>freeglut</i> library was developed in order to update GLUT,
315 it is natural that there will be some differences between the two.
316 Each function in the API notes any differences between the GLUT and the <i>
317 freeglut</i> function behaviours. The important ones are summarized
319 <h3> 3.4.1 glutMainLoop Behaviour</h3>
320 One of the commonest complaints about the GLUT library was that once an
321 application called "<tt>glutMainLoop</tt>", it never got control back.
322 There was no way for an application to loop in GLUT for a while, possibly
323 as a subloop while a specific window was open, and then return to the calling
324 function. A new function, "<tt>glutMainLoopEvent</tt>", has been added
325 to allow this functionality. Another function, "<tt>glutLeaveMainLoop</tt>
326 ", has also been added to allow the application to tell <i>freeglut</i> to clean
328 <h3> 3.4.2 Action on Window Closure</h3>
329 Another difficulty with GLUT, especially with multiple-window programs,
330 is that if the user clicks on the "x" in the window header the application
331 exits immediately. The application programmer can now set an option,
332 "<tt> GLUT_ACTION_ON_WINDOW_CLOSE</tt>", to specify whether execution should
333 continue, whether GLUT should return control to the main program, or whether
334 GLUT should simply exit (the default).
336 <h3>3.4.3 Changes to Callbacks<br>
338 Several new callbacks have been added and several callbacks which were specific
339 to Silicon Graphics hardware have not been implemented. Most or all
340 of the new callbacks are listed in the GLUT Version 4 "glut.h" header file
341 but did not make it into the documentation. The new callbacks consist
342 of regular and special key release callbacks, a joystick callback, a window
343 status callback, window closure callbacks, a menu closure callback, and a
344 mouse wheel callback. Unsupported callbacks are the three Spaceball
345 callbacks, the ButtonBox callback, and the two Tablet
346 callbacks. If the user has a need for an unsupported callback he should
347 contact the <i>freeglut</i> development team.<br>
349 <h3>3.4.4 String Rendering<br>
351 New functions have been added to render full character strings (including
352 carriage returns) rather than rendering one character at a time. More
353 functions return the widths of character strings and the font heights, in
354 pixels for bitmapped fonts and in OpenGL units for the stroke fonts.<br>
356 <h3>3.4.5 Geometry Rendering<br>
358 Functions have been added to render a wireframe and a solid rhombic
359 dodecahedron, a cylinder, and a Sierpinski sponge.
360 <h3> 3.4.5 Extension Function Queries</h3>
361 glutGetProcAddress is a wrapper for the glXGetProcAddressARB and wglGetProcAddress
363 <h1> 4.0 <a name="Initialization"></a>
364 Initialization Functions</h1>
366 <h2> 4.1 glutInit</h2>
368 <h2> 4.2 glutInitWindowPosition, glutInitWindowSize</h2>
369 The "<tt>glutInitWindowPosition</tt> " and "<tt>glutInitWindowSize</tt>
370 " functions specify a desired position and size for windows that <i>freeglut</i>
371 will create in the future.
374 <p><tt>void glutInitWindowPosition ( int
375 x, int y ) ;</tt> <br>
376 <tt>void glutInitWindowSize ( int width,
377 int height ) ;</tt> </p>
379 <p><b>Description</b> </p>
381 <p>The "<tt>glutInitWindowPosition</tt>
382 " and "<tt>glutInitWindowSize</tt>" functions specify a desired position
383 and size for windows that <i>freeglut</i> will create in the future.
384 The position is measured in pixels from the upper left hand corner of the
385 screen, with "x" increasing to the right and "y" increasing towards the bottom
386 of the screen. The size is measured in pixels. <i>Freeglut</i>
387 does not promise to follow these specifications in creating its windows,
388 it certainly makes an attempt to. </p>
390 <p>The position and size of a window are
391 a matter of some subtlety. Most windows have a usable area surrounded
392 by a border and with a title bar on the top. The border and title bar
393 are commonly called "decorations." The position of the window unfortunately
394 varies with the operating system. On Linux, it is the coordinates of
395 the upper left-hand corner of its decorations. On Windows, it is the
396 coordinates of the upper left hand corner of its usable interior. For
397 both operating systems, the size of the window is the size of the usable interior.
400 <p>Windows has some additional quirks which
401 the application programmer should know about. First, the minimum y-coordinate
402 of a window decoration is zero. (This is a feature of <i>freeglut</i>
403 and can be adjusted if so desired.) Second, there appears to be a
404 minimum window width on Windows which is 104 pixels. The user may specify
405 a smaller width, but the Windows system calls ignore it. It is also
406 impossible to make a window narrower than this by dragging on its corner.
409 <p><b>Changes From GLUT</b> </p>
411 <p>For some reason, GLUT is not affected
412 by the 104-pixel minimum window width. If the user clicks on the corner
413 of a window which is narrower than this amount, the window will immediately
414 snap out to this width, but the application can call "<tt>glutReshapeWindow</tt>
415 " and make a window narrower again. </p>
417 <h2> 4.3 glutInitDisplayMode</h2>
419 <h2> 4.4 glutInitDisplayString</h2>
421 <h1> 5.0 <a name="EventProcessing"></a>
422 Event Processing Functions</h1>
423 After an application has finished initializing its windows and menus, it
424 enters an event loop. Within this loop, <i>freeglut</i> polls the
425 data entry devices (keyboard, mouse, etc.) and calls the application's appropriate
427 <p>In GLUT, control never returned from
428 the event loop (as invoked by the "<tt>glutMainLoop</tt>" function) to the
429 calling function. This prevented an application from having re-entrant
430 code, in which GLUT could be invoked from within a callback, and it prevented
431 the application from doing any post-processing (such as freeing allocated
432 memory) after GLUT had closed down. <i>Freeglut</i> allows the application
433 programmer to specify more direct control over the event loop by means of
434 two new functions. The first, "<tt>glutMainLoopEvent</tt>", processes
435 a single iteration of the event loop and allows the application to use a different
436 event loop controller or to contain re-entrant code. The second, "<tt>
437 glutLeaveMainLoop</tt>", causes the event loop to exit nicely; this is preferable
438 to the application's calling "<tt>exit</tt>" from within a GLUT callback.
441 <h2> 5.1 glutMainLoop</h2>
442 The "<tt>glutMainLoop</tt>" function enters the event loop.
446 <p><tt>void glutMainLoop ( void ) ;</tt>
449 <p><b>Description</b> </p>
451 <p>The "<tt>glutMainLoop</tt>" function
452 causes the program to enter the window event loop. An application should
453 call this function at most once. It will call any application callback
454 functions as required to process mouse clicks, mouse motion, key presses,
457 <p><b>Changes From GLUT</b> </p>
459 <p>In GLUT, there was absolutely no way
460 for the application programmer to have control return from the "<tt>glutMainLoop</tt>
461 " function to the calling function. <i>Freeglut</i> allows the programmer
462 to force this by setting the "<tt>GLUT_ACTION_ON_WINDOW_CLOSE</tt>" option
463 and invoking the "<tt>glutLeaveMainLoop</tt>" function from one of the callbacks.
464 Stopping the program this way is preferable to simply calling "<tt>exit</tt>
465 " from within a callback because this allows <i>freeglut</i> to free allocated
466 memory and otherwise clean up after itself. (I know I just said this,
467 but I think it is important enough that it bears repeating.) </p>
469 <h2> 5.2 glutMainLoopEvent</h2>
470 The "<tt>glutMainLoopEvent</tt>" function processes a single iteration
471 in the <i>freeglut</i> event loop.
474 <p><tt>void glutMainLoopEvent ( void ) ;</tt>
477 <p><b>Description</b> </p>
479 <p>The "<tt>glutMainLoopEvent</tt>
480 " function causes <i>freeglut</i> to process one iteration's worth of events
481 in its event loop. This allows the application to control its own event
482 loop and still use the <i>freeglut</i> windowing system. </p>
484 <p><b>Changes From GLUT</b> </p>
486 <p>GLUT does not include this function.
489 <h2> 5.3 glutLeaveMainLoop</h2>
490 The "<tt>glutLeaveMainLoop</tt>" function causes <i>freeglut</i> to stop
494 <p><tt>void glutLeaveMainLoop ( void ) ;</tt>
497 <p><b>Description</b> </p>
499 <p>The "<tt>glutLeaveMainLoop</tt>
500 " function causes <i>freeglut</i> to stop the event loop. If the
501 "<tt> GLUT_ACTION_ON_WINDOW_CLOSE</tt>" option has been set to "<tt>GLUT_ACTION_CONTINUE_EXECUTION</tt>
502 ", control will return to the function which called "<tt>glutMainLoop</tt>
503 "; otherwise the application will exit. </p>
505 <p>If the application has two nested calls
506 to "<tt>glutMainLoop</tt>" and calls "<tt>glutLeaveMainLoop</tt>", the behaviour
507 of <i>freeglut</i> is undefined. It may leave only the inner nested
508 loop or it may leave both loops. If the reader has a strong preference
509 for one behaviour over the other he should contact the <i>freeglut</i> Programming
510 Consortium and ask for the code to be fixed. </p>
512 <p><b>Changes From GLUT</b> </p>
514 <p>GLUT does not include this function.
517 <h1> 6.0 <a name="Window"></a>
518 Window Functions</h1>
520 <h2> 6.1 glutCreateWindow</h2>
522 <h2> 6.2 glutCreateSubwindow</h2>
524 <h2> 6.3 glutDestroyWindow</h2>
526 <h2> 6.4 glutSetWindow, glutGetWindow</h2>
528 <h2> 6.5 glutSetWindowTitle, glutSetIconTitle</h2>
530 <h2> 6.6 glutReshapeWindow</h2>
532 <h2> 6.7 glutPositionWindow</h2>
534 <h2> 6.8 glutShowWindow, glutHideWindow,
535 glutIconifyWindow</h2>
537 <h2> 6.9 glutPushWindow, glutPopWindow</h2>
539 <h2> 6.10 glutFullScreen</h2>
541 <h1> 7.0 <a name="Display"></a>
542 Display Functions</h1>
544 <h2> 7.1 glutPostRedisplay</h2>
546 <h2> 7.2 glutPostWindowRedisplay</h2>
548 <h2> 7.3 glutSwapBuffers</h2>
550 <h1> 8.0 <a name="MouseCursor"></a>
551 Mouse Cursor Functions</h1>
553 <h2> 8.1 glutSetCursor</h2>
555 <h2> 8.2 glutWarpPointer</h2>
557 <h1> 9.0 <a name="Overlay"></a>
558 Overlay Functions</h1>
559 <i>Freeglut</i> does not allow overlays, although it does "answer the mail"
560 with function stubs so that GLUT-based programs can compile and link against
561 <i>freeglut</i> without modification.
562 If the reader needs overlays, he should contact the <i>freeglut</i> Programming
563 Consortium and ask for them to be implemented. He should also be prepared
564 to assist in the implementation.
565 <h2> 9.1 glutEstablishOverlay</h2>
566 The "<tt>glutEstablishOverlay</tt>" function is not implemented in <i>freeglut</i>
570 <p><tt>void glutEstablishOverlay ( void
573 <p><b>Description</b> </p>
575 <p>The "<tt>glutEstablishOverlay</tt>" function
576 is not implemented in <i>freeglut</i>. </p>
578 <p><b>Changes From GLUT</b> </p>
580 <p>GLUT implements this function. </p>
582 <h2> 9.2 glutRemoveOverlay</h2>
583 The "<tt>glutRemoveOverlay</tt>" function is not implemented in <i>freeglut</i>
587 <p><tt>void glutRemoveOverlay ( void ) ;</tt>
590 <p><b>Description</b> </p>
592 <p>The "<tt>glutRemoveOverlay</tt>" function
593 is not implemented in <i>freeglut</i>. </p>
595 <p><b>Changes From GLUT</b> </p>
597 <p>GLUT implements this function. </p>
599 <h2> 9.3 glutUseLayer</h2>
600 The "<tt>glutUseLayer</tt>" function is not implemented in <i>freeglut</i>
604 <p><tt>void glutUseLayer ( GLenum
607 <p><b>Description</b> </p>
609 <p>The "<tt>glutUseLayer</tt>" function
610 is not implemented in <i>freeglut</i>. </p>
612 <p><b>Changes From GLUT</b> </p>
614 <p>GLUT implements this function. </p>
616 <h2> 9.4 glutPostOverlayRedisplay</h2>
617 The "<tt>glutPostOverlayRedisplay</tt> " function is not implemented in
622 <p><tt>void glutPostOverlayRedisplay ( void
625 <p><b>Description</b> </p>
627 <p>The "<tt>glutPostOverlayRedisplay</tt>
628 " function is not implemented in <i>freeglut</i>. </p>
630 <p><b>Changes From GLUT</b> </p>
632 <p>GLUT implements this function. </p>
634 <h2> 9.5 glutPostWindowOverlayRedisplay</h2>
635 The "<tt>glutPostWindowOverlayRedisplay</tt> " function is not implemented
639 <p><tt>void glutPostWindowOverlayRedisplay
640 ( int window ) ;</tt> </p>
642 <p><b>Description</b> </p>
644 <p>The "<tt>glutPostWindowOverlayRedisplay</tt>
645 " function is not implemented in <i>freeglut</i>. </p>
647 <p><b>Changes From GLUT</b> </p>
649 <p>GLUT implements this function. </p>
651 <h2> 9.6 glutShowOverlay, glutHideOverlay</h2>
652 The "<tt>glutShowOverlay</tt>" and "<tt>glutHideOverlay</tt>" functions
653 are not implemented in <i>freeglut</i> .
657 <p><tt>void glutShowOverlay( void ) ;</tt>
659 <tt>void glutHideOverlay( void ) ;</tt>
662 <p><b>Description</b> </p>
664 <p>The "<tt>glutShowOverlay</tt>" and "<tt>
665 glutHideOverlay</tt>" functions are not implemented in <i>freeglut</i> .
668 <p><b>Changes From GLUT</b> </p>
670 <p>GLUT implements these functions. </p>
672 <h1> 10.0 <a name="Menu"></a>
675 <h2> 10.1 glutCreateMenu</h2>
677 <h2> 10.2 glutDestroyMenu</h2>
679 <h2> 10.3 glutGetMenu, glutSetMenu</h2>
681 <h2> 10.4 glutAddMenuEntry</h2>
683 <h2> 10.5 glutAddSubMenu</h2>
685 <h2> 10.6 glutChangeToMenuEntry</h2>
687 <h2> 10.7 glutChangeToSubMenu</h2>
689 <h2> 10.8 glutRemoveMenuItem</h2>
691 <h2> 10.9 glutAttachMenu, glutDetachMenu</h2>
693 <h1> 11.0 <a name="GlobalCallback"></a>
694 Global Callback Registration Functions</h1>
696 <h2> 11.1 glutTimerFunc</h2>
698 <h2> 11.2 glutIdleFunc</h2>
699 The "<tt>glutIdleFunc</tt>" function sets the global idle callback. <i>
700 Freeglut</i> calls the idle callback when there are no inputs from the user.
704 <p><tt>void glutIdleFunc ( void (*func)
705 ( void ) ) ;</tt> </p>
707 <p><tt>func </tt>The new
708 global idle callback function </p>
710 <p><b>Description</b> </p>
712 <p>The "<tt>glutIdleFunc</tt>" function
713 specifies the function that <i>freeglut</i> will call to perform background
714 processing tasks such as continuous animation when window system events are
715 not being received. If enabled, this function is called continuously
716 from <i>freeglut</i> while no events are received. The callback function
717 has no parameters and returns no value. <i>Freeglut</i> does not change
718 the <i>current window</i> or the <i>current menu</i> before invoking the idle
719 callback; programs with multiple windows or menus must explicitly set the
720 <i>current window</i> and <i>current menu</i>
721 and not rely on its current setting. <br>
722 The amount of computation and rendering done in an idle
723 callback should be minimized to avoid affecting the program's interactive
724 response. In general, no more than a single frame of rendering should
725 be done in a single invocation of an idle callback. <br>
726 Calling "<tt>glutIdleFunc</tt>" with a NULL argument
727 disables the call to an idle callback. </p>
729 <p><b>Changes From GLUT</b> </p>
731 <p>Application programmers should note that
732 if they have specified the "continue execution" action on window closure,
733 <i>freeglut</i> will continue to call the
734 idle callback after the user has closed a window by clicking on the "x" in
735 the window header bar. If the idle callback renders a particular window
736 (this is considered bad form but is frequently done anyway), the programmer
737 should supply a window closure callback for that window which changes or disables
738 the idle callback. </p>
740 <h1> 12.0 <a name="WindowCallback"></a>
741 Window-Specific Callback Registration Functions</h1>
743 <h2> 12.1 glutDisplayFunc</h2>
745 <h2> 12.2 glutOverlayDisplayFunc</h2>
747 <h2> 12.3 glutReshapeFunc</h2>
749 <h2> 12.4 glutCloseFunc</h2>
751 <h2> 12.5 glutKeyboardFunc</h2>
753 <h2> 12.6 glutSpecialFunc</h2>
754 The "<tt>glutSpecialFunc</tt>" function sets the window's special key press
755 callback. <i>Freeglut</i> calls the special key press callback when the
756 user presses a special key.
759 <p><tt>void glutSpecialFunc ( void (*func)
760 ( int key, int x, int y ) ) ;</tt> </p>
762 <p><tt>func </tt>The window's
763 new special key press callback function <br>
764 <tt>key </tt>The
765 key whose press triggers the callback <br>
766 <tt>x
767 </tt>The x-coordinate of the mouse relative
768 to the window at the time the key is pressed <br>
769 <tt>y
770 </tt>The y-coordinate of the mouse relative
771 to the window at the time the key is pressed </p>
773 <p><b>Description</b> </p>
775 <p>The "<tt>glutSpecialFunc</tt>"
776 function specifies the function that <i>freeglut</i> will call when the user
777 presses a special key on the keyboard. The callback function has one
778 argument: the name of the function to be invoked ("called back") at
779 the time at which the special key is pressed. The function returns no
780 value. <i>Freeglut</i> sets the <i>current window</i> to the window
781 which is active when the callback is invoked. "Special keys" are the
782 function keys, the arrow keys, the Page Up and Page Down keys, and the Insert
783 key. The Delete key is considered to be a regular key. <br>
784 Calling "<tt>glutSpecialUpFunc</tt>" with a NULL argument
785 disables the call to the window's special key press callback. </p>
787 <p> The "<tt>key</tt>
788 " argument may take one of the following defined constant values: </p>
791 <li> <tt>GLUT_KEY_F1, GLUT_KEY_F2, ..., GLUT_KEY_F12</tt>
792 - F1 through F12 keys</li>
793 <li> <tt>GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN</tt>
794 - Page Up and Page Down keys</li>
795 <li> <tt>GLUT_KEY_HOME, GLUT_KEY_END</tt>
796 - Home and End keys</li>
797 <li> <tt>GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN</tt>
799 <li> <tt>GLUT_KEY_INSERT</tt>
803 <b>Changes From GLUT</b>
806 <h2> 12.7 glutKeyboardUpFunc</h2>
807 The "<tt>glutKeyboardUpFunc</tt>" function sets the window's key release
808 callback. <i>Freeglut</i> calls the key release callback when the user releases
812 <p><tt>void glutKeyboardUpFunc ( void (*func)
813 ( unsigned char key, int x, int y ) ) ;</tt> </p>
815 <p><tt>func </tt>The window's
816 new key release callback function <br>
817 <tt>key </tt>The
818 key whose release triggers the callback <br>
819 <tt>x
820 </tt>The x-coordinate of the mouse relative
821 to the window at the time the key is released <br>
822 <tt>y
823 </tt>The y-coordinate of the mouse relative
824 to the window at the time the key is released </p>
826 <p><b>Description</b> </p>
828 <p>The "<tt>glutKeyboardUpFunc</tt>
829 " function specifies the function that <i>freeglut</i> will call when the
830 user releases a key from the keyboard. The callback function has one
831 argument: the name of the function to be invoked ("called back") at
832 the time at which the key is released. The function returns no value.
833 <i>Freeglut</i> sets the <i>current window</i>
834 to the window which is active when the callback is invoked. <br>
835 While <i>freeglut</i> checks for upper or lower case
836 letters, it does not do so for non-alphabetical characters. Nor does
837 it account for the Caps-Lock key being on. The operating system may
838 send some unexpected characters to <i>freeglut</i>, such as "8" when the
839 user is pressing the Shift key. <i>Freeglut</i> also invokes the callback
840 when the user releases the Control, Alt, or Shift keys, among others.
841 Releasing the Delete key causes this function to be invoked with a value
842 of 127 for "<tt>key</tt>". <br>
843 Calling "<tt>glutKeyboardUpFunc</tt>" with a NULL argument
844 disables the call to the window's key release callback. </p>
846 <p><b>Changes From GLUT</b> </p>
848 <p>This function is not implemented in GLUT
849 versions before Version 4. It has been designed to be as close to GLUT
850 as possible. Users who find differences should contact the
851 <i>freeglut</i> Programming Consortium to
852 have them fixed. </p>
854 <h2> 12.8 glutSpecialUpFunc</h2>
855 The "<tt>glutSpecialUpFunc</tt>" function sets the window's special key
856 release callback. <i>Freeglut</i> calls the special key release callback
857 when the user releases a special key.
860 <p><tt>void glutSpecialUpFunc ( void (*func)
861 ( int key, int x, int y ) ) ;</tt> </p>
863 <p><tt>func </tt>The window's
864 new special key release callback function <br>
865 <tt>key </tt>The
866 key whose release triggers the callback <br>
867 <tt>x
868 </tt>The x-coordinate of the mouse relative
869 to the window at the time the key is released <br>
870 <tt>y
871 </tt>The y-coordinate of the mouse relative
872 to the window at the time the key is released </p>
874 <p><b>Description</b> </p>
876 <p>The "<tt>glutSpecialUpFunc</tt>
877 " function specifies the function that <i>freeglut</i> will call when the
878 user releases a special key from the keyboard. The callback function
879 has one argument: the name of the function to be invoked ("called back")
880 at the time at which the special key is released. The function returns
881 no value. <i>Freeglut</i> sets the <i>current window</i> to the window
882 which is active when the callback is invoked. "Special keys" are the
883 function keys, the arrow keys, the Page Up and Page Down keys, and the Insert
884 key. The Delete key is considered to be a regular key. <br>
885 Calling "<tt>glutSpecialUpFunc</tt>" with a NULL argument
886 disables the call to the window's special key release callback. </p>
888 <p> The "<tt>key</tt>
889 " argument may take one of the following defined constant values: </p>
892 <li> <tt>GLUT_KEY_F1, GLUT_KEY_F2, ..., GLUT_KEY_F12</tt>
893 - F1 through F12 keys</li>
894 <li> <tt>GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN</tt>
895 - Page Up and Page Down keys</li>
896 <li> <tt>GLUT_KEY_HOME, GLUT_KEY_END</tt>
897 - Home and End keys</li>
898 <li> <tt>GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN</tt>
900 <li> <tt>GLUT_KEY_INSERT</tt>
904 <b>Changes From GLUT</b>
905 <p>This function is not implemented in GLUT
906 versions before Version 4. It has been designed to be as close to GLUT
907 as possible. Users who find differences should contact the
908 <i>freeglut</i> Programming Consortium to
909 have them fixed. </p>
911 <h2> 12.9 glutMouseFunc</h2>
913 <h2> 12.10 glutMotionFunc, glutPassiveMotionFunc</h2>
915 <h2> 12.11 glutVisibilityFunc</h2>
917 <h2> 12.12 glutEntryFunc</h2>
919 <h2> 12.13 glutJoystickFunc</h2>
921 <h2> 12.14 glutSpaceballMotionFunc</h2>
922 The "<tt>glutSpaceballMotionFunc</tt>" function is not implemented in
923 <i>freeglut</i>, although the library does
924 "answer the mail" to the extent that a call to the function will not produce
928 <p><tt>void glutSpaceballMotionFunc ( void
929 (* callback)( int x, int y, int z )</tt><tt> ) ;</tt></p>
931 <p><b>Description</b></p>
933 <p>The "<tt>glutSpaceballMotionFunc</tt>
934 " function is not implemented in <i>freeglut</i>. </p>
936 <p><b>Changes From GLUT</b></p>
938 <p>GLUT implements this function. </p>
940 <h2> 12.15 glutSpaceballRotateFunc</h2>
941 The "<tt>glutSpaceballRotateFunc</tt>" function is not implemented in
942 <i>freeglut</i>, although the library does
943 "answer the mail" to the extent that a call to the function will not produce
947 <p><tt>void glutSpaceballRotateFunc ( void
948 (* callback)( int x, int y, int z )</tt><tt> ) ;</tt></p>
950 <p><b>Description</b></p>
952 <p>The "<tt>glutSpaceballRotateFunc</tt>
953 " function is not implemented in <i>freeglut</i>. </p>
955 <p><b>Changes From GLUT</b></p>
957 <p>GLUT implements this function. </p>
959 <h2> 12.16 glutSpaceballButtonFunc</h2>
960 The "<tt>glutSpaceballButtonFunc</tt>" function is not implemented in
961 <i>freeglut</i>, although the library does
962 "answer the mail" to the extent that a call to the function will not produce
966 <p><tt>void glutSpaceballButtonFunc ( void
967 (* callback)( int button, int updown )</tt><tt> ) ;</tt></p>
969 <p><b>Description</b></p>
971 <p>The "<tt>glutSpaceballButtonFunc</tt>
972 " function is not implemented in <i>freeglut</i>. </p>
974 <p><b>Changes From GLUT</b></p>
976 <p>GLUT implements this function. </p>
978 <h2> 12.17 glutButtonBoxFunc</h2>
979 The "<tt>glutSpaceballButtonBoxFunc</tt>" function is not implemented
980 in <i>freeglut</i>, although the library does "answer the mail" to the extent
981 that a call to the function will not produce an error..
985 <p><tt>void glutSpaceballButtonBoxFunc (
986 void (* callback)( int button, int updown )</tt><tt> ) ;</tt></p>
988 <p><b>Description</b></p>
990 <p>The "<tt>glutSpaceballButtonBoxFunc</tt>
991 " function is not implemented in <i>freeglut</i>. </p>
993 <p><b>Changes From GLUT</b></p>
995 <p>GLUT implements this function. </p>
997 <h2> 12.18 glutDialsFunc</h2>
998 The "<tt>glutDialsFunc</tt>" function is not implemented in <i>freeglut</i>
999 , although the library does "answer the mail" to the extent that a call
1000 to the function will not produce an error..
1004 <p><tt>void glutDialsFunc ( void (* callback)(
1005 int dial, int value )</tt><tt> ) ;</tt></p>
1007 <p><b>Description</b></p>
1009 <p>The "<tt>glutDialsFunc</tt>" function
1010 is not implemented in <i>freeglut</i>. </p>
1012 <p><b>Changes From GLUT</b></p>
1014 <p>GLUT implements this function. </p>
1016 <h2> 12.19 glutTabletMotionFunc</h2>
1017 The "<tt>glutTabletMotionFunc</tt>" function is not implemented in <i>
1018 freeglut</i>, although the library does "answer the mail" to the extent
1019 that a call to the function will not produce an error..
1023 <p><tt>void glutTabletMotionFunc ( void
1024 (* callback)( int x, int y )</tt><tt> ) ;</tt></p>
1026 <p><b>Description</b></p>
1028 <p>The "<tt>glutTabletMotionFunc</tt>" function
1029 is not implemented in <i>freeglut</i>. </p>
1031 <p><b>Changes From GLUT</b></p>
1033 <p>GLUT implements this function. </p>
1035 <h2> 12.20 glutTabletButtonFunc</h2>
1036 The "<tt>glutTabletButtonFunc</tt>" function is not implemented in <i>
1037 freeglut</i>, although the library does "answer the mail" to the extent
1038 that a call to the function will not produce an error..
1042 <p><tt>void glutTabletButtonFunc ( void
1043 (* callback)( int button, int updown, int x, int y )</tt><tt> ) ;</tt></p>
1045 <p><b>Description</b></p>
1047 <p>The "<tt>glutTabletButtonFunc</tt>" function
1048 is not implemented in <i>freeglut</i>. </p>
1050 <p><b>Changes From GLUT</b></p>
1052 <p>GLUT implements this function. </p>
1054 <h2> 12.21 glutMenuStatusFunc</h2>
1056 <h2> 12.22 glutWindowStatusFunc</h2>
1058 <h1> 13.0 <a name="StateSetting"></a>
1059 State Setting and Retrieval Functions</h1>
1061 <h2> 13.1 glutSetOption</h2>
1063 <h2> 13.2 glutGet</h2>
1067 The following state variables may be queried with "<tt>glutGet</tt>".
1068 The returned value is an integer.
1072 These queries are with respect to the current window:
1076 <li>GLUT_WINDOW_X - window X position
1077 <li>GLUT_WINDOW_Y - window Y position
1078 <li>GLUT_WINDOW_WIDTH - window width
1079 <li>GLUT_WINDOW_HEIGHT - window height
1080 <li>GLUT_WINDOW_BUFFER_SIZE - number of color or color index bits per pixel
1081 <li>GLUT_WINDOW_STENCIL_SIZE - number of bits per stencil value
1082 <li>GLUT_WINDOW_DEPTH_SIZE - number of bits per depth value
1083 <li>GLUT_WINDOW_RED_SIZE - number of bits per red value
1084 <li>GLUT_WINDOW_GREEN_SIZE - number of bits per green value
1085 <li>GLUT_WINDOW_BLUE_SIZE - number of bits per blue value
1086 <li>GLUT_WINDOW_ALPHA_SIZE - number of bits per alpha value
1087 <li>GLUT_WINDOW_ACCUM_RED_SIZE - number of red bits in the accumulation buffer
1088 <li>GLUT_WINDOW_ACCUM_GREEN_SIZE - number of green bits in the accumulation buffer
1089 <li>GLUT_WINDOW_ACCUM_BLUE_SIZE - number of blue bits in the accumulation buffer
1090 <li>GLUT_WINDOW_ACCUM_ALPHA_SIZE - number of alpha bits in the accumulation buffer
1091 <li>GLUT_WINDOW_DOUBLEBUFFER - 1 if the color buffer is double buffered, 0 otherwise
1092 <li>GLUT_WINDOW_RGBA - 1 if the color buffers are RGB[A], 0 for color index
1093 <li>GLUT_WINDOW_PARENT - parent window ID
1094 <li>GLUT_WINDOW_NUM_CHILDREN - number of child windows
1095 <li>GLUT_WINDOW_COLORMAP_SIZE - number of entries in the window's colormap
1096 <li>GLUT_WINDOW_NUM_SAMPLES - number of samples per pixel if using multisampling
1097 <li>GLUT_WINDOW_STEREO - 1 if the window supports stereo, 0 otherwise
1098 <li>GLUT_WINDOW_CURSOR - current cursor
1099 <li>GLUT_WINDOW_FORMAT_ID - on Windows, return the pixel format number of the current window
1103 These queries do not depend on the current window.
1107 <li>GLUT_SCREEN_WIDTH - width of the screen in pixels
1108 <li>GLUT_SCREEN_HEIGHT - height of the screen in pixels
1109 <li>GLUT_SCREEN_WIDTH_MM - width of the screen in millimeters
1110 <li>GLUT_SCREEN_HEIGHT_MM - height of the screen in millimeters
1111 <li>GLUT_MENU_NUM_ITEMS - number of items in the current menu
1112 <li>GLUT_DISPLAY_MODE_POSSIBLE - return 1 if the current display mode is supported, 0 otherwise
1113 <li>GLUT_INIT_WINDOW_X - X position last set by glutInitWindowPosition
1114 <li>GLUT_INIT_WINDOW_Y - Y position last set by glutInitWindowPosition
1115 <li>GLUT_INIT_WINDOW_WIDTH - width last set by glutInitWindowSize
1116 <li>GLUT_INIT_WINDOW_HEIGHT - height last set by glutInitWindowSize
1117 <li>GLUT_INIT_DISPLAY_MODE - display mode last set by glutInitDisplayMode
1118 <li>GLUT_ELAPSED_TIME - time (in milliseconds) elapsed since glutInit or glutGet(GLUT_ELAPSED_TIME) was first called
1119 <li>GLUT_INIT_STATE - ?
1120 <li>GLUT_VERSION - Return value will be X*10000+Y*100+Z where X is the
1121 major version, Y is the minor version and Z is the patch level.
1122 This query is only supported in <i>freeglut</i> (version 2.0.0 or later).
1126 <h2> 13.3 glutDeviceGet</h2>
1128 <h2> 13.4 glutGetModifiers</h2>
1130 <h2> 13.5 glutLayerGet</h2>
1132 <h2> 13.6 glutExtensionSupported</h2>
1134 <h2> 13.7 glutGetProcAddress</h2>
1135 <p><tt>glutGetProcAddress</tt> returns
1136 a pointer to a named GL or <i>freeglut</i> function. </p>
1138 <p><tt>void *glutGetProcAddress ( const
1139 char *procName ) ;</tt></p>
1140 <p><tt>procName
1141 </tt>Name of an OpenGL or GLUT function.
1143 <p><b>Description</b></p>
1144 <p><tt>glutGetProcAddress</tt> is useful
1145 for dealing with OpenGL extensions. If an application calls OpenGL extension
1146 functions directly, that application will only link/run with an OpenGL library
1147 that supports the extension. By using a function pointer returned from glutGetProcAddress(),
1148 the application will avoid this hard dependency and be more portable and interoperate
1149 better with various implementations of OpenGL. </p>
1150 <p> Both OpenGL functions and <i>freeglut</i>
1151 functions can be queried with this function. </p>
1152 <p><b>Changes From GLUT</b> </p>
1154 <p>GLUT does not include this function.
1157 <h1> 14.0 <a name="FontRendering"></a>
1158 Font Rendering Functions</h1>
1159 <i>Freeglut</i> supports two types of font rendering: bitmap fonts,
1160 which are rendered using the "<tt>glBitmap</tt>" function call, and stroke
1161 fonts, which are rendered as sequences of OpenGL line segments. Because
1162 they are rendered as bitmaps, the bitmap fonts tend to render more quickly
1163 than stroke fonts, but they are less flexible in terms of scaling and rendering.
1164 Bitmap font characters are positioned with calls to the "<tt>glRasterPos*</tt>
1165 " functions while stroke font characters use the OpenGL transformations
1166 to position characters.
1167 <p> It should be noted
1168 that <i>freeglut</i> fonts are similar but not identical to GLUT fonts.
1169 At the moment, <i>freeglut</i> fonts do not support the "`" (backquote) and
1170 "|" (vertical line) characters; in their place it renders asterisks. </p>
1172 <p> <i>Freeglut</i> supports
1173 the following bitmap fonts: </p>
1176 <li> <tt>GLUT_BITMAP_8_BY_13</tt> - A variable-width font with every character
1177 fitting in a rectangle of 13 pixels high by at most 8 pixels wide.</li>
1178 <li> <tt>GLUT_BITMAP_9_BY_15</tt> - A variable-width font with every character
1179 fitting in a rectangle of 15 pixels high by at most 9 pixels wide.</li>
1180 <li> <tt>GLUT_BITMAP_TIMES_ROMAN_10</tt> - A 10-point variable-width Times
1182 <li> <tt>GLUT_BITMAP_TIMES_ROMAN_24</tt> - A 24-point variable-width Times
1184 <li> <tt>GLUT_BITMAP_HELVETICA_10</tt> - A 10-point variable-width Helvetica
1186 <li> <tt>GLUT_BITMAP_HELVETICA_12</tt> - A 12-point variable-width Helvetica
1188 <li> <tt>GLUT_BITMAP_HELVETICA_18</tt> - A 18-point variable-width Helvetica
1192 <i>Freeglut</i> calls "<tt>glRasterPos4v</tt>" to advance the cursor by
1193 the width of a character and to render carriage returns when appropriate.
1194 It does not use any display lists in it rendering in bitmap fonts.
1196 <p> <i>Freeglut</i> supports
1197 the following stroke fonts: </p>
1200 <li> <tt>GLUT_STROKE_ROMAN</tt> - A proportionally-spaced Roman Simplex
1202 <li> <tt>GLUT_STROKE_MONO_ROMAN</tt> - A fixed-width Roman Simplex font</li>
1205 <i>Freeglut</i> does not use any display lists in its rendering of stroke
1206 fonts. It calls "<tt>glTranslatef</tt>" to advance the cursor by the
1207 width of a character and to render carriage returns when appropriate.
1209 <h2> 14.1 glutBitmapCharacter</h2>
1210 The "<tt>glutBitmapCharacter</tt>" function renders a single bitmapped
1211 character in the <i>current window</i> using the specified font.
1213 <p><b>Usage</b> </p>
1215 <p><tt>void glutBitmapCharacter ( void *font,
1216 int character ) ;</tt> </p>
1218 <p><tt>font
1219 </tt>The bitmapped font to use in rendering
1221 <tt>character </tt>The ASCII
1222 code of the character to be rendered </p>
1224 <p><b>Description</b> </p>
1226 <p>The "<tt>glutBitmapCharacter</tt>
1227 " function renders the given character in the specified bitmap font.
1228 <i>Freeglut</i> automatically sets the necessary
1229 pixel unpack storage modes and restores the existing modes when it has finished.
1230 Before the first call to "<tt>glutBitMapCharacter</tt> " the application
1231 program should call "<tt>glRasterPos*</tt>" to set the position of the character
1232 in the window. The "<tt>glutBitmapCharacter</tt> " function advances
1233 the cursor position as part of its call to "<tt>glBitmap</tt> " and so the
1234 application does not need to call "<tt>glRasterPos*</tt>" again for successive
1235 characters on the same line. </p>
1237 <p><b>Changes From GLUT</b> </p>
1239 <p>Nonexistent characters are rendered as
1240 asterisks. The rendering position in <i>freeglut</i> is apparently off
1241 from GLUT's position by a few pixels vertically and one or two pixels horizontally.
1244 <h2> 14.2 glutBitmapString</h2>
1245 The "<tt>glutBitmapString</tt>" function renders a string of bitmapped
1246 characters in the <i>current window</i> using the specified font.
1248 <p><b>Usage</b> </p>
1250 <p><tt>void glutBitmapString ( void *font,
1251 char *string ) ;</tt> </p>
1253 <p><tt>font
1254 </tt>The bitmapped font to use in rendering
1255 the character string <br>
1256 <tt>string </tt>String
1257 of characters to be rendered </p>
1259 <p><b>Description</b> </p>
1261 <p>The "<tt>glutBitmapString</tt>
1262 " function renders the given character string in the specified bitmap font.
1263 <i>Freeglut</i> automatically sets the necessary
1264 pixel unpack storage modes and restores the existing modes when it has finished.
1265 Before calling "<tt>glutBitMapString</tt>" the application program should
1266 call "<tt>glRasterPos*</tt>" to set the position of the string in the window.
1267 The "<tt>glutBitmapString</tt>" function handles carriage returns.
1268 Nonexistent characters are rendered as asterisks. </p>
1270 <p><b>Changes From GLUT</b> </p>
1272 <p>GLUT does not include this function.
1275 <h2> 14.3 glutBitmapWidth</h2>
1276 The "<tt>glutBitmapWidth</tt>" function returns the width in pixels of
1277 a single bitmapped character in the specified font.
1279 <p><b>Usage</b> </p>
1281 <p><tt>int glutBitmapWidth ( void *font,
1282 int character ) ;</tt> </p>
1284 <p><tt>font
1285 </tt>The bitmapped font to use in calculating
1286 the character width <br>
1287 <tt>character </tt>The ASCII
1288 code of the character </p>
1290 <p><b>Description</b> </p>
1292 <p>The "<tt>glutBitmapWidth</tt>"
1293 function returns the width of the given character in the specified bitmap
1294 font. Because the font is bitmapped, the width is an exact integer.
1297 <p><b>Changes From GLUT</b> </p>
1299 <p>Nonexistent characters return the width
1300 of an asterisk. </p>
1302 <h2> 14.4 glutBitmapLength</h2>
1303 The "<tt>glutBitmapLength</tt>" function returns the width in pixels of
1304 a string of bitmapped characters in the specified font.
1306 <p><b>Usage</b> </p>
1308 <p><tt>int glutBitmapLength ( void *font,
1309 char *string ) ;</tt> </p>
1311 <p><tt>font </tt>The bitmapped
1312 font to use in calculating the character width <br>
1313 <tt>string </tt>String of characters
1314 whose width is to be calculated </p>
1316 <p><b>Description</b> </p>
1318 <p>The "<tt>glutBitmapLength</tt>
1319 " function returns the width in pixels of the given character string in
1320 the specified bitmap font. Because the font is bitmapped, the width
1321 is an exact integer: the return value is identical to the sum of the
1322 character widths returned by a series of calls to "<tt>glutBitmapWidth</tt>
1323 ". The width of nonexistent characters is counted to be the width of
1326 <p> If the string contains
1327 one or more carriage returns, <i>freeglut</i> calculates the widths in pixels
1328 of the lines separately and returns the largest width. </p>
1330 <p><b>Changes From GLUT</b> </p>
1332 <p>GLUT does not include this function.
1335 <h2> 14.5 glutBitmapHeight</h2>
1336 The "<tt>glutBitmapHeight</tt>" function returns the height in pixels of
1338 <p><b>Usage</b> </p>
1340 <p><tt>int glutBitmapHeight ( void *font
1343 <p><tt>font
1344 </tt>The bitmapped font to use in calculating
1345 the character height </p>
1347 <p><b>Description</b> </p>
1349 <p>The "<tt>glutBitmapHeight</tt>
1350 " function returns the height of a character in the specified bitmap font.
1351 Because the font is bitmapped, the height is an exact integer. The fonts
1352 are designed such that all characters have (nominally) the same height.
1355 <p><b>Changes From GLUT</b> </p>
1357 <p>GLUT does not include this function.
1360 <h2> 14.6 glutStrokeCharacter</h2>
1361 The "<tt>glutStrokeCharacter</tt>" function renders a single stroke character
1362 in the <i>current window</i> using the specified font.
1364 <p><b>Usage</b> </p>
1366 <p><tt>void glutStrokeCharacter ( void *font,
1367 int character ) ;</tt> </p>
1369 <p><tt>font
1370 </tt>The stroke font to use in rendering
1372 <tt>character </tt>The ASCII
1373 code of the character to be rendered </p>
1375 <p><b>Description</b> </p>
1377 <p>The "<tt>glutStrokeCharacter</tt>
1378 " function renders the given character in the specified stroke font.
1379 Before the first call to "<tt>glutStrokeCharacter</tt>" the application program
1380 should call the OpenGL transformation (positioning and scaling) functions
1381 to set the position of the character in the window. The "<tt>glutStrokeCharacter</tt>
1382 " function advances the cursor position by a call to "<tt>glTranslatef</tt>
1383 " and so the application does not need to call the OpenGL positioning functions
1384 again for successive characters on the same line. </p>
1386 <p><b>Changes From GLUT</b> </p>
1388 <p>Nonexistent characters are rendered as
1391 <h2> 14.7 glutStrokeString</h2>
1392 The "<tt>glutStrokeString</tt>" function renders a string of characters
1393 in the <i>current window</i> using the specified stroke font.
1395 <p><b>Usage</b> </p>
1397 <p><tt>void glutStrokeString ( void *font,
1398 char *string ) ;</tt> </p>
1400 <p><tt>font
1401 </tt>The stroke font to use in rendering
1402 the character string <br>
1403 <tt>string </tt>String
1404 of characters to be rendered </p>
1406 <p><b>Description</b> </p>
1408 <p>The "<tt>glutStrokeString</tt>
1409 " function renders the given character string in the specified stroke font.
1410 Before calling "<tt>glutStrokeString</tt>" the application program should
1411 call the OpenGL transformation (positioning and scaling) functions to set
1412 the position of the string in the window. The "<tt>glutStrokeString</tt>
1413 " function handles carriage returns. Nonexistent characters are rendered
1416 <p><b>Changes From GLUT</b> </p>
1418 <p>GLUT does not include this function.
1421 <h2> 14.8 glutStrokeWidth</h2>
1422 The "<tt>glutStrokeWidth</tt>" function returns the width in pixels of
1423 a single character in the specified stroke font.
1425 <p><b>Usage</b> </p>
1427 <p><tt>int glutStrokeWidth ( void *font,
1428 int character ) ;</tt> </p>
1430 <p><tt>font
1431 </tt>The stroke font to use in calculating
1432 the character width <br>
1433 <tt>character </tt>The ASCII
1434 code of the character </p>
1436 <p><b>Description</b> </p>
1438 <p>The "<tt>glutStrokeWidth</tt>"
1439 function returns the width of the given character in the specified stroke
1440 font. Because the font is a stroke font, the width is actually a floating-point
1441 number; the function rounds it to the nearest integer for the return value.
1444 <p><b>Changes From GLUT</b> </p>
1446 <p>Nonexistent characters return the width
1447 of an asterisk. </p>
1449 <h2> 14.9 glutStrokeLength</h2>
1450 The "<tt>glutStrokeLength</tt>" function returns the width in pixels of
1451 a string of characters in the specified stroke font.
1453 <p><b>Usage</b> </p>
1455 <p><tt>int glutStrokeLength ( void *font,
1456 char *string ) ;</tt> </p>
1458 <p><tt>font </tt>The stroke
1459 font to use in calculating the character width <br>
1460 <tt>string </tt>String of characters
1461 whose width is to be calculated </p>
1463 <p><b>Description</b> </p>
1465 <p>The "<tt>glutStrokeLength</tt>
1466 " function returns the width in pixels of the given character string in
1467 the specified stroke font. Because the font is a stroke font, the width
1468 of an individual character is a floating-point number. <i>Freeglut</i>
1469 adds the floating-point widths and rounds the funal result to return the
1470 integer value. Thus the return value may differ from the sum of the
1471 character widths returned by a series of calls to "<tt>glutStrokeWidth</tt>
1472 ". The width of nonexistent characters is counted to be the width
1473 of an asterisk. </p>
1475 <p> If the string contains
1476 one or more carriage returns, <i>freeglut</i> calculates the widths in pixels
1477 of the lines separately and returns the largest width. </p>
1479 <p><b>Changes From GLUT</b> </p>
1481 <p>GLUT does not include this function.
1484 <h2> 14.10 glutStrokeHeight</h2>
1485 The "<tt>glutStrokeHeight</tt>" function returns the height in pixels of
1487 <p><b>Usage</b> </p>
1489 <p><tt>GLfloat glutStrokeHeight ( void *font
1492 <p><tt>font
1493 </tt>The stroke font to use in calculating
1494 the character height </p>
1496 <p><b>Description</b> </p>
1498 <p>The "<tt>glutStrokeHeight</tt>
1499 " function returns the height of a character in the specified stroke font.
1500 The application programmer should note that, unlike the other <i>freeglut</i>
1501 font functions, this one returns a floating-point number. The fonts
1502 are designed such that all characters have (nominally) the same height. </p>
1504 <p><b>Changes From GLUT</b> </p>
1506 <p>GLUT does not include this function.
1509 <h1> 15.0 <a name="GeometricObject"></a>
1510 Geometric Object Rendering Functions</h1>
1511 <i>Freeglut</i> includes eighteen routines for generating easily-recognizable
1512 3-d geometric objects. These routines are effectively the same ones
1513 that are included in the GLUT library, and reflect the functionality available
1514 in the <i>aux</i> toolkit described in the <i>OpenGL Programmer's Guide</i>
1515 . They are included to allow programmers to create with a single
1516 line of code a three-dimensional object which can be used to test a variety
1517 of OpenGL functionality. None of the routines generates a display list
1518 for the object which it draws. The functions generate normals appropriate
1519 for lighting but, except for the teapon functions, do not generate texture
1521 <h2> 15.1 glutWireSphere, glutSolidSphere</h2>
1522 The "<tt>glutWireSphere</tt>" and "<tt>glutSolidSphere</tt>" functions
1523 draw a wireframe and solid sphere respectively.
1525 <p><b>Usage</b> </p>
1527 <p><tt>void glutWireSphere ( GLdouble dRadius,
1528 GLint slices, GLint stacks ) ;</tt> </p>
1530 <p><tt>void glutSolidSphere ( GLdouble dRadius,
1531 GLint slices, GLint stacks ) ;</tt> </p>
1533 <p><tt>dRadius
1534 </tt>The desired radius of the sphere </p>
1536 <p><tt>slices
1537 </tt>The desired number of slices (divisions
1538 in the longitudinal direction) in the sphere </p>
1540 <p><tt>stacks
1541 </tt>The desired number of stacks (divisions
1542 in the latitudinal direction) in the sphere. The number of points in
1543 this direction, including the north and south poles, is <tt>stacks+1</tt>
1546 <p><b>Description</b> </p>
1548 <p>The "<tt>glutWireSphere</tt>" and "<tt>
1549 glutSolidSphere</tt>" functions render a sphere centered at the origin
1550 of the modeling coordinate system. The north and south poles of the
1551 sphere are on the positive and negative Z-axes respectively and the prime
1552 meridian crosses the positive X-axis. </p>
1554 <p><b>Changes From GLUT</b> </p>
1556 <p>None that we know of. </p>
1558 <h2> 15.2 glutWireTorus, glutSolidTorus</h2>
1559 The "<tt>glutWireTorus</tt>" and "<tt>glutSolidTorus</tt>" functions draw
1560 a wireframe and solid torus (donut shape) respectively.
1562 <p><b>Usage</b> </p>
1564 <p><tt>void glutWireTorus ( GLdouble dInnerRadius,
1565 GLdouble dOuterRadius, GLint nSides, GLint nRings ) ;</tt> </p>
1567 <p><tt>void glutSolidTorus ( GLdouble dInnerRadius,
1568 GLdouble dOuterRadius, GLint nSides, GLint nRings ) ;</tt> </p>
1570 <p><tt>dInnerRadius
1571 </tt>The desired inner radius of the torus,
1572 from the origin to the circle defining the centers of the outer circles </p>
1574 <p><tt>dOuterRadius
1575 </tt>The desired outer radius of the torus,
1576 from the center of the outer circle to the actual surface of the torus </p>
1578 <p><tt>nSides
1579 </tt>The desired number of segments in a
1580 single outer circle of the torus </p>
1582 <p><tt>nRings
1583 </tt>The desired number of outer circles
1584 around the origin of the torus </p>
1586 <p><b>Description</b> </p>
1588 <p>The "<tt>glutWireTorus</tt>" and "<tt>
1589 glutSolidTorus</tt>" functions render a torus centered at the origin of
1590 the modeling coordinate system. The torus is circularly symmetric about
1591 the Z-axis and starts at the positive X-axis. </p>
1593 <p><b>Changes From GLUT</b> </p>
1595 <p>None that we know of. </p>
1597 <h2> 15.3 glutWireCone, glutSolidCone</h2>
1598 The "<tt>glutWireCone</tt>" and "<tt>glutSolidCone</tt>" functions draw
1599 a wireframe and solid cone respectively.
1601 <p><b>Usage</b> </p>
1603 <p><tt>void glutWireCone ( GLdouble base,
1604 GLdouble height, GLint slices, GLint stacks ) ;</tt> </p>
1606 <p><tt>void glutSolidCone ( GLdouble base,
1607 GLdouble height, GLint slices, GLint stacks ) ;</tt> </p>
1609 <p><tt>base
1610 </tt>The desired radius of the base of the
1613 <p><tt>height
1614 </tt>The desired height of the cone </p>
1616 <p><tt>slices
1617 </tt>The desired number of slices around
1618 the base of the cone </p>
1620 <p><tt>stacks
1621 </tt>The desired number of segments between
1622 the base and the tip of the cone (the number of points, including the tip,
1623 is <tt>stacks + 1</tt>) </p>
1625 <p><b>Description</b> </p>
1627 <p>The "<tt>glutWireCone</tt>" and "<tt>
1628 glutSolidCone</tt>" functions render a right circular cone with a base
1629 centered at the origin and in the X-Y plane and its tip on the positive Z-axis.
1630 The wire cone is rendered with triangular elements. </p>
1632 <p><b>Changes From GLUT</b> </p>
1634 <p>None that we know of. </p>
1636 <h2> 15.4 glutWireCube, glutSolidCube</h2>
1637 The "<tt>glutWireCube</tt>" and "<tt>glutSolidCube</tt>" functions draw
1638 a wireframe and solid cube respectively.
1640 <p><b>Usage</b> </p>
1642 <p><tt>void glutWireCube ( GLdouble dSize
1645 <p><tt>void glutSolidCube ( GLdouble dSize
1648 <p><tt>dSize
1649 </tt>The desired length of an edge of the
1652 <p><b>Description</b> </p>
1654 <p>The "<tt>glutWireCube</tt>" and "<tt>
1655 glutSolidCube</tt>" functions render a cube of the desired size, centered
1656 at the origin. Its faces are normal to the coordinate directions. </p>
1658 <p><b>Changes From GLUT</b> </p>
1660 <p>None that we know of. </p>
1662 <h2> 15.5 glutWireTetrahedron, glutSolidTetrahedron</h2>
1663 The "<tt>glutWireTetrahedron</tt>" and "<tt>glutSolidTetrahedron</tt>"
1664 functions draw a wireframe and solid tetrahedron (four-sided Platonic solid)
1666 <p><b>Usage</b> </p>
1668 <p><tt>void glutWireTetrahedron ( void )
1671 <p><tt>void glutSolidTetrahedron ( void
1674 <p><b>Description</b> </p>
1676 <p>The "<tt>glutWireTetrahedron</tt>" and
1677 "<tt>glutSolidTetrahedron</tt>" functions render a tetrahedron whose corners
1678 are each a distance of one from the origin. The length of each side
1679 is 2/3 sqrt(6). One corner is on the positive X-axis and another is
1680 in the X-Y plane with a positive Y-coordinate. </p>
1682 <p><b>Changes From GLUT</b> </p>
1684 <p>None that we know of. </p>
1686 <h2> 15.6 glutWireOctahedron, glutSolidOctahedron</h2>
1687 The "<tt>glutWireOctahedron</tt>" and "<tt>glutSolidOctahedron</tt>" functions
1688 draw a wireframe and solid octahedron (eight-sided Platonic solid) respectively.
1690 <p><b>Usage</b> </p>
1692 <p><tt>void glutWireOctahedron ( void )
1695 <p><tt>void glutSolidOctahedron ( void )
1698 <p><b>Description</b> </p>
1700 <p>The "<tt>glutWireOctahedron</tt>" and
1701 "<tt>glutSolidOctahedron</tt>" functions render an octahedron whose corners
1702 are each a distance of one from the origin. The length of each side
1703 is sqrt(2). The corners are on the positive and negative coordinate
1706 <p><b>Changes From GLUT</b> </p>
1708 <p>None that we know of. </p>
1710 <h2> 15.7 glutWireDodecahedron, glutSolidDodecahedron</h2>
1711 The "<tt>glutWireDodecahedron</tt>" and "<tt>glutSolidDodecahedron</tt>
1712 " functions draw a wireframe and solid dodecahedron (twelve-sided Platonic
1713 solid) respectively.
1714 <p><b>Usage</b> </p>
1716 <p><tt>void glutWireDodecahedron ( void
1719 <p><tt>void glutSolidDodecahedron ( void
1722 <p><b>Description</b> </p>
1724 <p>The "<tt>glutWireDodecahedron</tt>" and
1725 "<tt>glutSolidDodecahedron</tt>" functions render a dodecahedron whose corners
1726 are each a distance of sqrt(3) from the origin. The length of each
1727 side is sqrt(5)-1. There are twenty corners; interestingly enough,
1728 eight of them coincide with the corners of a cube with sizes of length 2.
1731 <p><b>Changes From GLUT</b> </p>
1733 <p>None that we know of. </p>
1735 <h2> 15.8 glutWireIcosahedron, glutSolidIcosahedron</h2>
1736 The "<tt>glutWireIcosahedron</tt>" and "<tt>glutSolidIcosahedron</tt>"
1737 functions draw a wireframe and solid icosahedron (twenty-sided Platonic solid)
1739 <p><b>Usage</b> </p>
1741 <p><tt>void glutWireIcosahedron ( void )
1744 <p><tt>void glutSolidIcosahedron ( void
1747 <p><b>Description</b> </p>
1749 <p>The "<tt>glutWireIcosahedron</tt>" and
1750 "<tt>glutSolidIcosahedron</tt>" functions render an icosahedron whose corners
1751 are each a unit distance from the origin. The length of each side is
1752 slightly greater than one. Two of the corners lie on the positive and
1753 negative X-axes. </p>
1755 <p><b>Changes From GLUT</b> </p>
1757 <p>None that we know of. </p>
1759 <h2> 15.7 glutWireRhombicDodecahedron,
1760 glutSolidRhombicDodecahedron</h2>
1761 The "<tt>glutWireRhombicDodecahedron</tt>" and "<tt>glutSolidRhombicDodecahedron</tt>
1762 " functions draw a wireframe and solid rhombic dodecahedron (twelve-sided
1763 semi-regular solid) respectively.
1764 <p><b>Usage</b> </p>
1766 <p><tt>void glutWireRhombicDodecahedron
1767 ( void ) ;</tt> </p>
1769 <p><tt>void glutSolidRhombicDodecahedron
1770 ( void ) ;</tt> </p>
1772 <p><b>Description</b> </p>
1774 <p>The "<tt>glutWireRhombicDodecahedron</tt>
1775 " and "<tt>glutSolidRhombicDodecahedron</tt>" functions render a rhombic
1776 dodecahedron whose corners are at most a distance of one from the origin.
1777 The rhombic dodecahedron has faces which are identical rhombuses (rhombi?)
1778 but which have some vertices at which three faces meet and some vertices at
1779 which four faces meet. The length of each side is sqrt(3)/2. Vertices
1780 at which four faces meet are found at (0, 0, <u>+</u>1) and (<u> +</u>sqrt(2)/2,
1781 <u>+</u>sqrt(2)/2, 0). </p>
1783 <p><b>Changes From GLUT</b> </p>
1785 <p>GLUT does not include these functions.
1788 <h2> 15.10 glutWireTeapot, glutSolidTeapot</h2>
1789 The "<tt>glutWireTeapot</tt>" and "<tt>glutSolidTeapot</tt>" functions
1790 draw a wireframe and solid teapot respectively.
1792 <p><b>Usage</b> </p>
1794 <p><tt>void glutWireTeapot ( GLdouble dSize
1797 <p><tt>void glutSolidTeapot ( GLdouble dSize
1800 <p><tt>dSize
1801 </tt>The desired size of the teapot </p>
1803 <p><b>Description</b> </p>
1805 <p>The "<tt>glutWireTeapot</tt>" and "<tt>
1806 glutSolidTeapot</tt>" functions render a teapot of the desired size, centered
1807 at the origin. This is the famous OpenGL teapot [add reference]. </p>
1809 <p><b>Changes From GLUT</b> </p>
1811 <p>None that we know of. </p>
1813 <h1> 16.0 <a name="GameMode"></a>
1814 Game Mode Functions</h1>
1816 <h2> 16.1 glutGameModeString</h2>
1818 <h2> 16.2 glutEnterGameMode, glutLeaveGameMode</h2>
1820 <h2> 16.3 glutGameModeGet</h2>
1822 <h1> 17.0 <a name="VideoResize"></a>
1823 Video Resize Functions</h1>
1825 <h2> 17.1 glutVideoResizeGet</h2>
1827 <h2> 17.2 glutSetupVideoResizing,
1828 glutStopVideoResizing</h2>
1830 <h2> 17.3 glutVideoResize</h2>
1832 <h2> 17.4 glutVideoPan</h2>
1834 <h1> 18.0 <a name="ColorMap"></a>
1835 Color Map Functions</h1>
1837 <h2> 18.1 glutSetColor, glutGetColor</h2>
1839 <h2> 18.2 glutCopyColormap</h2>
1841 <h1> 19.0 <a name="Miscellaneous"></a>
1842 Miscellaneous Functions</h1>
1844 <h2> 19.1 glutIgnoreKeyRepeat, glutSetKeyRepeat</h2>
1846 <h2> 19.2 glutForceJoystickFunc</h2>
1848 <h2> 19.3 glutReportErrors</h2>
1850 <h1> 20.0 <a name="UsageNotes"></a>
1853 <p> The following environment variables
1854 are recognized by <i>freeglut</i>: </p>
1856 <li>DISPLAY - specifies a display name.<br>
1858 <li>GLUT_FPS - specifies a time interval
1859 (in milliseconds) for reporting framerate messages to stderr. For example,
1860 if FREEGLUT_FPS is set to 5000, every 5 seconds a message will be printed
1861 to stderr showing the current frame rate. The frame rate is measured by counting
1862 the number of times glutSwapBuffers() is called over the time interval.</li>
1863 <li>GLUT_ICON - specifies the icon that
1864 goes in the upper left-hand corner of the <i>freeglut</i><i> </i>windows </li>
1866 <h1> 21.0 <a name="ImplementationNotes"></a>
1867 Implementation Notes</h1>
1869 <h1> 22.0 <a name="GLUT_State"></a>
1872 <h1> 23.0 <a name="Freeglut.h_Header"></a>
1873 "freeglut.h" Header File</h1>
1877 Application programmers who are porting their GLUT programs to <i>freeglut</i> may continue
1878 to include <tt><GL/glut.h></tt> in their programs.
1879 Programs which use the <i>freeglut</i>-specific extensions to GLUT should include
1880 <tt><GL/freeglut.h></tt>. One possible arrangement is as follows:
1885 #include <GL/freeglut_ext.h>
1887 #include <GL/glut.h>
1892 Compile-time <i>freeglut</i> version testing can be done as follows:
1896 #ifdef FREEGLUT_VERSION_2_0
1897 code specific to freeglut 2.0 or later here
1902 In future releases, FREEGLUT_VERSION_2_1, FREEGLUT_VERSION_2_2, etc will
1903 be defined. This scheme mimics OpenGL conventions.
1907 The <i>freeglut</i> version can be queried at runtime by calling
1908 glutGet(GLUT_VERSION).
1909 The result will be X*10000+Y*100+Z where X is the major version, Y is the
1910 minor version and Z is the patch level.
1913 This may be used as follows:
1917 if (glutGet(GLUT_VERSION) < 20001) {
1918 printf("Sorry, you need freeglut version 2.0.1 or later to run this program.\n");
1925 <h1> 24.0 <a name="References"></a>
1928 <h1> 25.0 <a name="Index"></a>