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 menu
343 state callback (with one argument, distinct from the menu status callback
344 which has three arguments), and a window status callback <br>
345 (also with one argument). Unsupported callbacks are the three Spaceball
346 callbacks, the ButtonBox callback, the Dials callback, and the two Tablet
347 callbacks. If the user has a need for an unsupported callback he should
348 contact the <i>freeglut</i> development team.<br>
350 <h3>3.4.4 String Rendering<br>
352 New functions have been added to render full character strings (including
353 carriage returns) rather than rendering one character at a time. More
354 functions return the widths of character strings and the font heights, in
355 pixels for bitmapped fonts and in OpenGL units for the stroke fonts.<br>
357 <h3>3.4.5 Geometry Rendering<br>
359 Two functions have been added to render a wireframe and a solid rhombic
361 <h3> 3.4.5 Extension Function Queries</h3>
362 glutGetProcAddress is a wrapper for the glXGetProcAddressARB and wglGetProcAddress
364 <h1> 4.0 <a name="Initialization"></a>
365 Initialization Functions</h1>
367 <h2> 4.1 glutInit</h2>
369 <h2> 4.2 glutInitWindowPosition, glutInitWindowSize</h2>
370 The "<tt>glutInitWindowPosition</tt> " and "<tt>glutInitWindowSize</tt>
371 " functions specify a desired position and size for windows that <i>freeglut</i>
372 will create in the future.
375 <p><tt>void glutInitWindowPosition ( int
376 x, int y ) ;</tt> <br>
377 <tt>void glutInitWindowSize ( int width,
378 int height ) ;</tt> </p>
380 <p><b>Description</b> </p>
382 <p>The "<tt>glutInitWindowPosition</tt>
383 " and "<tt>glutInitWindowSize</tt>" functions specify a desired position
384 and size for windows that <i>freeglut</i> will create in the future.
385 The position is measured in pixels from the upper left hand corner of the
386 screen, with "x" increasing to the right and "y" increasing towards the bottom
387 of the screen. The size is measured in pixels. <i>Freeglut</i>
388 does not promise to follow these specifications in creating its windows,
389 it certainly makes an attempt to. </p>
391 <p>The position and size of a window are
392 a matter of some subtlety. Most windows have a usable area surrounded
393 by a border and with a title bar on the top. The border and title bar
394 are commonly called "decorations." The position of the window unfortunately
395 varies with the operating system. On Linux, it is the coordinates of
396 the upper left-hand corner of its decorations. On Windows, it is the
397 coordinates of the upper left hand corner of its usable interior. For
398 both operating systems, the size of the window is the size of the usable interior.
401 <p>Windows has some additional quirks which
402 the application programmer should know about. First, the minimum y-coordinate
403 of a window decoration is zero. (This is a feature of <i>freeglut</i>
404 and can be adjusted if so desired.) Second, there appears to be a
405 minimum window width on Windows which is 104 pixels. The user may specify
406 a smaller width, but the Windows system calls ignore it. It is also
407 impossible to make a window narrower than this by dragging on its corner.
410 <p><b>Changes From GLUT</b> </p>
412 <p>For some reason, GLUT is not affected
413 by the 104-pixel minimum window width. If the user clicks on the corner
414 of a window which is narrower than this amount, the window will immediately
415 snap out to this width, but the application can call "<tt>glutReshapeWindow</tt>
416 " and make a window narrower again. </p>
418 <h2> 4.3 glutInitDisplayMode</h2>
420 <h2> 4.4 glutInitDisplayString</h2>
422 <h1> 5.0 <a name="EventProcessing"></a>
423 Event Processing Functions</h1>
424 After an application has finished initializing its windows and menus, it
425 enters an event loop. Within this loop, <i>freeglut</i> polls the
426 data entry devices (keyboard, mouse, etc.) and calls the application's appropriate
428 <p>In GLUT, control never returned from
429 the event loop (as invoked by the "<tt>glutMainLoop</tt>" function) to the
430 calling function. This prevented an application from having re-entrant
431 code, in which GLUT could be invoked from within a callback, and it prevented
432 the application from doing any post-processing (such as freeing allocated
433 memory) after GLUT had closed down. <i>Freeglut</i> allows the application
434 programmer to specify more direct control over the event loop by means of
435 two new functions. The first, "<tt>glutMainLoopEvent</tt>", processes
436 a single iteration of the event loop and allows the application to use a different
437 event loop controller or to contain re-entrant code. The second, "<tt>
438 glutLeaveMainLoop</tt>", causes the event loop to exit nicely; this is preferable
439 to the application's calling "<tt>exit</tt>" from within a GLUT callback.
442 <h2> 5.1 glutMainLoop</h2>
443 The "<tt>glutMainLoop</tt>" function enters the event loop.
447 <p><tt>void glutMainLoop ( void ) ;</tt>
450 <p><b>Description</b> </p>
452 <p>The "<tt>glutMainLoop</tt>" function
453 causes the program to enter the window event loop. An application should
454 call this function at most once. It will call any application callback
455 functions as required to process mouse clicks, mouse motion, key presses,
458 <p><b>Changes From GLUT</b> </p>
460 <p>In GLUT, there was absolutely no way
461 for the application programmer to have control return from the "<tt>glutMainLoop</tt>
462 " function to the calling function. <i>Freeglut</i> allows the programmer
463 to force this by setting the "<tt>GLUT_ACTION_ON_WINDOW_CLOSE</tt>" option
464 and invoking the "<tt>glutLeaveMainLoop</tt>" function from one of the callbacks.
465 Stopping the program this way is preferable to simply calling "<tt>exit</tt>
466 " from within a callback because this allows <i>freeglut</i> to free allocated
467 memory and otherwise clean up after itself. (I know I just said this,
468 but I think it is important enough that it bears repeating.) </p>
470 <h2> 5.2 glutMainLoopEvent</h2>
471 The "<tt>glutMainLoopEvent</tt>" function processes a single iteration
472 in the <i>freeglut</i> event loop.
475 <p><tt>void glutMainLoopEvent ( void ) ;</tt>
478 <p><b>Description</b> </p>
480 <p>The "<tt>glutMainLoopEvent</tt>
481 " function causes <i>freeglut</i> to process one iteration's worth of events
482 in its event loop. This allows the application to control its own event
483 loop and still use the <i>freeglut</i> windowing system. </p>
485 <p><b>Changes From GLUT</b> </p>
487 <p>GLUT does not include this function.
490 <h2> 5.3 glutLeaveMainLoop</h2>
491 The "<tt>glutLeaveMainLoop</tt>" function causes <i>freeglut</i> to stop
495 <p><tt>void glutLeaveMainLoop ( void ) ;</tt>
498 <p><b>Description</b> </p>
500 <p>The "<tt>glutLeaveMainLoop</tt>
501 " function causes <i>freeglut</i> to stop the event loop. If the
502 "<tt> GLUT_ACTION_ON_WINDOW_CLOSE</tt>" option has been set to "<tt>GLUT_ACTION_CONTINUE_EXECUTION</tt>
503 ", control will return to the function which called "<tt>glutMainLoop</tt>
504 "; otherwise the application will exit. </p>
506 <p>If the application has two nested calls
507 to "<tt>glutMainLoop</tt>" and calls "<tt>glutLeaveMainLoop</tt>", the behaviour
508 of <i>freeglut</i> is undefined. It may leave only the inner nested
509 loop or it may leave both loops. If the reader has a strong preference
510 for one behaviour over the other he should contact the <i>freeglut</i> Programming
511 Consortium and ask for the code to be fixed. </p>
513 <p><b>Changes From GLUT</b> </p>
515 <p>GLUT does not include this function.
518 <h1> 6.0 <a name="Window"></a>
519 Window Functions</h1>
521 <h2> 6.1 glutCreateWindow</h2>
523 <h2> 6.2 glutCreateSubwindow</h2>
525 <h2> 6.3 glutDestroyWindow</h2>
527 <h2> 6.4 glutSetWindow, glutGetWindow</h2>
529 <h2> 6.5 glutSetWindowTitle, glutSetIconTitle</h2>
531 <h2> 6.6 glutReshapeWindow</h2>
533 <h2> 6.7 glutPositionWindow</h2>
535 <h2> 6.8 glutShowWindow, glutHideWindow,
536 glutIconifyWindow</h2>
538 <h2> 6.9 glutPushWindow, glutPopWindow</h2>
540 <h2> 6.10 glutFullScreen</h2>
542 <h1> 7.0 <a name="Display"></a>
543 Display Functions</h1>
545 <h2> 7.1 glutPostRedisplay</h2>
547 <h2> 7.2 glutPostWindowRedisplay</h2>
549 <h2> 7.3 glutSwapBuffers</h2>
551 <h1> 8.0 <a name="MouseCursor"></a>
552 Mouse Cursor Functions</h1>
554 <h2> 8.1 glutSetCursor</h2>
556 <h2> 8.2 glutWarpPointer</h2>
558 <h1> 9.0 <a name="Overlay"></a>
559 Overlay Functions</h1>
560 <i>Freeglut</i> does not allow overlays, although it does "answer the mail"
561 with function stubs so that GLUT-based programs can compile and link against
562 <i>freeglut</i> without modification.
563 If the reader needs overlays, he should contact the <i>freeglut</i> Programming
564 Consortium and ask for them to be implemented. He should also be prepared
565 to assist in the implementation.
566 <h2> 9.1 glutEstablishOverlay</h2>
567 The "<tt>glutEstablishOverlay</tt>" function is not implemented in <i>freeglut</i>
571 <p><tt>void glutEstablishOverlay ( void
574 <p><b>Description</b> </p>
576 <p>The "<tt>glutEstablishOverlay</tt>" function
577 is not implemented in <i>freeglut</i>. </p>
579 <p><b>Changes From GLUT</b> </p>
581 <p>GLUT implements this function. </p>
583 <h2> 9.2 glutRemoveOverlay</h2>
584 The "<tt>glutRemoveOverlay</tt>" function is not implemented in <i>freeglut</i>
588 <p><tt>void glutRemoveOverlay ( void ) ;</tt>
591 <p><b>Description</b> </p>
593 <p>The "<tt>glutRemoveOverlay</tt>" function
594 is not implemented in <i>freeglut</i>. </p>
596 <p><b>Changes From GLUT</b> </p>
598 <p>GLUT implements this function. </p>
600 <h2> 9.3 glutUseLayer</h2>
601 The "<tt>glutUseLayer</tt>" function is not implemented in <i>freeglut</i>
605 <p><tt>void glutUseLayer ( GLenum
608 <p><b>Description</b> </p>
610 <p>The "<tt>glutUseLayer</tt>" function
611 is not implemented in <i>freeglut</i>. </p>
613 <p><b>Changes From GLUT</b> </p>
615 <p>GLUT implements this function. </p>
617 <h2> 9.4 glutPostOverlayRedisplay</h2>
618 The "<tt>glutPostOverlayRedisplay</tt> " function is not implemented in
623 <p><tt>void glutPostOverlayRedisplay ( void
626 <p><b>Description</b> </p>
628 <p>The "<tt>glutPostOverlayRedisplay</tt>
629 " function is not implemented in <i>freeglut</i>. </p>
631 <p><b>Changes From GLUT</b> </p>
633 <p>GLUT implements this function. </p>
635 <h2> 9.5 glutPostWindowOverlayRedisplay</h2>
636 The "<tt>glutPostWindowOverlayRedisplay</tt> " function is not implemented
640 <p><tt>void glutPostWindowOverlayRedisplay
641 ( int window ) ;</tt> </p>
643 <p><b>Description</b> </p>
645 <p>The "<tt>glutPostWindowOverlayRedisplay</tt>
646 " function is not implemented in <i>freeglut</i>. </p>
648 <p><b>Changes From GLUT</b> </p>
650 <p>GLUT implements this function. </p>
652 <h2> 9.6 glutShowOverlay, glutHideOverlay</h2>
653 The "<tt>glutShowOverlay</tt>" and "<tt>glutHideOverlay</tt>" functions
654 are not implemented in <i>freeglut</i> .
658 <p><tt>void glutShowOverlay( void ) ;</tt>
660 <tt>void glutHideOverlay( void ) ;</tt>
663 <p><b>Description</b> </p>
665 <p>The "<tt>glutShowOverlay</tt>" and "<tt>
666 glutHideOverlay</tt>" functions are not implemented in <i>freeglut</i> .
669 <p><b>Changes From GLUT</b> </p>
671 <p>GLUT implements these functions. </p>
673 <h1> 10.0 <a name="Menu"></a>
676 <h2> 10.1 glutCreateMenu</h2>
678 <h2> 10.2 glutDestroyMenu</h2>
680 <h2> 10.3 glutGetMenu, glutSetMenu</h2>
682 <h2> 10.4 glutAddMenuEntry</h2>
684 <h2> 10.5 glutAddSubMenu</h2>
686 <h2> 10.6 glutChangeToMenuEntry</h2>
688 <h2> 10.7 glutChangeToSubMenu</h2>
690 <h2> 10.8 glutRemoveMenuItem</h2>
692 <h2> 10.9 glutAttachMenu, glutDetachMenu</h2>
694 <h1> 11.0 <a name="GlobalCallback"></a>
695 Global Callback Registration Functions</h1>
697 <h2> 11.1 glutTimerFunc</h2>
699 <h2> 11.2 glutIdleFunc</h2>
700 The "<tt>glutIdleFunc</tt>" function sets the global idle callback. <i>
701 Freeglut</i> calls the idle callback when there are no inputs from the user.
705 <p><tt>void glutIdleFunc ( void (*func)
706 ( void ) ) ;</tt> </p>
708 <p><tt>func </tt>The new
709 global idle callback function </p>
711 <p><b>Description</b> </p>
713 <p>The "<tt>glutIdleFunc</tt>" function
714 specifies the function that <i>freeglut</i> will call to perform background
715 processing tasks such as continuous animation when window system events are
716 not being received. If enabled, this function is called continuously
717 from <i>freeglut</i> while no events are received. The callback function
718 has no parameters and returns no value. <i>Freeglut</i> does not change
719 the <i>current window</i> or the <i>current menu</i> before invoking the idle
720 callback; programs with multiple windows or menus must explicitly set the
721 <i>current window</i> and <i>current menu</i>
722 and not rely on its current setting. <br>
723 The amount of computation and rendering done in an idle
724 callback should be minimized to avoid affecting the program's interactive
725 response. In general, no more than a single frame of rendering should
726 be done in a single invocation of an idle callback. <br>
727 Calling "<tt>glutIdleFunc</tt>" with a NULL argument
728 disables the call to an idle callback. </p>
730 <p><b>Changes From GLUT</b> </p>
732 <p>Application programmers should note that
733 if they have specified the "continue execution" action on window closure,
734 <i>freeglut</i> will continue to call the
735 idle callback after the user has closed a window by clicking on the "x" in
736 the window header bar. If the idle callback renders a particular window
737 (this is considered bad form but is frequently done anyway), the programmer
738 should supply a window closure callback for that window which changes or disables
739 the idle callback. </p>
741 <h1> 12.0 <a name="WindowCallback"></a>
742 Window-Specific Callback Registration Functions</h1>
744 <h2> 12.1 glutDisplayFunc</h2>
746 <h2> 12.2 glutOverlayDisplayFunc</h2>
748 <h2> 12.3 glutReshapeFunc</h2>
750 <h2> 12.4 glutCloseFunc</h2>
752 <h2> 12.5 glutKeyboardFunc</h2>
754 <h2> 12.6 glutSpecialFunc</h2>
755 The "<tt>glutSpecialFunc</tt>" function sets the window's special key press
756 callback. <i>Freeglut</i> calls the special key press callback when the
757 user presses a special key.
760 <p><tt>void glutSpecialFunc ( void (*func)
761 ( int key, int x, int y ) ) ;</tt> </p>
763 <p><tt>func </tt>The window's
764 new special key press callback function <br>
765 <tt>key </tt>The
766 key whose press triggers the callback <br>
767 <tt>x
768 </tt>The x-coordinate of the mouse relative
769 to the window at the time the key is pressed <br>
770 <tt>y
771 </tt>The y-coordinate of the mouse relative
772 to the window at the time the key is pressed </p>
774 <p><b>Description</b> </p>
776 <p>The "<tt>glutSpecialFunc</tt>"
777 function specifies the function that <i>freeglut</i> will call when the user
778 presses a special key on the keyboard. The callback function has one
779 argument: the name of the function to be invoked ("called back") at
780 the time at which the special key is pressed. The function returns no
781 value. <i>Freeglut</i> sets the <i>current window</i> to the window
782 which is active when the callback is invoked. "Special keys" are the
783 function keys, the arrow keys, the Page Up and Page Down keys, and the Insert
784 key. The Delete key is considered to be a regular key. <br>
785 Calling "<tt>glutSpecialUpFunc</tt>" with a NULL argument
786 disables the call to the window's special key press callback. </p>
788 <p> The "<tt>key</tt>
789 " argument may take one of the following defined constant values: </p>
792 <li> <tt>GLUT_KEY_F1, GLUT_KEY_F2, ..., GLUT_KEY_F12</tt>
793 - F1 through F12 keys</li>
794 <li> <tt>GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN</tt>
795 - Page Up and Page Down keys</li>
796 <li> <tt>GLUT_KEY_HOME, GLUT_KEY_END</tt>
797 - Home and End keys</li>
798 <li> <tt>GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN</tt>
800 <li> <tt>GLUT_KEY_INSERT</tt>
804 <b>Changes From GLUT</b>
807 <h2> 12.7 glutKeyboardUpFunc</h2>
808 The "<tt>glutKeyboardUpFunc</tt>" function sets the window's key release
809 callback. <i>Freeglut</i> calls the key release callback when the user releases
813 <p><tt>void glutKeyboardUpFunc ( void (*func)
814 ( unsigned char key, int x, int y ) ) ;</tt> </p>
816 <p><tt>func </tt>The window's
817 new key release callback function <br>
818 <tt>key </tt>The
819 key whose release triggers the callback <br>
820 <tt>x
821 </tt>The x-coordinate of the mouse relative
822 to the window at the time the key is released <br>
823 <tt>y
824 </tt>The y-coordinate of the mouse relative
825 to the window at the time the key is released </p>
827 <p><b>Description</b> </p>
829 <p>The "<tt>glutKeyboardUpFunc</tt>
830 " function specifies the function that <i>freeglut</i> will call when the
831 user releases a key from the keyboard. The callback function has one
832 argument: the name of the function to be invoked ("called back") at
833 the time at which the key is released. The function returns no value.
834 <i>Freeglut</i> sets the <i>current window</i>
835 to the window which is active when the callback is invoked. <br>
836 While <i>freeglut</i> checks for upper or lower case
837 letters, it does not do so for non-alphabetical characters. Nor does
838 it account for the Caps-Lock key being on. The operating system may
839 send some unexpected characters to <i>freeglut</i>, such as "8" when the
840 user is pressing the Shift key. <i>Freeglut</i> also invokes the callback
841 when the user releases the Control, Alt, or Shift keys, among others.
842 Releasing the Delete key causes this function to be invoked with a value
843 of 127 for "<tt>key</tt>". <br>
844 Calling "<tt>glutKeyboardUpFunc</tt>" with a NULL argument
845 disables the call to the window's key release callback. </p>
847 <p><b>Changes From GLUT</b> </p>
849 <p>This function is not implemented in GLUT
850 versions before Version 4. It has been designed to be as close to GLUT
851 as possible. Users who find differences should contact the
852 <i>freeglut</i> Programming Consortium to
853 have them fixed. </p>
855 <h2> 12.8 glutSpecialUpFunc</h2>
856 The "<tt>glutSpecialUpFunc</tt>" function sets the window's special key
857 release callback. <i>Freeglut</i> calls the special key release callback
858 when the user releases a special key.
861 <p><tt>void glutSpecialUpFunc ( void (*func)
862 ( int key, int x, int y ) ) ;</tt> </p>
864 <p><tt>func </tt>The window's
865 new special key release callback function <br>
866 <tt>key </tt>The
867 key whose release triggers the callback <br>
868 <tt>x
869 </tt>The x-coordinate of the mouse relative
870 to the window at the time the key is released <br>
871 <tt>y
872 </tt>The y-coordinate of the mouse relative
873 to the window at the time the key is released </p>
875 <p><b>Description</b> </p>
877 <p>The "<tt>glutSpecialUpFunc</tt>
878 " function specifies the function that <i>freeglut</i> will call when the
879 user releases a special key from the keyboard. The callback function
880 has one argument: the name of the function to be invoked ("called back")
881 at the time at which the special key is released. The function returns
882 no value. <i>Freeglut</i> sets the <i>current window</i> to the window
883 which is active when the callback is invoked. "Special keys" are the
884 function keys, the arrow keys, the Page Up and Page Down keys, and the Insert
885 key. The Delete key is considered to be a regular key. <br>
886 Calling "<tt>glutSpecialUpFunc</tt>" with a NULL argument
887 disables the call to the window's special key release callback. </p>
889 <p> The "<tt>key</tt>
890 " argument may take one of the following defined constant values: </p>
893 <li> <tt>GLUT_KEY_F1, GLUT_KEY_F2, ..., GLUT_KEY_F12</tt>
894 - F1 through F12 keys</li>
895 <li> <tt>GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN</tt>
896 - Page Up and Page Down keys</li>
897 <li> <tt>GLUT_KEY_HOME, GLUT_KEY_END</tt>
898 - Home and End keys</li>
899 <li> <tt>GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN</tt>
901 <li> <tt>GLUT_KEY_INSERT</tt>
905 <b>Changes From GLUT</b>
906 <p>This function is not implemented in GLUT
907 versions before Version 4. It has been designed to be as close to GLUT
908 as possible. Users who find differences should contact the
909 <i>freeglut</i> Programming Consortium to
910 have them fixed. </p>
912 <h2> 12.9 glutMouseFunc</h2>
914 <h2> 12.10 glutMotionFunc, glutPassiveMotionFunc</h2>
916 <h2> 12.11 glutVisibilityFunc</h2>
918 <h2> 12.12 glutEntryFunc</h2>
920 <h2> 12.13 glutJoystickFunc</h2>
922 <h2> 12.14 glutSpaceballMotionFunc</h2>
923 The "<tt>glutSpaceballMotionFunc</tt>" function is not implemented in
924 <i>freeglut</i>, although the library does
925 "answer the mail" to the extent that a call to the function will not produce
929 <p><tt>void glutSpaceballMotionFunc ( void
930 (* callback)( int x, int y, int z )</tt><tt> ) ;</tt></p>
932 <p><b>Description</b></p>
934 <p>The "<tt>glutSpaceballMotionFunc</tt>
935 " function is not implemented in <i>freeglut</i>. </p>
937 <p><b>Changes From GLUT</b></p>
939 <p>GLUT implements this function. </p>
941 <h2> 12.15 glutSpaceballRotateFunc</h2>
942 The "<tt>glutSpaceballRotateFunc</tt>" function is not implemented in
943 <i>freeglut</i>, although the library does
944 "answer the mail" to the extent that a call to the function will not produce
948 <p><tt>void glutSpaceballRotateFunc ( void
949 (* callback)( int x, int y, int z )</tt><tt> ) ;</tt></p>
951 <p><b>Description</b></p>
953 <p>The "<tt>glutSpaceballRotateFunc</tt>
954 " function is not implemented in <i>freeglut</i>. </p>
956 <p><b>Changes From GLUT</b></p>
958 <p>GLUT implements this function. </p>
960 <h2> 12.16 glutSpaceballButtonFunc</h2>
961 The "<tt>glutSpaceballButtonFunc</tt>" function is not implemented in
962 <i>freeglut</i>, although the library does
963 "answer the mail" to the extent that a call to the function will not produce
967 <p><tt>void glutSpaceballButtonFunc ( void
968 (* callback)( int button, int updown )</tt><tt> ) ;</tt></p>
970 <p><b>Description</b></p>
972 <p>The "<tt>glutSpaceballButtonFunc</tt>
973 " function is not implemented in <i>freeglut</i>. </p>
975 <p><b>Changes From GLUT</b></p>
977 <p>GLUT implements this function. </p>
979 <h2> 12.17 glutButtonBoxFunc</h2>
980 The "<tt>glutSpaceballButtonBoxFunc</tt>" function is not implemented
981 in <i>freeglut</i>, although the library does "answer the mail" to the extent
982 that a call to the function will not produce an error..
986 <p><tt>void glutSpaceballButtonBoxFunc (
987 void (* callback)( int button, int updown )</tt><tt> ) ;</tt></p>
989 <p><b>Description</b></p>
991 <p>The "<tt>glutSpaceballButtonBoxFunc</tt>
992 " function is not implemented in <i>freeglut</i>. </p>
994 <p><b>Changes From GLUT</b></p>
996 <p>GLUT implements this function. </p>
998 <h2> 12.18 glutDialsFunc</h2>
999 The "<tt>glutDialsFunc</tt>" function is not implemented in <i>freeglut</i>
1000 , although the library does "answer the mail" to the extent that a call
1001 to the function will not produce an error..
1005 <p><tt>void glutDialsFunc ( void (* callback)(
1006 int dial, int value )</tt><tt> ) ;</tt></p>
1008 <p><b>Description</b></p>
1010 <p>The "<tt>glutDialsFunc</tt>" function
1011 is not implemented in <i>freeglut</i>. </p>
1013 <p><b>Changes From GLUT</b></p>
1015 <p>GLUT implements this function. </p>
1017 <h2> 12.19 glutTabletMotionFunc</h2>
1018 The "<tt>glutTabletMotionFunc</tt>" function is not implemented in <i>
1019 freeglut</i>, although the library does "answer the mail" to the extent
1020 that a call to the function will not produce an error..
1024 <p><tt>void glutTabletMotionFunc ( void
1025 (* callback)( int x, int y )</tt><tt> ) ;</tt></p>
1027 <p><b>Description</b></p>
1029 <p>The "<tt>glutTabletMotionFunc</tt>" function
1030 is not implemented in <i>freeglut</i>. </p>
1032 <p><b>Changes From GLUT</b></p>
1034 <p>GLUT implements this function. </p>
1036 <h2> 12.20 glutTabletButtonFunc</h2>
1037 The "<tt>glutTabletButtonFunc</tt>" function is not implemented in <i>
1038 freeglut</i>, although the library does "answer the mail" to the extent
1039 that a call to the function will not produce an error..
1043 <p><tt>void glutTabletButtonFunc ( void
1044 (* callback)( int button, int updown, int x, int y )</tt><tt> ) ;</tt></p>
1046 <p><b>Description</b></p>
1048 <p>The "<tt>glutTabletButtonFunc</tt>" function
1049 is not implemented in <i>freeglut</i>. </p>
1051 <p><b>Changes From GLUT</b></p>
1053 <p>GLUT implements this function. </p>
1055 <h2> 12.21 glutMenuStatusFunc</h2>
1057 <h2> 12.22 glutWindowStatusFunc</h2>
1059 <h1> 13.0 <a name="StateSetting"></a>
1060 State Setting and Retrieval Functions</h1>
1062 <h2> 13.1 glutSetOption</h2>
1064 <h2> 13.2 glutGet</h2>
1068 The following state variables may be queried with "<tt>glutGet</tt>".
1069 The returned value is an integer.
1073 These queries are with respect to the current window:
1077 <li>GLUT_WINDOW_X - window X position
1078 <li>GLUT_WINDOW_Y - window Y position
1079 <li>GLUT_WINDOW_WIDTH - window width
1080 <li>GLUT_WINDOW_HEIGHT - window height
1081 <li>GLUT_WINDOW_BUFFER_SIZE - number of color or color index bits per pixel
1082 <li>GLUT_WINDOW_STENCIL_SIZE - number of bits per stencil value
1083 <li>GLUT_WINDOW_DEPTH_SIZE - number of bits per depth value
1084 <li>GLUT_WINDOW_RED_SIZE - number of bits per red value
1085 <li>GLUT_WINDOW_GREEN_SIZE - number of bits per green value
1086 <li>GLUT_WINDOW_BLUE_SIZE - number of bits per blue value
1087 <li>GLUT_WINDOW_ALPHA_SIZE - number of bits per alpha value
1088 <li>GLUT_WINDOW_ACCUM_RED_SIZE - number of red bits in the accumulation buffer
1089 <li>GLUT_WINDOW_ACCUM_GREEN_SIZE - number of green bits in the accumulation buffer
1090 <li>GLUT_WINDOW_ACCUM_BLUE_SIZE - number of blue bits in the accumulation buffer
1091 <li>GLUT_WINDOW_ACCUM_ALPHA_SIZE - number of alpha bits in the accumulation buffer
1092 <li>GLUT_WINDOW_DOUBLEBUFFER - 1 if the color buffer is double buffered, 0 otherwise
1093 <li>GLUT_WINDOW_RGBA - 1 if the color buffers are RGB[A], 0 for color index
1094 <li>GLUT_WINDOW_PARENT - parent window ID
1095 <li>GLUT_WINDOW_NUM_CHILDREN - number of child windows
1096 <li>GLUT_WINDOW_COLORMAP_SIZE - number of entries in the window's colormap
1097 <li>GLUT_WINDOW_NUM_SAMPLES - number of samples per pixel if using multisampling
1098 <li>GLUT_WINDOW_STEREO - 1 if the window supports stereo, 0 otherwise
1099 <li>GLUT_WINDOW_CURSOR - current cursor
1100 <li>GLUT_WINDOW_FORMAT_ID - on Windows, return the pixel format number of the current window
1104 These queries do not depend on the current window.
1108 <li>GLUT_SCREEN_WIDTH - width of the screen in pixels
1109 <li>GLUT_SCREEN_HEIGHT - height of the screen in pixels
1110 <li>GLUT_SCREEN_WIDTH_MM - width of the screen in millimeters
1111 <li>GLUT_SCREEN_HEIGHT_MM - height of the screen in millimeters
1112 <li>GLUT_MENU_NUM_ITEMS - number of items in the current menu
1113 <li>GLUT_DISPLAY_MODE_POSSIBLE - return 1 if the current display mode is supported, 0 otherwise
1114 <li>GLUT_INIT_WINDOW_X - X position last set by glutInitWindowPosition
1115 <li>GLUT_INIT_WINDOW_Y - Y position last set by glutInitWindowPosition
1116 <li>GLUT_INIT_WINDOW_WIDTH - width last set by glutInitWindowSize
1117 <li>GLUT_INIT_WINDOW_HEIGHT - height last set by glutInitWindowSize
1118 <li>GLUT_INIT_DISPLAY_MODE - display mode last set by glutInitDisplayMode
1119 <li>GLUT_ELAPSED_TIME - time (in milliseconds) elapsed since glutInit or glutGet(GLUT_ELAPSED_TIME) was first called
1120 <li>GLUT_INIT_STATE - ?
1121 <li>GLUT_VERSION - Return value will be X*10000+Y*100+Z where X is the
1122 major version, Y is the minor version and Z is the patch level.
1123 This query is only supported in <i>freeglut</i> (version 2.0.0 or later).
1127 <h2> 13.3 glutDeviceGet</h2>
1129 <h2> 13.4 glutGetModifiers</h2>
1131 <h2> 13.5 glutLayerGet</h2>
1133 <h2> 13.6 glutExtensionSupported</h2>
1135 <h2> 13.7 glutGetProcAddress</h2>
1136 <p><tt>glutGetProcAddress</tt> returns
1137 a pointer to a named GL or <i>freeglut</i> function. </p>
1139 <p><tt>void *glutGetProcAddress ( const
1140 char *procName ) ;</tt></p>
1141 <p><tt>procName
1142 </tt>Name of an OpenGL or GLUT function.
1144 <p><b>Description</b></p>
1145 <p><tt>glutGetProcAddress</tt> is useful
1146 for dealing with OpenGL extensions. If an application calls OpenGL extension
1147 functions directly, that application will only link/run with an OpenGL library
1148 that supports the extension. By using a function pointer returned from glutGetProcAddress(),
1149 the application will avoid this hard dependency and be more portable and interoperate
1150 better with various implementations of OpenGL. </p>
1151 <p> Both OpenGL functions and <i>freeglut</i>
1152 functions can be queried with this function. </p>
1153 <p><b>Changes From GLUT</b> </p>
1155 <p>GLUT does not include this function.
1158 <h1> 14.0 <a name="FontRendering"></a>
1159 Font Rendering Functions</h1>
1160 <i>Freeglut</i> supports two types of font rendering: bitmap fonts,
1161 which are rendered using the "<tt>glBitmap</tt>" function call, and stroke
1162 fonts, which are rendered as sequences of OpenGL line segments. Because
1163 they are rendered as bitmaps, the bitmap fonts tend to render more quickly
1164 than stroke fonts, but they are less flexible in terms of scaling and rendering.
1165 Bitmap font characters are positioned with calls to the "<tt>glRasterPos*</tt>
1166 " functions while stroke font characters use the OpenGL transformations
1167 to position characters.
1168 <p> It should be noted
1169 that <i>freeglut</i> fonts are similar but not identical to GLUT fonts.
1170 At the moment, <i>freeglut</i> fonts do not support the "`" (backquote) and
1171 "|" (vertical line) characters; in their place it renders asterisks. </p>
1173 <p> <i>Freeglut</i> supports
1174 the following bitmap fonts: </p>
1177 <li> <tt>GLUT_BITMAP_8_BY_13</tt> - A variable-width font with every character
1178 fitting in a rectangle of 13 pixels high by at most 8 pixels wide.</li>
1179 <li> <tt>GLUT_BITMAP_9_BY_15</tt> - A variable-width font with every character
1180 fitting in a rectangle of 15 pixels high by at most 9 pixels wide.</li>
1181 <li> <tt>GLUT_BITMAP_TIMES_ROMAN_10</tt> - A 10-point variable-width Times
1183 <li> <tt>GLUT_BITMAP_TIMES_ROMAN_24</tt> - A 24-point variable-width Times
1185 <li> <tt>GLUT_BITMAP_HELVETICA_10</tt> - A 10-point variable-width Helvetica
1187 <li> <tt>GLUT_BITMAP_HELVETICA_12</tt> - A 12-point variable-width Helvetica
1189 <li> <tt>GLUT_BITMAP_HELVETICA_18</tt> - A 18-point variable-width Helvetica
1193 <i>Freeglut</i> calls "<tt>glRasterPos4v</tt>" to advance the cursor by
1194 the width of a character and to render carriage returns when appropriate.
1195 It does not use any display lists in it rendering in bitmap fonts.
1197 <p> <i>Freeglut</i> supports
1198 the following stroke fonts: </p>
1201 <li> <tt>GLUT_STROKE_ROMAN</tt> - A proportionally-spaced Roman Simplex
1203 <li> <tt>GLUT_STROKE_MONO_ROMAN</tt> - A fixed-width Roman Simplex font</li>
1206 <i>Freeglut</i> does not use any display lists in its rendering of stroke
1207 fonts. It calls "<tt>glTranslatef</tt>" to advance the cursor by the
1208 width of a character and to render carriage returns when appropriate.
1210 <h2> 14.1 glutBitmapCharacter</h2>
1211 The "<tt>glutBitmapCharacter</tt>" function renders a single bitmapped
1212 character in the <i>current window</i> using the specified font.
1214 <p><b>Usage</b> </p>
1216 <p><tt>void glutBitmapCharacter ( void *font,
1217 int character ) ;</tt> </p>
1219 <p><tt>font
1220 </tt>The bitmapped font to use in rendering
1222 <tt>character </tt>The ASCII
1223 code of the character to be rendered </p>
1225 <p><b>Description</b> </p>
1227 <p>The "<tt>glutBitmapCharacter</tt>
1228 " function renders the given character in the specified bitmap font.
1229 <i>Freeglut</i> automatically sets the necessary
1230 pixel unpack storage modes and restores the existing modes when it has finished.
1231 Before the first call to "<tt>glutBitMapCharacter</tt> " the application
1232 program should call "<tt>glRasterPos*</tt>" to set the position of the character
1233 in the window. The "<tt>glutBitmapCharacter</tt> " function advances
1234 the cursor position as part of its call to "<tt>glBitmap</tt> " and so the
1235 application does not need to call "<tt>glRasterPos*</tt>" again for successive
1236 characters on the same line. </p>
1238 <p><b>Changes From GLUT</b> </p>
1240 <p>Nonexistent characters are rendered as
1241 asterisks. The rendering position in <i>freeglut</i> is apparently off
1242 from GLUT's position by a few pixels vertically and one or two pixels horizontally.
1245 <h2> 14.2 glutBitmapString</h2>
1246 The "<tt>glutBitmapString</tt>" function renders a string of bitmapped
1247 characters in the <i>current window</i> using the specified font.
1249 <p><b>Usage</b> </p>
1251 <p><tt>void glutBitmapString ( void *font,
1252 char *string ) ;</tt> </p>
1254 <p><tt>font
1255 </tt>The bitmapped font to use in rendering
1256 the character string <br>
1257 <tt>string </tt>String
1258 of characters to be rendered </p>
1260 <p><b>Description</b> </p>
1262 <p>The "<tt>glutBitmapString</tt>
1263 " function renders the given character string in the specified bitmap font.
1264 <i>Freeglut</i> automatically sets the necessary
1265 pixel unpack storage modes and restores the existing modes when it has finished.
1266 Before calling "<tt>glutBitMapString</tt>" the application program should
1267 call "<tt>glRasterPos*</tt>" to set the position of the string in the window.
1268 The "<tt>glutBitmapString</tt>" function handles carriage returns.
1269 Nonexistent characters are rendered as asterisks. </p>
1271 <p><b>Changes From GLUT</b> </p>
1273 <p>GLUT does not include this function.
1276 <h2> 14.3 glutBitmapWidth</h2>
1277 The "<tt>glutBitmapWidth</tt>" function returns the width in pixels of
1278 a single bitmapped character in the specified font.
1280 <p><b>Usage</b> </p>
1282 <p><tt>int glutBitmapWidth ( void *font,
1283 int character ) ;</tt> </p>
1285 <p><tt>font
1286 </tt>The bitmapped font to use in calculating
1287 the character width <br>
1288 <tt>character </tt>The ASCII
1289 code of the character </p>
1291 <p><b>Description</b> </p>
1293 <p>The "<tt>glutBitmapWidth</tt>"
1294 function returns the width of the given character in the specified bitmap
1295 font. Because the font is bitmapped, the width is an exact integer.
1298 <p><b>Changes From GLUT</b> </p>
1300 <p>Nonexistent characters return the width
1301 of an asterisk. </p>
1303 <h2> 14.4 glutBitmapLength</h2>
1304 The "<tt>glutBitmapLength</tt>" function returns the width in pixels of
1305 a string of bitmapped characters in the specified font.
1307 <p><b>Usage</b> </p>
1309 <p><tt>int glutBitmapLength ( void *font,
1310 char *string ) ;</tt> </p>
1312 <p><tt>font </tt>The bitmapped
1313 font to use in calculating the character width <br>
1314 <tt>string </tt>String of characters
1315 whose width is to be calculated </p>
1317 <p><b>Description</b> </p>
1319 <p>The "<tt>glutBitmapLength</tt>
1320 " function returns the width in pixels of the given character string in
1321 the specified bitmap font. Because the font is bitmapped, the width
1322 is an exact integer: the return value is identical to the sum of the
1323 character widths returned by a series of calls to "<tt>glutBitmapWidth</tt>
1324 ". The width of nonexistent characters is counted to be the width of
1327 <p> If the string contains
1328 one or more carriage returns, <i>freeglut</i> calculates the widths in pixels
1329 of the lines separately and returns the largest width. </p>
1331 <p><b>Changes From GLUT</b> </p>
1333 <p>GLUT does not include this function.
1336 <h2> 14.5 glutBitmapHeight</h2>
1337 The "<tt>glutBitmapHeight</tt>" function returns the height in pixels of
1339 <p><b>Usage</b> </p>
1341 <p><tt>int glutBitmapHeight ( void *font
1344 <p><tt>font
1345 </tt>The bitmapped font to use in calculating
1346 the character height </p>
1348 <p><b>Description</b> </p>
1350 <p>The "<tt>glutBitmapHeight</tt>
1351 " function returns the height of a character in the specified bitmap font.
1352 Because the font is bitmapped, the height is an exact integer. The fonts
1353 are designed such that all characters have (nominally) the same height.
1356 <p><b>Changes From GLUT</b> </p>
1358 <p>GLUT does not include this function.
1361 <h2> 14.6 glutStrokeCharacter</h2>
1362 The "<tt>glutStrokeCharacter</tt>" function renders a single stroke character
1363 in the <i>current window</i> using the specified font.
1365 <p><b>Usage</b> </p>
1367 <p><tt>void glutStrokeCharacter ( void *font,
1368 int character ) ;</tt> </p>
1370 <p><tt>font
1371 </tt>The stroke font to use in rendering
1373 <tt>character </tt>The ASCII
1374 code of the character to be rendered </p>
1376 <p><b>Description</b> </p>
1378 <p>The "<tt>glutStrokeCharacter</tt>
1379 " function renders the given character in the specified stroke font.
1380 Before the first call to "<tt>glutStrokeCharacter</tt>" the application program
1381 should call the OpenGL transformation (positioning and scaling) functions
1382 to set the position of the character in the window. The "<tt>glutStrokeCharacter</tt>
1383 " function advances the cursor position by a call to "<tt>glTranslatef</tt>
1384 " and so the application does not need to call the OpenGL positioning functions
1385 again for successive characters on the same line. </p>
1387 <p><b>Changes From GLUT</b> </p>
1389 <p>Nonexistent characters are rendered as
1392 <h2> 14.7 glutStrokeString</h2>
1393 The "<tt>glutStrokeString</tt>" function renders a string of characters
1394 in the <i>current window</i> using the specified stroke font.
1396 <p><b>Usage</b> </p>
1398 <p><tt>void glutStrokeString ( void *font,
1399 char *string ) ;</tt> </p>
1401 <p><tt>font
1402 </tt>The stroke font to use in rendering
1403 the character string <br>
1404 <tt>string </tt>String
1405 of characters to be rendered </p>
1407 <p><b>Description</b> </p>
1409 <p>The "<tt>glutStrokeString</tt>
1410 " function renders the given character string in the specified stroke font.
1411 Before calling "<tt>glutStrokeString</tt>" the application program should
1412 call the OpenGL transformation (positioning and scaling) functions to set
1413 the position of the string in the window. The "<tt>glutStrokeString</tt>
1414 " function handles carriage returns. Nonexistent characters are rendered
1417 <p><b>Changes From GLUT</b> </p>
1419 <p>GLUT does not include this function.
1422 <h2> 14.8 glutStrokeWidth</h2>
1423 The "<tt>glutStrokeWidth</tt>" function returns the width in pixels of
1424 a single character in the specified stroke font.
1426 <p><b>Usage</b> </p>
1428 <p><tt>int glutStrokeWidth ( void *font,
1429 int character ) ;</tt> </p>
1431 <p><tt>font
1432 </tt>The stroke font to use in calculating
1433 the character width <br>
1434 <tt>character </tt>The ASCII
1435 code of the character </p>
1437 <p><b>Description</b> </p>
1439 <p>The "<tt>glutStrokeWidth</tt>"
1440 function returns the width of the given character in the specified stroke
1441 font. Because the font is a stroke font, the width is actually a floating-point
1442 number; the function rounds it to the nearest integer for the return value.
1445 <p><b>Changes From GLUT</b> </p>
1447 <p>Nonexistent characters return the width
1448 of an asterisk. </p>
1450 <h2> 14.9 glutStrokeLength</h2>
1451 The "<tt>glutStrokeLength</tt>" function returns the width in pixels of
1452 a string of characters in the specified stroke font.
1454 <p><b>Usage</b> </p>
1456 <p><tt>int glutStrokeLength ( void *font,
1457 char *string ) ;</tt> </p>
1459 <p><tt>font </tt>The stroke
1460 font to use in calculating the character width <br>
1461 <tt>string </tt>String of characters
1462 whose width is to be calculated </p>
1464 <p><b>Description</b> </p>
1466 <p>The "<tt>glutStrokeLength</tt>
1467 " function returns the width in pixels of the given character string in
1468 the specified stroke font. Because the font is a stroke font, the width
1469 of an individual character is a floating-point number. <i>Freeglut</i>
1470 adds the floating-point widths and rounds the funal result to return the
1471 integer value. Thus the return value may differ from the sum of the
1472 character widths returned by a series of calls to "<tt>glutStrokeWidth</tt>
1473 ". The width of nonexistent characters is counted to be the width
1474 of an asterisk. </p>
1476 <p> If the string contains
1477 one or more carriage returns, <i>freeglut</i> calculates the widths in pixels
1478 of the lines separately and returns the largest width. </p>
1480 <p><b>Changes From GLUT</b> </p>
1482 <p>GLUT does not include this function.
1485 <h2> 14.10 glutStrokeHeight</h2>
1486 The "<tt>glutStrokeHeight</tt>" function returns the height in pixels of
1488 <p><b>Usage</b> </p>
1490 <p><tt>GLfloat glutStrokeHeight ( void *font
1493 <p><tt>font
1494 </tt>The stroke font to use in calculating
1495 the character height </p>
1497 <p><b>Description</b> </p>
1499 <p>The "<tt>glutStrokeHeight</tt>
1500 " function returns the height of a character in the specified stroke font.
1501 The application programmer should note that, unlike the other <i>freeglut</i>
1502 font functions, this one returns a floating-point number. The fonts
1503 are designed such that all characters have (nominally) the same height. </p>
1505 <p><b>Changes From GLUT</b> </p>
1507 <p>GLUT does not include this function.
1510 <h1> 15.0 <a name="GeometricObject"></a>
1511 Geometric Object Rendering Functions</h1>
1512 <i>Freeglut</i> includes eighteen routines for generating easily-recognizable
1513 3-d geometric objects. These routines are effectively the same ones
1514 that are included in the GLUT library, and reflect the functionality available
1515 in the <i>aux</i> toolkit described in the <i>OpenGL Programmer's Guide</i>
1516 . They are included to allow programmers to create with a single
1517 line of code a three-dimensional object which can be used to test a variety
1518 of OpenGL functionality. None of the routines generates a display list
1519 for the object which it draws. The functions generate normals appropriate
1520 for lighting but, except for the teapon functions, do not generate texture
1522 <h2> 15.1 glutWireSphere, glutSolidSphere</h2>
1523 The "<tt>glutWireSphere</tt>" and "<tt>glutSolidSphere</tt>" functions
1524 draw a wireframe and solid sphere respectively.
1526 <p><b>Usage</b> </p>
1528 <p><tt>void glutWireSphere ( GLdouble dRadius,
1529 GLint slices, GLint stacks ) ;</tt> </p>
1531 <p><tt>void glutSolidSphere ( GLdouble dRadius,
1532 GLint slices, GLint stacks ) ;</tt> </p>
1534 <p><tt>dRadius
1535 </tt>The desired radius of the sphere </p>
1537 <p><tt>slices
1538 </tt>The desired number of slices (divisions
1539 in the longitudinal direction) in the sphere </p>
1541 <p><tt>stacks
1542 </tt>The desired number of stacks (divisions
1543 in the latitudinal direction) in the sphere. The number of points in
1544 this direction, including the north and south poles, is <tt>stacks+1</tt>
1547 <p><b>Description</b> </p>
1549 <p>The "<tt>glutWireSphere</tt>" and "<tt>
1550 glutSolidSphere</tt>" functions render a sphere centered at the origin
1551 of the modeling coordinate system. The north and south poles of the
1552 sphere are on the positive and negative Z-axes respectively and the prime
1553 meridian crosses the positive X-axis. </p>
1555 <p><b>Changes From GLUT</b> </p>
1557 <p>None that we know of. </p>
1559 <h2> 15.2 glutWireTorus, glutSolidTorus</h2>
1560 The "<tt>glutWireTorus</tt>" and "<tt>glutSolidTorus</tt>" functions draw
1561 a wireframe and solid torus (donut shape) respectively.
1563 <p><b>Usage</b> </p>
1565 <p><tt>void glutWireTorus ( GLdouble dInnerRadius,
1566 GLdouble dOuterRadius, GLint nSides, GLint nRings ) ;</tt> </p>
1568 <p><tt>void glutSolidTorus ( GLdouble dInnerRadius,
1569 GLdouble dOuterRadius, GLint nSides, GLint nRings ) ;</tt> </p>
1571 <p><tt>dInnerRadius
1572 </tt>The desired inner radius of the torus,
1573 from the origin to the circle defining the centers of the outer circles </p>
1575 <p><tt>dOuterRadius
1576 </tt>The desired outer radius of the torus,
1577 from the center of the outer circle to the actual surface of the torus </p>
1579 <p><tt>nSides
1580 </tt>The desired number of segments in a
1581 single outer circle of the torus </p>
1583 <p><tt>nRings
1584 </tt>The desired number of outer circles
1585 around the origin of the torus </p>
1587 <p><b>Description</b> </p>
1589 <p>The "<tt>glutWireTorus</tt>" and "<tt>
1590 glutSolidTorus</tt>" functions render a torus centered at the origin of
1591 the modeling coordinate system. The torus is circularly symmetric about
1592 the Z-axis and starts at the positive X-axis. </p>
1594 <p><b>Changes From GLUT</b> </p>
1596 <p>None that we know of. </p>
1598 <h2> 15.3 glutWireCone, glutSolidCone</h2>
1599 The "<tt>glutWireCone</tt>" and "<tt>glutSolidCone</tt>" functions draw
1600 a wireframe and solid cone respectively.
1602 <p><b>Usage</b> </p>
1604 <p><tt>void glutWireCone ( GLdouble base,
1605 GLdouble height, GLint slices, GLint stacks ) ;</tt> </p>
1607 <p><tt>void glutSolidCone ( GLdouble base,
1608 GLdouble height, GLint slices, GLint stacks ) ;</tt> </p>
1610 <p><tt>base
1611 </tt>The desired radius of the base of the
1614 <p><tt>height
1615 </tt>The desired height of the cone </p>
1617 <p><tt>slices
1618 </tt>The desired number of slices around
1619 the base of the cone </p>
1621 <p><tt>stacks
1622 </tt>The desired number of segments between
1623 the base and the tip of the cone (the number of points, including the tip,
1624 is <tt>stacks + 1</tt>) </p>
1626 <p><b>Description</b> </p>
1628 <p>The "<tt>glutWireCone</tt>" and "<tt>
1629 glutSolidCone</tt>" functions render a right circular cone with a base
1630 centered at the origin and in the X-Y plane and its tip on the positive Z-axis.
1631 The wire cone is rendered with triangular elements. </p>
1633 <p><b>Changes From GLUT</b> </p>
1635 <p>None that we know of. </p>
1637 <h2> 15.4 glutWireCube, glutSolidCube</h2>
1638 The "<tt>glutWireCube</tt>" and "<tt>glutSolidCube</tt>" functions draw
1639 a wireframe and solid cube respectively.
1641 <p><b>Usage</b> </p>
1643 <p><tt>void glutWireCube ( GLdouble dSize
1646 <p><tt>void glutSolidCube ( GLdouble dSize
1649 <p><tt>dSize
1650 </tt>The desired length of an edge of the
1653 <p><b>Description</b> </p>
1655 <p>The "<tt>glutWireCube</tt>" and "<tt>
1656 glutSolidCube</tt>" functions render a cube of the desired size, centered
1657 at the origin. Its faces are normal to the coordinate directions. </p>
1659 <p><b>Changes From GLUT</b> </p>
1661 <p>None that we know of. </p>
1663 <h2> 15.5 glutWireTetrahedron, glutSolidTetrahedron</h2>
1664 The "<tt>glutWireTetrahedron</tt>" and "<tt>glutSolidTetrahedron</tt>"
1665 functions draw a wireframe and solid tetrahedron (four-sided Platonic solid)
1667 <p><b>Usage</b> </p>
1669 <p><tt>void glutWireTetrahedron ( void )
1672 <p><tt>void glutSolidTetrahedron ( void
1675 <p><b>Description</b> </p>
1677 <p>The "<tt>glutWireTetrahedron</tt>" and
1678 "<tt>glutSolidTetrahedron</tt>" functions render a tetrahedron whose corners
1679 are each a distance of one from the origin. The length of each side
1680 is 2/3 sqrt(6). One corner is on the positive X-axis and another is
1681 in the X-Y plane with a positive Y-coordinate. </p>
1683 <p><b>Changes From GLUT</b> </p>
1685 <p>None that we know of. </p>
1687 <h2> 15.6 glutWireOctahedron, glutSolidOctahedron</h2>
1688 The "<tt>glutWireOctahedron</tt>" and "<tt>glutSolidOctahedron</tt>" functions
1689 draw a wireframe and solid octahedron (eight-sided Platonic solid) respectively.
1691 <p><b>Usage</b> </p>
1693 <p><tt>void glutWireOctahedron ( void )
1696 <p><tt>void glutSolidOctahedron ( void )
1699 <p><b>Description</b> </p>
1701 <p>The "<tt>glutWireOctahedron</tt>" and
1702 "<tt>glutSolidOctahedron</tt>" functions render an octahedron whose corners
1703 are each a distance of one from the origin. The length of each side
1704 is sqrt(2). The corners are on the positive and negative coordinate
1707 <p><b>Changes From GLUT</b> </p>
1709 <p>None that we know of. </p>
1711 <h2> 15.7 glutWireDodecahedron, glutSolidDodecahedron</h2>
1712 The "<tt>glutWireDodecahedron</tt>" and "<tt>glutSolidDodecahedron</tt>
1713 " functions draw a wireframe and solid dodecahedron (twelve-sided Platonic
1714 solid) respectively.
1715 <p><b>Usage</b> </p>
1717 <p><tt>void glutWireDodecahedron ( void
1720 <p><tt>void glutSolidDodecahedron ( void
1723 <p><b>Description</b> </p>
1725 <p>The "<tt>glutWireDodecahedron</tt>" and
1726 "<tt>glutSolidDodecahedron</tt>" functions render a dodecahedron whose corners
1727 are each a distance of sqrt(3) from the origin. The length of each
1728 side is sqrt(5)-1. There are twenty corners; interestingly enough,
1729 eight of them coincide with the corners of a cube with sizes of length 2.
1732 <p><b>Changes From GLUT</b> </p>
1734 <p>None that we know of. </p>
1736 <h2> 15.8 glutWireIcosahedron, glutSolidIcosahedron</h2>
1737 The "<tt>glutWireIcosahedron</tt>" and "<tt>glutSolidIcosahedron</tt>"
1738 functions draw a wireframe and solid icosahedron (twenty-sided Platonic solid)
1740 <p><b>Usage</b> </p>
1742 <p><tt>void glutWireIcosahedron ( void )
1745 <p><tt>void glutSolidIcosahedron ( void
1748 <p><b>Description</b> </p>
1750 <p>The "<tt>glutWireIcosahedron</tt>" and
1751 "<tt>glutSolidIcosahedron</tt>" functions render an icosahedron whose corners
1752 are each a unit distance from the origin. The length of each side is
1753 slightly greater than one. Two of the corners lie on the positive and
1754 negative X-axes. </p>
1756 <p><b>Changes From GLUT</b> </p>
1758 <p>None that we know of. </p>
1760 <h2> 15.7 glutWireRhombicDodecahedron,
1761 glutSolidRhombicDodecahedron</h2>
1762 The "<tt>glutWireRhombicDodecahedron</tt>" and "<tt>glutSolidRhombicDodecahedron</tt>
1763 " functions draw a wireframe and solid rhombic dodecahedron (twelve-sided
1764 semi-regular solid) respectively.
1765 <p><b>Usage</b> </p>
1767 <p><tt>void glutWireRhombicDodecahedron
1768 ( void ) ;</tt> </p>
1770 <p><tt>void glutSolidRhombicDodecahedron
1771 ( void ) ;</tt> </p>
1773 <p><b>Description</b> </p>
1775 <p>The "<tt>glutWireRhombicDodecahedron</tt>
1776 " and "<tt>glutSolidRhombicDodecahedron</tt>" functions render a rhombic
1777 dodecahedron whose corners are at most a distance of one from the origin.
1778 The rhombic dodecahedron has faces which are identical rhombuses (rhombi?)
1779 but which have some vertices at which three faces meet and some vertices at
1780 which four faces meet. The length of each side is sqrt(3)/2. Vertices
1781 at which four faces meet are found at (0, 0, <u>+</u>1) and (<u> +</u>sqrt(2)/2,
1782 <u>+</u>sqrt(2)/2, 0). </p>
1784 <p><b>Changes From GLUT</b> </p>
1786 <p>GLUT does not include these functions.
1789 <h2> 15.10 glutWireTeapot, glutSolidTeapot</h2>
1790 The "<tt>glutWireTeapot</tt>" and "<tt>glutSolidTeapot</tt>" functions
1791 draw a wireframe and solid teapot respectively.
1793 <p><b>Usage</b> </p>
1795 <p><tt>void glutWireTeapot ( GLdouble dSize
1798 <p><tt>void glutSolidTeapot ( GLdouble dSize
1801 <p><tt>dSize
1802 </tt>The desired size of the teapot </p>
1804 <p><b>Description</b> </p>
1806 <p>The "<tt>glutWireTeapot</tt>" and "<tt>
1807 glutSolidTeapot</tt>" functions render a teapot of the desired size, centered
1808 at the origin. This is the famous OpenGL teapot [add reference]. </p>
1810 <p><b>Changes From GLUT</b> </p>
1812 <p>None that we know of. </p>
1814 <h1> 16.0 <a name="GameMode"></a>
1815 Game Mode Functions</h1>
1817 <h2> 16.1 glutGameModeString</h2>
1819 <h2> 16.2 glutEnterGameMode, glutLeaveGameMode</h2>
1821 <h2> 16.3 glutGameModeGet</h2>
1823 <h1> 17.0 <a name="VideoResize"></a>
1824 Video Resize Functions</h1>
1826 <h2> 17.1 glutVideoResizeGet</h2>
1828 <h2> 17.2 glutSetupVideoResizing,
1829 glutStopVideoResizing</h2>
1831 <h2> 17.3 glutVideoResize</h2>
1833 <h2> 17.4 glutVideoPan</h2>
1835 <h1> 18.0 <a name="ColorMap"></a>
1836 Color Map Functions</h1>
1838 <h2> 18.1 glutSetColor, glutGetColor</h2>
1840 <h2> 18.2 glutCopyColormap</h2>
1842 <h1> 19.0 <a name="Miscellaneous"></a>
1843 Miscellaneous Functions</h1>
1845 <h2> 19.1 glutIgnoreKeyRepeat, glutSetKeyRepeat</h2>
1847 <h2> 19.2 glutForceJoystickFunc</h2>
1849 <h2> 19.3 glutReportErrors</h2>
1851 <h1> 20.0 <a name="UsageNotes"></a>
1854 <p> The following environment variables
1855 are recognized by <i>freeglut</i>: </p>
1857 <li>DISPLAY - specifies a display name.<br>
1859 <li>GLUT_FPS - specifies a time interval
1860 (in milliseconds) for reporting framerate messages to stderr. For example,
1861 if FREEGLUT_FPS is set to 5000, every 5 seconds a message will be printed
1862 to stderr showing the current frame rate. The frame rate is measured by counting
1863 the number of times glutSwapBuffers() is called over the time interval.</li>
1864 <li>GLUT_ICON - specifies the icon that
1865 goes in the upper left-hand corner of the <i>freeglut</i><i> </i>windows </li>
1867 <h1> 21.0 <a name="ImplementationNotes"></a>
1868 Implementation Notes</h1>
1870 <h1> 22.0 <a name="GLUT_State"></a>
1873 <h1> 23.0 <a name="Freeglut.h_Header"></a>
1874 "freeglut.h" Header File</h1>
1878 Application programmers who are porting their GLUT programs to <i>freeglut</i> may continue
1879 to include <tt><GL/glut.h></tt> in their programs.
1880 Programs which use the <i>freeglut</i>-specific extensions to GLUT should include
1881 <tt><GL/freeglut.h></tt>. One possible arrangement is as follows:
1886 #include <GL/freeglut_ext.h>
1888 #include <GL/glut.h>
1893 Compile-time <i>freeglut</i> version testing can be done as follows:
1897 #ifdef FREEGLUT_VERSION_1_4
1898 code specific to freeglut 1.4 or later here
1903 In future releases, FREEGLUT_VERSION_1_5, FREEGLUT_VERSION_1_6, etc will
1904 be defined. This scheme mimics OpenGL conventions.
1908 The <i>freeglut</i> version can be queried at runtime by calling
1909 glutGet(GLUT_VERSION).
1910 The result will be X*10000+Y*100+Z where X is the major version, Y is the
1911 minor version and Z is the patch level.
1914 This may be used as follows:
1918 if (glutGet(GLUT_VERSION) < 10300) {
1919 printf("Sorry, you need freeglut version 1.3.0 or later to run this program.\n");
1926 <h1> 24.0 <a name="References"></a>
1929 <h1> 25.0 <a name="Index"></a>