OpenGL Toolkits FAQ (2-2005)
I. GLUT
II. Popular GLUT Patches
III. OpenGL Game Development Frameworks
IV. OpenGL Windowing Application Frameworks
V. Upper Level OpenGL User Interface Widget Libraries
VI. More Toolkits Information and Support
VII. Font Rendering libraries for OpenGL
VIII. Scripting interfaces to OpenGL
I. GLUT
GLUT, or OpenGL Utility Toolkit was written by Mark Kilgard. The first version
of the library was released back in 1994. Since then it has been ported to pretty much
every platform that exists. It is used in thousands of demos including the demos used in
the OpenGL Red Book. The current version is 3.7. Additional releases of the library are
not anticipated. The library is very useful in prototyping OpenGL applications and games,
and in writing OpenGL demos.
For answers to common questions about GLUT functionality, make sure and read
the GLUT section of OpenGL.org's OpenGL Developer FAQ.
1) Where can I find compiled GLUT libraries, source code and docs?
a) Opengl.org's GLUT download page.
b) Nate Robins's GLUT for Windows.
c) FreeGlut - Opensource re-write of the popular GLUT library.
d) GLUT 3.7.2 API Documentation.
2) Is GLUT Open Source?
GLUT is not open source. Mark Kilgard maintains the the copyright. There are
a number of newer alternatives, including FreeGlut.
3) How do I track keyboard input using GLUT?
The best way to do this is to track the keyboard state using
an array, something like this (Win32 console example code):
// gluttest.cpp : Defines the entry point for the console application.
//
#include
#include
#include "glut.h"
#pragma comment( lib, "glut32" )
static bool keystate[256];
void glutKeyboardUpCallback( unsigned char key, int x, int y )
{
printf( "keyup=%i\n", key );
keystate[key] = false;
}
void glutKeyboardCallback( unsigned char key, int x, int y )
{
printf( "keydn=%i\n", key );
keystate[key] = true;
}
void glutDisplayCallback( void )
{
Sleep(100);
for ( int i=0; i <= 255; i++ ) { if ( keystate[i] == true ) printf( "ASCII key %i is pressed.\n", i ); } glutPostRedisplay(); } int main(int argc, char* argv[]) { glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow( "test" ); glutKeyboardFunc( glutKeyboardCallback ); glutKeyboardUpFunc( glutKeyboardUpCallback ); glutDisplayFunc( glutDisplayCallback ); glutMainLoop(); return 0; } 4) Help with glutGameMode http://www.nullterminator.net/glut.html
glutGameModeString
glutGameModeString is a useful function for setting the screen resolution,
refresh rate, and bit depth for fullscreen applications (like games). The
sole parameter is a pointer to a string which specifies the screen properties
desired.
glutGameModeString( "640x480:16@60" );
In the above example, this selects a resolution of 640x480, 16 bits per pixel
(bit depth), and 60Hz refresh rate. You can create your own game mode string
using the following sprintf statement or your own method.
char temp[64];
sprintf( temp, "%dx%d:%d@%d", width, height,
pixelDepth, refreshRate );
Think of this as a request to the GLUT system. You aren't necessarily guarenteed
the mode you requested.
glutGameModeGet
To see what you are working with, simply use the glutGameModeGet function.
The single arguement specifies what you are trying to get. Here's a list
of possible arguements.
Arguement Description
GLUT_GAME_MODE_ACTIVE Whether game mode is active.
GLUT_GAME_MODE_POSSIBLE Whether game mode is possible.
GLUT_GAME_MODE_WIDTH The game mode screen width (ex. 640 pixels).
GLUT_GAME_MODE_HEIGHT The game mode screen height (ex. 480 pixels).
GLUT_GAME_MODE_PIXEL_DEPTH The game mode pixel depth (ex. 16bits).
GLUT_GAME_MODE_REFRESH_RATE The game mode screen pixel depth (ex. 60Hz).
GLUT_GAME_MODE_DISPLAY_CHANGED Whether game mode changed the display.
To determine what mode we are dealing with, the following code snippet
should suffice for most cases.
width = glutGameModeGet( GLUT_GAME_MODE_WIDTH );
height = glutGameModeGet( GLUT_GAME_MODE_WIDTH );
pixelDepth = glutGameModeGet( GLUT_GAME_MODE_PIXEL_DEPTH );
refreshRate = glutGameModeGet( GLUT_GAME_MODE_REFRESH_RATE );
glutEnterGameMode
Instead of worrying about a bunch of calls to the Operating System to
initialize a fullscreen window and create the OpenGL interface, you
can do it in one single call to glutEnterGameMode. It's that simple.
Think of it as a replacement to your usual call of glutCreateWindow.
Then you must setup your callbacks (display, keyboard, etc) after the
call to glutEnterGameMode just like an ordinary GLUT program.
int main(int argc, char * argv[])
{
// initialize GLUT
glutInit( &argc, argv );
// set RGBA mode with double and depth buffers
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
// 640x480, 16bit pixel depth, 60Hz refresh rate
glutGameModeString( "640x480:16@60" );
// start fullscreen game mode
glutEnterGameMode();
// setup window callbacks
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
glutIdleFunc( idle );
...
// enter main loop
glutMainLoop();
return 0;
}
glutLeaveGameMode
After you are finished with the fullscreen window, you can get
rid of it with a call to glutLeaveGameMode somewhere where you
are shutting down.
II. Popular GLUT Patches
For answers to common questions about GLUT functionality, make sure and read
the GLUT section of OpenGL.org's OpenGL Developer FAQ.
1) Fixing GLUT's "X" button close window exit() bug
Rob Fletcher, at the University of York, has written a fix to the GLUT
window-close problem. He's added a callback which informs the caller
when a window is closed. The default action is to exit, so this is
backwards-compatible with existing code. But multi-window GLUT applications
can now handle window closes properly.
Editors Note:
Rob's patch adds a window close callback -
void glutWMCloseFunc( void (*func)(void) );
It also creates a re-entrant event loop that returns on exit to the calling
process. e.g.:
for(;;)
glutCheckLoop()
Rob Fletcher's GLUT Patches.
2) Creating a re-entrant glutMainloop.
Steven Baker's glutMainLoopUpdate.
Rob Fletcher's GLUT Patches.
III. OpenGL Game Development Frameworks
Game frameworks take the hassle out of OpenGL game programming by providing
an underlying support layer for the developer to rely on. Each framework has
various different features and platform support. Click on the links below for
brief summaries of each.
1) GLUT - See the GLUT section of this FAQ.
2) GLFW - An OpenGL Framework.
3) Cpw - Cross Platform Windowing for OpenGL.
4) PLIB - The Portable Games Library.
5) FreeGlut - Opensource re-write of the popular GLUT library.
6) GLT - GL C++ Toolkit.
7) Grand Unified Toolkit - a cross-platform C++ API for game development.
8) DemoGL - execution platform for multi-media based graphical effects.
9) SDL - cross-platform multimedia library adapted to OpenGL.
IV. OpenGL Windowing Application Frameworks
Application frameworks take the hassle out of Window based OpenGL
applications by providing an underlying support layer for the developer
to rely on. Each framework has various different features and platform
support. Click on the links below for brief summaries of each.
1) GLUT - See the GLUT section of this FAQ.
2) Cpw - Cross Platform Windowing for OpenGL.
3) FreeGlut - Opensource re-write of the popular GLUT library.
4) GLT - GL C++ Toolkit.
5) GLFW - An OpenGL Framework.
6) SDL - cross-platform multimedia library adapted to OpenGL.
V. Upper Level OpenGL User Interface Widget Libraries
Widget Libraries or UI Frameworks take the hassle out of displaying
common windowing controls such as drop downs, text entry, and buttons.
Each framework has various different features and platform support.
Click on the links below for brief summaries of each.
1) MUI/PUI/GLUI
a) GLUI Home Page
b) Steve Baker's MUI/PUI/GLUI Information
2) GLOW - a C++ OpenGL Widget Library.
3) FLTK - a C++ OpenGL Widget Library.
4) FOX - C++ Toolkit for developing Graphical User Interfaces easily.
5) libUFO - a C++ OpenGL Widget Library.
6) GLOWaux - a C++ OpenGL Framework for the GLOW Library.
7) Cpw - Cross Platform Windowing for OpenGL.
8) GLGooey - platform-independent, small, extensible collection of user interface components.
VI. More Toolkits Information and Support
1) Visit the www.OpenGL.org Toolkits Discussion Forum
2) Google Directory: OpenGL Add-on Libraries
3) The OpenGL Developer FAQ and TroubleShooting Guide
4) The OpenGL Game Development FAQ
VII. Font Rendering in OpenGL
A number of different libraries support various different types of font rendering
in OpenGL. Make sure and read OpenGL.org's Survey of OpenGL Font Technology.
1) GLUT - ANSI C, Simple Stroke and Bitmap Fonts.
2) glFont - ANSI C, Texture Mapped Fonts.
3) FTGL - C++, TrueType Fonts, Requires FreeType 2.0.
4) GLTT - C++, TrueType Fonts, Requires FreeType 1.0.
5) FNT - Part of PLIB, ANSI C.
6) GLF
7) Cpw - ANSI C, TrueType Fonts, Requires FreeType 2.0.
VIII. Scripting interfaces to OpenGL
A number of different scripting engines support OpenGL. Aside from interfaces
for common languages such as Python there are a number of less known scripting
languages out there that provide unique ways of programming in OpenGL.
1) SharpGL - C# wrapper for OpenGL #1
2) CFC# OpenGL Wrapper - C# wrapper for OpenGL #2
3) CsGl - CsGL implements a wrapper for the well known C-library OpenGL allowing any
.NET language make use of it.
4) LuaGL - Lua is a powerful light-weight programming language designed for extending
applications.
5) IoGL - Io is small prototype-based programming language.
________________________________________________________________________________________________________
Download the zipped source of this
FAQ
Please send additional submissions for this FAQ to the maintainer via email.