Version 0.3 - Added missing function prorotypes.
The OpenGL programming world owes a tremendous debt to Mr. Mark J. Kilgard for writing the OpenGL Utility Toolkit, or GLUT. The GLUT library of functions allows an application programmer to create, control, and manipulate windows independent of what operating system the program is running on. By hiding the dependency on the operating system from the application programmer, he allowed people to write truly portable OpenGL applications.
Mr. Kilgard copyrighted his library and gave it a rather unusual license. Under his license, people are allowed freely to copy and distribute the libraries and the source code, but they are not allowed to modify it. For a long time this did not matter because the GLUT library worked so well and because Mr. Kilgard was releasing updates on a regular basis. But with the passage of time, people started wanting some slightly different behaviours in their windowing system. When Mr. Kilgard stopped supporting the GLUT library in 1999, having moved on to bigger and better things, this started to become a problem.
In December 1999, Mr. Pawel Olzsta started work on an open-source clone of the GLUT library. This open-source clone, which does not use any of the GLUT source code, has evolved into the present freeglut library. This documentation specifies the application program interface to the freeglut library.
Since the freeglut library was developed in order to update GLUT, it is natural that there will be some differences between the two. Each function in the API notes any differences between the GLUT and the freeglut function behaviours. The important ones are summarized here.
One of the commonest complaints about the GLUT library was that once an application called glutMainLoop, it never got control back. There was no way for an application to loop in GLUT for a while, possibly as a subloop while a specific window was open, and then return to the calling function. A new function, glutMainLoopEvent, has been added to allow this functionality. Another function, glutLeaveMainLoop, has also been added to allow the application to tell freeglut to clean up and close down.
Another difficulty with GLUT, especially with multiple-window programs, is that if the user clicks on the "x" in the window header the application exits immediately. The application programmer can now set an option, GLUT_ACTION_ON_WINDOW_CLOSE, to specify whether execution should continue, whether GLUT should return control to the main program, or whether GLUT should simply exit (the default).
Several new callbacks have been added and several callbacks which were specific to Silicon Graphics hardware have not been implemented. Most or all of the new callbacks are listed in the GLUT Version 4 "glut.h" header file but did not make it into the documentation. The new callbacks consist of regular and special key release callbacks, a joystick callback, a menu state callback (with one argument, distinct from the menu status callback which has three arguments), and a window status callback (also with one argument). Unsupported callbacks are the three Spaceball callbacks, the ButtonBox callback, the Dials callback, and the two Tablet callbacks. If the user has a need for an unsupported callback he should contact the freeglut development team.
New functions have been added to render full character strings (including carriage returns) rather than rendering one character at a time. More functions return the widths of character strings and the font heights, in pixels for bitmapped fonts and in OpenGL units for the stroke fonts.
Two functions have been added to render a wireframe and a solid rhombic dodecahedron.
glutGetProcAddress is a wrapper for the glXGetProcAddressARB and wglGetProcAddress functions.
void glutInit ( int * argcp, char ** argv );
argcp Pointer to the argc variable from
the main function of the program.
argv The argv variable from the main
function of the program.
The glutInit function should be called before parsing command line options, since freeglut may update the argc and argv variables when extracting options he recognises.
The glutInitWindowPosition and glutInitWindowSize functions specify a desired position and size for windows that freeglut will create in the future.
void glutInitWindowPosition ( int x, int y );
void glutInitWindowSize ( int width, int height );
The glutInitWindowPosition and glutInitWindowSize functions specify a desired position and size for windows that freeglut will create in the future. The position is measured in pixels from the upper left hand corner of the screen, with "x" increasing to the right and "y" increasing towards the bottom of the screen. The size is measured in pixels. Freeglut does not promise to follow these specifications in creating its windows, it certainly makes an attempt to.
The position and size of a window are a matter of some subtlety. Most windows have a usable area surrounded by a border and with a title bar on the top. The border and title bar are commonly called "decorations." The position of the window unfortunately varies with the operating system. On Linux, it is the coordinates of the upper left-hand corner of its decorations. On Windows, it is the coordinates of the upper left hand corner of its usable interior. For both operating systems, the is the coordinates of the upper left-hand corner of its usable interior. The size of the window is the size of the usable interior.
Windows The Windows operating system has some additional quirks which the application programmer should know about. First, the minimum y-coordinate of a window decoration is zero. (This is a feature of freeglut and can be adjusted if so desired.) Second, there appears to be a minimum window width on Windows which is 104 pixels. The user may specify a smaller width, but the Windows system calls ignore it. It is also impossible to make a window narrower than this by dragging on its corner.
For some reason, GLUT is not affected by the 104-pixel minimum window width. If the user clicks on the corner of a window which is narrower than this amount, the window will immediately snap out to this width, but the application can call glutReshapeWindow and make a window narrower again.
The glutInitDisplayMode function sets the initial display mode.
void glutInitDisplayMode ( unsigned int mode );
mode The bitwise OR-ing display mode bit masks. Values can be:
After an application has finished initializing its windows and menus, it enters an event loop. Within this loop, freeglut polls the data entry devices (keyboard, mouse, etc.) and calls the application's appropriate callbacks.
In GLUT, control never returned from the event loop (as invoked by the glutMainLoop function) to the calling function. This prevented an application from having re-entrant code, in which GLUT could be invoked from within a callback, and it prevented the application from doing any post-processing (such as freeing allocated memory) after GLUT had closed down. Freeglut allows the application programmer to specify more direct control over the event loop by means of two new functions. The first, glutMainLoopEvent, processes a single iteration of the event loop and allows the application to use a different event loop controller or to contain re-entrant code. The second, glutLeaveMainLoop, causes the event loop to exit nicely; this is preferable to the application's calling exit from within a GLUT callback.
The glutMainLoop function enters the event loop.
void glutMainLoop ( void );
The glutMainLoop function causes the program to enter the window event loop. An application should call this function at most once. It will call any application callback functions as required to process mouse clicks, mouse motion, key presses, and so on.
In GLUT, there was absolutely no way for the application programmer to have control return from the glutMainLoop function to the calling function. Freeglut allows the programmer to force this have control return from the glutMainLoop function to the calling function by setting the GLUT_ACTION_ON_WINDOW_CLOSE option and invoking the glutLeaveMainLoop function from one of the callbacks. Stopping the program this way is preferable to simply calling exit from within a callback because this allows freeglut to free allocated memory and otherwise clean up after itself. (I know I just said this, but I think it is important enough that it bears repeating.)
The glutMainLoopEvent function processes a single iteration in the freeglut event loop.
void glutMainLoopEvent ( void );
The glutMainLoopEvent function causes freeglut to process one iteration's worth of events in its event loop. This allows the application to control its own event loop and still use the freeglut windowing system. Once the application's loop has ended and there is no more call to glutMainLoopEvent, the glutExit function can be called to deinitialise freeglut.
GLUT does not include this function.
The glutLeaveMainLoop function causes freeglut to stop its event loop.
void glutLeaveMainLoop ( void );
The glutLeaveMainLoop function causes freeglut to stop the event loop. If the GLUT_ACTION_ON_WINDOW_CLOSE option has been set to GLUT_ACTION_CONTINUE_EXECUTION, control will return to the function which called glutMainLoop; otherwise the application will exit.
If the application has two nested calls to glutMainLoop and calls glutLeaveMainLoop, the behaviour of freeglut is undefined. It may leave only the inner nested loop or it may leave both loops. If the reader has a strong preference for one behaviour over the other he should contact the freeglut Programming Consortium and ask for the code to be fixed.
GLUT does not include this function.
The glutExit function causes freeglut to deinitialise itself.
void glutExit ( void );
The glutExit function causes freeglut to deinitialise itself. If the application uses its own event loop, this function can be called after the loop has ended and there is no more calls to glutMainLoopEvent.
The function should not be called while beeing inside the freeglut main loop, or even after it has ended, since freeglut will automatically deinitialise itself when leaving the loop.
int glutCreateWindow ( char * name );
name The name of the window to be created.
int glutCreateSubWindow ( int win, int x, int y, int width, int height );
win The identifier of the subwindow's parent, as returned by
the glutCreateWindow function.
x, y The coordinates of the origin of the subwindow,
relative to the origin of its parent.
width, height The size of the subwindow.
void glutDestroyWindow ( int win );
win The identifier of the window to be destroyed.
void glutSetWindow ( int win );
int glutGetWindow ( void );
win The identifier of the window to be set as the current window.
void glutSetWindowTitle ( char * windowName );
void glutSetIconTitle ( char * iconName );
windowName The name of the current window.
iconName The name of the current window's icon.
void glutReshapeWindow ( int width, int height );
width, height The new size of the current window.
void glutPositionWindow ( int x, int y );
x, y The new coordinates of the origin of the current window.
void glutShowWindow ( void );
void glutHideWindow ( void );
void glutIconifyWindow ( void );
void glutPushWindow ( void );
void glutPopWindow ( void );
void glutFullScreen ( void );
void glutPostRedisplay ( void );
The glutPostWindowRedisplay function marks the specified window as needing to be redisplayed.
void glutPostWindowRedisplay ( int windowID );
windowID The identifier of the window to be marked.
The glutPostWindowRedisplay function behaves the same way glutPostRedisplay does, but it marks the specified window rather than the current window.
void glutSwapBuffers ( void );
The glutSetCursor function sets the cursor of the current window.
void glutSetCursor ( int cursor );
cursor The name of the cursor image, one of:
The GLUT_CURSOR_TOP_SIDE, GLUT_CURSOR_BOTTOM_SIDE, GLUT_CURSOR_LEFT_SIDE, GLUT_CURSOR_RIGHT_SIDE and GLUT_CURSOR_INHERIT cursors are not implemented for the Windows operating system in freeglut.
void glutWarpPointer ( int x, int y );
x, y The new coordinates of the pointer relative to the current window.
Freeglut does not allow overlays, although it does "answer the mail" with function stubs so that GLUT-based programs can compile and link against freeglut without modification.
If the reader needs overlays, he should contact the freeglut Programming Consortium and ask for them to be implemented. He should also be prepared to assist in the implementation.
The glutEstablishOverlay function is not implemented in freeglut.
void glutEstablishOverlay ( void );
The glutEstablishOverlay function is not implemented in freeglut.
GLUT implements this function.
The glutRemoveOverlay function is not implemented in freeglut.
void glutRemoveOverlay ( void );
The glutRemoveOverlay function is not implemented in freeglut.
GLUT implements this function.
The glutUseLayer function is not implemented in freeglut.
void glutUseLayer ( GLenum layer );
The glutUseLayer function is not implemented in freeglut.
GLUT implements this function.
The glutPostOverlayRedisplay function is not implemented in freeglut.
void glutPostOverlayRedisplay ( void );
The glutPostOverlayRedisplay function is not implemented in freeglut.
GLUT implements this function.
The glutPostWindowOverlayRedisplay function is not implemented in freeglut.
void glutPostWindowOverlayRedisplay ( int window );
The glutPostWindowOverlayRedisplay function is not implemented in freeglut.
GLUT implements this function.
The glutShowOverlay and glutHideOverlay functions are not implemented in freeglut.
void glutShowOverlay( void );
void glutHideOverlay( void );
The glutShowOverlay and glutHideOverlay functions are not implemented in freeglut.
GLUT implements these functions.
int glutCreateMenu( void (* func)( int menu ) );
func The callback function that is called when a menu entry
is selected.
value The value associated with the selected menu entry, as
set by the glutAddMenuEntry function.
void glutDestroyMenu( int menu );
menu The identifier of the menu to destroy, as returned by the glutCreateMenu function.
int glutGetMenu( void );
void glutSetMenu( int menu );
menu The identifier of the menu to be set as the current menu, as returned by the glutCreateMenu function.
void glutAddMenuEntry( const char * label, int value );
label The label of the new menu entry.
value The value passed to the menu's callback function when
the entry is selected.
void glutAddSubMenu( const char * label, int subMenu );
label The label of the new sub-menu.
subMenu The identifier of the sub-menu to be added to the
current menu, as returned by the glutCreateMenu function.
void glutChangeToMenuEntry( int item, const char * label, int value );
item The index (starting at 1) of the menu item to be
changed into a menu entry inside the current menu.
label The label of the menu entry.
value The value passed to the menu's callback function when
the entry is selected.
void glutChangeToMenuEntry( int item, const char * label, int value );
item The index (starting at 1) of the menu item to be
changed into a sub-menu inside the current menu.
label The label of the sub-menu.
subMenu The identifier of the sub-menu, as returned by
the glutCreateMenu function.
void glutRemoveMenuItem( int item );
item The index (starting at 1) of the menu item to be removed.
void glutAttachMenu( int button );
void glutDetachMenu( int button );
button The button to attach or detach the current menu.
void glutTimerFunc( unsigned int time, void (* func)( int value), int value );
time The number of milliseconds to wait before the callback
function is called.
func The callback function to be called.
value The value to pass to the callback function.
The glutIdleFunc function sets the global idle callback. Freeglut calls the idle callback when there are no inputs from the user.
void glutIdleFunc ( void (* func) ( void ) );
func The new global idle callback function
The glutIdleFunc function specifies the function
that freeglut will call to perform background processing tasks
such as continuous animation when window system events are not being
received. If enabled, this function is called continuously
from freeglut while no events are received. The callback
function has no parameters and returns no value. Freeglut does
not change the current window or the current menu before
invoking the idle callback; programs with multiple windows or menus must
explicitly set the current window and current menu and not
rely on its current setting.
The amount of computation and rendering done in an idle callback should
be minimized to avoid affecting the program's interactive response. In
general, no more than a single frame of rendering should be done in a
single invocation of an idle callback.
Calling glutIdleFunc with a NULL argument disables the call to
an idle callback.
Application programmers should note that if they have specified the "continue execution" action on window closure, freeglut will continue to call the idle callback after the user has closed a window by clicking on the "x" in the window header bar. If the idle callback renders a particular window (this is considered bad form but is frequently done anyway), the programmer should supply a window closure callback for that window which changes or disables the idle callback.
void glutTimerFunc( void (* func)( void ) );
func The callback function to be called.
void glutReshapeFunc ( void (* func) ( int width, int height ) );
func The callback function to be called.
width, height The new window size.
The glutCloseFunc function sets the window's close callback. Freeglut calls the close callback when the user close the window.
void glutCloseFunc ( void (* func) ( void ) );
func The window's new close function callback function to be called.
void glutKeyboardFunc ( void (* func) ( unsigned char key, int x, int y ) );
func The callback function to be called.
key The key whose press triggers the callback.
x, y The coordinates of the mouse relative to the
window at the time the key is pressed.
The glutSpecialFunc function sets the window's special key press callback. Freeglut calls the special key press callback when the user presses a special key.
void glutSpecialFunc ( void (* func) ( int key, int x, int y ) );
func The window's new special key press callback function
key The key whose press triggers the callback
x The x-coordinate of the mouse relative to the window at the
time the key is pressed
y The y-coordinate of the mouse relative to the window at the
time the key is pressed
The glutSpecialFunc function specifies the function
that freeglut will call when the user presses a special key on
the keyboard. The callback function has one argument: the name of the
function to be invoked ("called back") at the time at which the special
key is pressed. The function returns no value. Freeglut sets
the current window to the window which is active when the
callback is invoked. "Special keys" are the function keys, the arrow
keys, the Page Up and Page Down keys, and the Insert key. The Delete
key is considered to be a regular key.
Calling glutSpecialUpFunc with a NULL argument disables the
call to the window's special key press callback.
The key argument may take one of the following defined constant values:
None.
The glutKeyboardUpFunc function sets the window's key release callback. Freeglut calls the key release callback when the user releases a key.
void glutKeyboardUpFunc ( void (* func) ( unsigned char key, int x, int y ) );
func The window's new key release callback function
key The key whose release triggers the callback
x The x-coordinate of the mouse relative to the window at the
time the key is released
y The y-coordinate of the mouse relative to the window at the
time the key is released
The glutKeyboardUpFunc function specifies the function
that freeglut will call when the user releases a key from the
keyboard. The callback function has one argument: the name of the
function to be invoked ("called back") at the time at which the key is
released. The function returns no value. Freeglut sets
the current window to the window which is active when the
callback is invoked.
While freeglut checks for upper or lower case letters, it does
not do so for non-alphabetical characters. Nor does it account for the
Caps-Lock key being on. The operating system may send some unexpected
characters to freeglut, such as "8" when the user is pressing the
Shift key. Freeglut also invokes the callback when the user
releases the Control, Alt, or Shift keys, among others. Releasing the
Delete key causes this function to be invoked with a value of 127
for key.
Calling glutKeyboardUpFunc with a NULL argument disables the
call to the window's key release callback.
This function is not implemented in GLUT versions before Version 4. It has been designed to be as close to GLUT as possible. Users who find differences should contact the freeglutProgramming Consortium to have them fixed.
The glutSpecialUpFunc function sets the window's special key release callback. Freeglut calls the special key release callback when the user releases a special key.
void glutSpecialUpFunc ( void (* func) ( int key, int x, int y ) );
func The window's new special key release callback
function
key The key whose release triggers the callback
x The x-coordinate of the mouse relative to the window at the
time the key is released
y The y-coordinate of the mouse relative to the window at the
time the key is released
The glutSpecialUpFuncfunction specifies the function
that freeglut will call when the user releases a special key from
the keyboard. The callback function has one argument: the name of the
function to be invoked ("called back") at the time at which the special
key is released. The function returns no value. Freeglut sets
the current window to the window which is active when the
callback is invoked. "Special keys" are the function keys, the arrow
keys, the Page Up and Page Down keys, and the Insert key. The Delete
key is considered to be a regular key.
Calling glutSpecialUpFunc with a NULL argument disables the
call to the window's special key release callback.
The key argument may take one of the following defined constant values:
This function is not implemented in GLUT versions before Version 4. It has been designed to be as close to GLUT as possible. Users who find differences should contact the freeglut Programming Consortium to have them fixed.
void glutMouseFunc ( void (* func) ( int button, int state, int x, int y ) );
func The callback function to be called.
button The button that is pressed or released.
state The state of the button, one of:
x, y The coordinates of the mouse relative to the
window at the time the button is pressed or released.
void glutMotionFunc ( void (* func) ( int x, int y ) );
void glutPassiveMotionFunc ( void (* func) ( int x, int y )
);
func The callback function to be called.
x, y The coordinates of the mouse relative to the
window.
void glutVisibilityFunc ( void (* func) ( int state ) );
func The callback function to be called.
state The visibility state of the window, one of:
void glutEntryFunc ( void (* func) ( int state ) );
func The callback function to be called.
state The state of the window, one of:
void glutJoystickFunc ( void (* func) ( unsigned int buttonMask, int x, int y, int z ), int pollInterval );
func The callback function to be called.
The glutSpaceballMotionFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutSpaceballMotionFunc ( void (* callback)( int x, int y, int z ) );
The glutSpaceballMotionFunc function is not implemented in freeglut.
GLUT implements this function.
The glutSpaceballRotateFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutSpaceballRotateFunc ( void (* callback)( int x, int y, int z ) );
The glutSpaceballRotateFunc function is not implemented in freeglut.
GLUT implements this function.
The glutSpaceballButtonFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutSpaceballButtonFunc ( void (* callback)( int button, int updown ) );
The glutSpaceballButtonFunc function is not implemented in freeglut.
GLUT implements this function.
The glutSpaceballButtonBoxFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutSpaceballButtonBoxFunc ( void (* callback)( int button, int updown ) );
The glutSpaceballButtonBoxFunc function is not implemented in freeglut.
GLUT implements this function.
The glutDialsFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutDialsFunc ( void (* callback)( int dial, int value ) );
The glutDialsFunc function is not implemented in freeglut.
GLUT implements this function.
The glutTabletMotionFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutTabletMotionFunc ( void (* callback)( int x, int y ) );
The glutTabletMotionFunc function is not implemented in freeglut.
GLUT implements this function.
The glutTabletButtonFunc function is not implemented in freeglut, although the library does "answer the mail" to the extent that a call to the function will not produce an error..
void glutTabletButtonFunc ( void (* callback)( int button, int updown, int x, int y ) );
The glutTabletButtonFunc function is not implemented in freeglut.
GLUT implements this function.
void glutMenuStatusFunc ( void (* func) ( int status, int x, int y ) );
func The callback function to be called.
status The status of the menu, one of:
x, y The coordinates of the mouse relative to the window.
The glutWindowStatusFunc function sets the window's status callback. Freeglut calls the status callback when the visibility of the window changes.
void glutWindowStatusFunc ( void (* callback func)( int status ) );
callback func the window's status
callback function
status the window's new visibility status
The glutWindowStatusFunc specifies the function that freeglut will call when the visibility of the window changes. It is somewhat similar to the glutVisibilityFunc callback registration function but can give more informations about the window's visibility status.
Values for the status parameter can be:
The glutSetOption function sets freeglut options.
void glutSetOption ( unsigned int option, int value );
option The name of the option to be set
value The value of the option to be set
Option name can be one of:
The glutSetOption can be called to set freeglut options to a given value.
Setting option to GLUT_ACTION_ON_WINDOW_CLOSE allows to choose which action freeglut will perform when the user closes a window. value can be one of:
Setting option to GLUT_RENDERING_CONTEXT allows to control if new windows may be created with the OpenGL rendering context of the current window (at the time a new window is created) or not. value can be one of:
int glutGet ( GLenum state );
state The state to query.
The following state variables may be queried with glutGet. The returned value is an integer.
These queries are with respect to the current window:
These queries do not depend on the current window.
When state is GLUT_ELAPSED_TIME or GLUT_INIT_STATE, glutGet may be called before glutInit.
The GLUT_WINDOW_COLORMAP_SIZE state is not implemented on Windows in freeglut.
int glutDeviceGet ( GLenum info );
info The information to query.
The following info variables information may be queried with glutDeviceGet. The returned value is an integer.
The following informations are not completely reliable in freeglut. Depending on the system, a value of 1 may always be returned.
int glutGetModifiers ( void );
The glutGetModifiers functions returns one of the following values:
int glutExtensionSupported ( const char * extension );
extension The name of the OpenGL extension to query.
glutGetProcAddress returns a pointer to a named GL or freeglut function.
void *glutGetProcAddress ( const char *procName );
procName Name of an OpenGL or GLUT function.
glutGetProcAddress is useful for dealing with OpenGL extensions. If an application calls OpenGL extension functions directly, that application will only link/run with an OpenGL library that supports the extension. By using a function pointer returned from glutGetProcAddress(), the application will avoid this hard dependency and be more portable and interoperate better with various implementations of OpenGL.
Both OpenGL functions and freeglut functions can be queried with this function.
GLUT does not include this function.
Freeglut supports two types of font rendering: bitmap fonts, which are rendered using the glBitmap function call, and stroke fonts, which are rendered as sequences of OpenGL line segments. Because they are rendered as bitmaps, the bitmap fonts tend to render more quickly than stroke fonts, but they are less flexible in terms of scaling and rendering. Bitmap font characters are positioned with calls to the glRasterPos* functions while stroke font characters use the OpenGL transformations to position characters.
It should be noted that freeglut fonts are similar but not identical to GLUT fonts. At the moment, freeglut fonts do not support the "`" (backquote) and "|" (vertical line) characters; in their place it renders asterisks.
Freeglut supports the following bitmap fonts:
Freeglut calls glRasterPos4v to advance the cursor by the width of a character and to render carriage returns when appropriate. It does not use any display lists in it rendering in bitmap fonts.
Freeglut supports the following stroke fonts:
Freeglut does not use any display lists in its rendering of stroke fonts. It calls glTranslatef to advance the cursor by the width of a character and to render carriage returns when appropriate.
The glutBitmapCharacter function renders a single bitmapped character in the current window using the specified font.
void glutBitmapCharacter ( void *font, int character );
font The bitmapped font to use in rendering the character
character The ASCII code of the character to be rendered
The glutBitmapCharacter function renders the given character in the specified bitmap font. Freeglut automatically sets the necessary pixel unpack storage modes and restores the existing modes when it has finished. Before the first call to glutBitMapCharacter the application program should call glRasterPos* to set the position of the character in the window. The glutBitmapCharacter function advances the cursor position as part of its call to glBitmap and so the application does not need to call glRasterPos* again for successive characters on the same line.
Nonexistent characters are rendered as asterisks. The rendering position in freeglut is apparently off from GLUT's position by a few pixels vertically and one or two pixels horizontally.
The glutBitmapString function renders a string of bitmapped characters in the current window using the specified font.
void glutBitmapString ( void *font, char *string );
font The bitmapped font to use in rendering the character
string
string String of characters to be rendered
The glutBitmapString function renders the given character string in the specified bitmap font. Freeglut automatically sets the necessary pixel unpack storage modes and restores the existing modes when it has finished. Before calling glutBitMapString the application program should call glRasterPos* to set the position of the string in the window. The glutBitmapString function handles carriage returns. Nonexistent characters are rendered as asterisks.
GLUT does not include this function.
The glutBitmapWidth function returns the width in pixels of a single bitmapped character in the specified font.
int glutBitmapWidth ( void *font, int character );
fontThe bitmapped font to use in calculating the character
width
character The ASCII code of the character
The glutBitmapWidth function returns the width of the given character in the specified bitmap font. Because the font is bitmapped, the width is an exact integer.
Nonexistent characters return the width of an asterisk.
The glutBitmapLength function returns the width in pixels of a string of bitmapped characters in the specified font.
int glutBitmapLength ( void *font, char *string );
font The bitmapped font to use in calculating the character
width
string String of characters whose width is to be
calculated
The glutBitmapLength function returns the width in pixels of the given character string in the specified bitmap font. Because the font is bitmapped, the width is an exact integer: the return value is identical to the sum of the character widths returned by a series of calls to glutBitmapWidth. The width of nonexistent characters is counted to be the width of an asterisk.
If the string contains one or more carriage returns, freeglut calculates the widths in pixels of the lines separately and returns the largest width.
GLUT does not include this function.
The glutBitmapHeight function returns the height in pixels of the specified font.
int glutBitmapHeight ( void *font );
font The bitmapped font to use in calculating the character height
The glutBitmapHeight function returns the height of a character in the specified bitmap font. Because the font is bitmapped, the height is an exact integer. The fonts are designed such that all characters have (nominally) the same height.
GLUT does not include this function.
The glutStrokeCharacter function renders a single stroke character in the current window using the specified font.
void glutStrokeCharacter ( void *font, int character );
fontThe stroke font to use in rendering the character
characterThe ASCII code of the character to be rendered
The glutStrokeCharacter function renders the given character in the specified stroke font. Before the first call to glutStrokeCharacter the application program should call the OpenGL transformation (positioning and scaling) functions to set the position of the character in the window. The glutStrokeCharacter function advances the cursor position by a call to glTranslatef and so the application does not need to call the OpenGL positioning functions again for successive characters on the same line.
Nonexistent characters are rendered as asterisks.
The glutStrokeString function renders a string of characters in the current window using the specified stroke font.
void glutStrokeString ( void *font, char *string );
font The stroke font to use in rendering the character string
string String of characters to be rendered
The glutStrokeString function renders the given character string in the specified stroke font. Before calling glutStrokeString the application program should call the OpenGL transformation (positioning and scaling) functions to set the position of the string in the window. The glutStrokeString function handles carriage returns. Nonexistent characters are rendered as asterisks.
GLUT does not include this function.
The glutStrokeWidth function returns the width in pixels of a single character in the specified stroke font.
int glutStrokeWidth ( void *font, int character );
font The stroke font to use in calculating the character width
character The ASCII code of the character
The glutStrokeWidth function returns the width of the given character in the specified stroke font. Because the font is a stroke font, the width is actually a floating-point number; the function rounds it to the nearest integer for the return value.
Nonexistent characters return the width of an asterisk.
The glutStrokeLength function returns the width in pixels of a string of characters in the specified stroke font.
int glutStrokeLength ( void *font, char *string );
font The stroke font to use in calculating the character
width
string String of characters whose width is to be
calculated
The glutStrokeLength function returns the width in pixels of the given character string in the specified stroke font. Because the font is a stroke font, the width of an individual character is a floating-point number. Freeglut adds the floating-point widths and rounds the funal result to return the integer value. Thus the return value may differ from the sum of the character widths returned by a series of calls to glutStrokeWidth. The width of nonexistent characters is counted to be the width of an asterisk.
If the string contains one or more carriage returns, freeglut calculates the widths in pixels of the lines separately and returns the largest width.
GLUT does not include this function.
The glutStrokeHeight function returns the height in pixels of the specified font.
GLfloat glutStrokeHeight ( void *font );
fontThe stroke font to use in calculating the character height
The glutStrokeHeight function returns the height of a character in the specified stroke font. The application programmer should note that, unlike the other freeglut font functions, this one returns a floating-point number. The fonts are designed such that all characters have (nominally) the same height.
GLUT does not include this function.
Freeglut includes eighteen routines for generating easily-recognizable 3-d geometric objects. These routines are effectively the same ones that are included in the GLUT library, and reflect the functionality available in the aux toolkit described in the OpenGL Programmer's Guide . They are included to allow programmers to create with a single line of code a three-dimensional object which can be used to test a variety of OpenGL functionality. None of the routines generates a display list for the object which it draws. The functions generate normals appropriate for lighting but, except for the teapon functions, do not generate texture coordinates.
The glutWireSphere and glutSolidSphere functions draw a wireframe and solid sphere respectively.
void glutWireSphere ( GLdouble dRadius, GLint slices, GLint stacks );
void glutSolidSphere ( GLdouble dRadius, GLint slices, GLint stacks );
dRadius The desired radius of the sphere
slices The desired number of slices (divisions in the longitudinal direction) in the sphere
stacks The desired number of stacks (divisions in the latitudinal direction) in the sphere. The number of points in this direction, including the north and south poles, is stacks+1
The glutWireSphere and glutSolidSphere functions render a sphere centered at the origin of the modeling coordinate system. The north and south poles of the sphere are on the positive and negative Z-axes respectively and the prime meridian crosses the positive X-axis.
None that we know of.
The glutWireTorus and glutSolidTorus functions draw a wireframe and solid torus (donut shape) respectively.
void glutWireTorus ( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings );
void glutSolidTorus ( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings );
dInnerRadius The desired inner radius of the torus, from the origin to the circle defining the centers of the outer circles
dOuterRadius The desired outer radius of the torus, from the center of the outer circle to the actual surface of the torus
nSidesThe desired number of segments in a single outer circle of the torus
nRingsThe desired number of outer circles around the origin of the torus
The glutWireTorus and glutSolidTorus functions render a torus centered at the origin of the modeling coordinate system. The torus is circularly symmetric about the Z-axis and starts at the positive X-axis.
None that we know of.
The glutWireCone and glutSolidCone functions draw a wireframe and solid cone respectively.
void glutWireCone ( GLdouble base, GLdouble height, GLint slices, GLint stacks );
void glutSolidCone ( GLdouble base, GLdouble height, GLint slices, GLint stacks );
base The desired radius of the base of the cone
height The desired height of the cone
slices The desired number of slices around the base of the cone
stacks The desired number of segments between the base and the tip of the cone (the number of points, including the tip, is stacks + 1)
The glutWireCone and glutSolidCone functions render a right circular cone with a base centered at the origin and in the X-Y plane and its tip on the positive Z-axis. The wire cone is rendered with triangular elements.
None that we know of.
The glutWireCube and glutSolidCube functions draw a wireframe and solid cube respectively.
void glutWireCube ( GLdouble dSize );
void glutSolidCube ( GLdouble dSize );
dSize The desired length of an edge of the cube
The glutWireCube and glutSolidCube functions render a cube of the desired size, centered at the origin. Its faces are normal to the coordinate directions.
None that we know of.
The glutWireTetrahedron and glutSolidTetrahedron functions draw a wireframe and solid tetrahedron (four-sided Platonic solid) respectively.
void glutWireTetrahedron ( void ) ;
void glutSolidTetrahedron ( void );
The glutWireTetrahedron and glutSolidTetrahedron functions render a tetrahedron whose corners are each a distance of one from the origin. The length of each side is 2/3 sqrt(6). One corner is on the positive X-axis and another is in the X-Y plane with a positive Y-coordinate.
None that we know of.
The glutWireOctahedron and glutSolidOctahedron functions draw a wireframe and solid octahedron (eight-sided Platonic solid) respectively.
void glutWireOctahedron ( void ) ;
void glutSolidOctahedron ( void ) ;
The glutWireOctahedron and glutSolidOctahedron functions render an octahedron whose corners are each a distance of one from the origin. The length of each side is sqrt(2). The corners are on the positive and negative coordinate axes.
None that we know of.
The glutWireDodecahedron and glutSolidDodecahedron functions draw a wireframe and solid dodecahedron (twelve-sided Platonic solid) respectively.
void glutWireDodecahedron ( void );
void glutSolidDodecahedron ( void );
The glutWireDodecahedron and glutSolidDodecahedron functions render a dodecahedron whose corners are each a distance of sqrt(3) from the origin. The length of each side is sqrt(5)-1. There are twenty corners; interestingly enough, eight of them coincide with the corners of a cube with sizes of length 2.
None that we know of.
The glutWireIcosahedron and glutSolidIcosahedron functions draw a wireframe and solid icosahedron (twenty-sided Platonic solid) respectively.
void glutWireIcosahedron ( void ) ;
void glutSolidIcosahedron ( void );
The glutWireIcosahedron and glutSolidIcosahedron functions render an icosahedron whose corners are each a unit distance from the origin. The length of each side is slightly greater than one. Two of the corners lie on the positive and negative X-axes.
None that we know of.
The glutWireRhombicDodecahedron and glutSolidRhombicDodecahedron functions draw a wireframe and solid rhombic dodecahedron (twelve-sided semi-regular solid) respectively.
void glutWireRhombicDodecahedron ( void );
void glutSolidRhombicDodecahedron ( void );
The glutWireRhombicDodecahedron and glutSolidRhombicDodecahedron functions render a rhombic dodecahedron whose corners are at most a distance of one from the origin. The rhombic dodecahedron has faces which are identical rhombuses (rhombi?) but which have some vertices at which three faces meet and some vertices at which four faces meet. The length of each side is sqrt(3)/2. Vertices at which four faces meet are found at (0, 0, +/- 1) and (+/- sqrt(2)/2, +/- sqrt(2)/2, 0).
GLUT does not include these functions.
The glutWireTeapot and glutSolidTeapot functions draw a wireframe and solid teapot respectively.
void glutWireTeapot ( GLdouble dSize );
void glutSolidTeapot ( GLdouble dSize );
dSize The desired size of the teapot
The glutWireTeapot and glutSolidTeapot functions render a teapot of the desired size, centered at the origin. This is the famous OpenGL teapot [add reference].
None that we know of.
The glutWireCylinder and glutSolidCylinder functions draw a wireframe and solid cylinder respectively.
void glutWireCylinder ( GLdouble radius, GLdouble height, GLint slices, GLint stacks );
void glutSolidCylinder ( GLdouble radius, GLdouble height, GLint slices, GLint stacks );
radius The desired radius of the cylinder
height The desired height of the cylinder
slices The desired number of slices around the ends of the cylinder
stacks The desired number of stacks between the ends of the cylinder (the number of points, including both bases, is stacks + 1)
The glutWireCylinder and glutSolidCylinder functions render a cylinder with a base centered at the origin and in the X-Y plane and the other base on the positive Z-axis.
void glutGameModeString ( const char * string );
string The game mode configuration string.
void glutEnterGameMode ( void );
void glutLeaveGameMode ( void );
int glutGameModeGet ( GLenum info );
info The information to query, one of:
void glutIgnoreKeyRepeat ( int ignore );
void glutSetKeyRepeat ( int repeatMode);
ignore The boolean indicating if the auto repeat keystroke must be ignore or not.
repeatMode The repeat mode, one of:
void glutForceJoystickFunc ( void );
void glutReportErrors ( void );
The glutReportErrors function prints OpenGL run-time errors by calling glGetError and gluErrorString until there is no more pending errors.
While calling this function when appropriate may be convenient to isolate OpenGL errors, it may be more advised to use the -gldebug option when calling a freeglut-based program.
The following environment variables are recognized by freeglut:
Application programmers who are porting their GLUT programs to freeglut may continue to include <GL/glut.h> in their programs. Programs which use the freeglut-specific extensions to GLUT should include <GL/freeglut.h>. One possible arrangement is as follows:
#ifdef FREEGLUT #include <GL/freeglut_ext.h> #else #include <GL/glut.h> #endif
Compile-time freeglut version testing can be done as follows:
#ifdef FREEGLUT_VERSION_2_0 code specific to freeglut 2.0 or later here #endif
In future releases, FREEGLUT_VERSION_2_1, FREEGLUT_VERSION_2_2, etc will be defined. This scheme mimics OpenGL conventions.
The freeglut version can be queried at runtime by calling glutGet(GLUT_VERSION). The result will be X*10000+Y*100+Z where X is the major version, Y is the minor version and Z is the patch level.
This may be used as follows:
if (glutGet(GLUT_VERSION) < 20001) { printf("Sorry, you need freeglut version 2.0.1 or later to run this program.\n"); exit(1); }
The freeglut implementation of the following GLUT functions lack important parts or all of their original functionalities. In the worst cases, functions are implemented with function stubs so that they can “answer the mail” and GLUT-based programs can compile and link against freeglut without modification. If the reader needs some of this functions, he should contact the freeglut Programming Consortium and ask for them to be implemented. He should also be prepared to assist in the implementation.
The following GLUT functions was not documented in “The OpenGL Utility Toolkit Programming (GLUT) Interface” version 3, although man pages was available for most of them.
The following freeglut functions was not part of the original GLUT.
For some reason, GLUT is not affected by the 104-pixel minimum window width. If the user clicks on the corner of a window which is narrower than this amount, the window will immediately snap out to this width, but the application can call glutReshapeWindow and make a window narrower again.
The GLUT_LUMINANCE display mode is not implemented in freeglut.
GLUT does not include the GLUT_AUX display mode.
In GLUT, there was absolutely no way for the application programmer to have control return from the glutMainLoop function to the calling function.
The GLUT_CURSOR_FULL_CROSSHAIR cursor is not implemented in freeglut.
GLUT does not include the GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_INIT_STATE, GLUT_RENDERING_CONTEXT, GLUT_VERSION, GLUT_WINDOW_BORDER_WIDTH and GLUT_WINDOW_HEADER_HEIGHT states.
freeglut does not implement the GLUT_HAS_SPACEBALL, GLUT_HAS_TABLET, GLUT_NUM_BUTTON_BOX_BUTTONS, GLUT_NUM_SPACEBALL_BUTTONS and GLUT_NUM_TABLET_BUTTONS informations.
Nonexistent characters are rendered as asterisks. The rendering position in freeglut is apparently off from GLUT's position by a few pixels vertically and one or two pixels horizontally.
Nonexistent characters are rendered as asterisks.