OpenGL Utility Toolkit
Encyclopedia
The OpenGL Utility Toolkit (GLUT) is a library of utilities for OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

 programs, which primarily perform system-level I/O
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 with the host operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

. Functions performed include window definition, window control, and monitoring of keyboard
Computer keyboard
In computing, a keyboard is a typewriter-style keyboard, which uses an arrangement of buttons or keys, to act as mechanical levers or electronic switches...

 and mouse input. Routines for drawing a number of geometric primitives (both in solid and wireframe mode) are also provided, including cubes, sphere
Sphere
A sphere is a perfectly round geometrical object in three-dimensional space, such as the shape of a round ball. Like a circle in two dimensions, a perfect sphere is completely symmetrical around its center, with all points on the surface lying the same distance r from the center point...

s, and the Utah teapot
Utah teapot
The Utah teapot or Newell teapot is a 3D computer model which has become a standard reference object in the computer graphics community. It is a mathematical model of an ordinary teapot of fairly simple shape, which appears solid, cylindrical and partially convex...

. GLUT also has some limited support for creating pop-up menus.

GLUT was written by Mark J. Kilgard
Mark Kilgard
Mark J. Kilgard is a graphics software engineer working at Nvidia.Prior to joining Nvidia, Mark Kilgard worked at Compaq and Silicon Graphics. While at Silicon Graphics, he authored the OpenGL Utility Toolkit, better known as GLUT, to make it easy to write OpenGL-based 3D examples and demos. The...

, author of OpenGL Programming for the X Window System and The Cg Tutorial: The Definitive Guide to Programmable Real-Time Graphics, while he was working for Silicon Graphics
Silicon Graphics
Silicon Graphics, Inc. was a manufacturer of high-performance computing solutions, including computer hardware and software, founded in 1981 by Jim Clark...

 Inc.

The two aims of GLUT are to allow the creation of rather portable code between operating systems (GLUT is cross-platform
Cross-platform
In computing, cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts that are implemented and inter-operate on multiple computer platforms...

) and to make learning OpenGL easier. Getting started with OpenGL programming while using GLUT often takes only a few lines of code and does not require knowledge of operating system–specific windowing APIs
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

.

All GLUT functions start with the glut prefix (for example, glutPostRedisplay marks the current window as needing to be redrawn).

Implementations

The original GLUT library by Mark Kilgard supports the X Window System
X Window System
The X window system is a computer software system and network protocol that provides a basis for graphical user interfaces and rich input device capability for networked computers...

 (GLX
GLX
GLX provides the interface connecting OpenGL and the X Window System: it enables programs wishing to use OpenGL to do so within a window provided by the X Window System.-History:...

) and was ported to Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 (WGL) by Nate Robins. Additionally, Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 ships with a GLUT framework that supports its own NSGL/CGL
Core OpenGL
Core OpenGL, or CGL, is Apple Inc.'s Macintosh Quartz windowing system interface to the Mac OS X implementation of the OpenGL specification...

.

Kilgard's GLUT library is no longer maintained, and its license did not permit the redistribution of modified versions of the library. This spurred the need for free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 or open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 reimplementations of the API from scratch. The first such library was freeglut
Freeglut
freeglut is an open source alternative to the OpenGL Utility Toolkit library. GLUT allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions...

, which aims to be a reasonably close reproduction, though introducing a small number of new functions to deal with GLUT's limitations. OpenGLUT, a fork of freeglut, adds a number of new features to the original API, but work on it ceased in May 2005.

Limitations

Some of GLUT's original design decisions made it hard for programmers to perform desired tasks. This led many to create non-canon patches and extensions to GLUT.http://www.mathies.com/glfaq/GLToolkitFAQ.html#II Some free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 or open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 reimplementations also include fixes.

Some of the more notable limitations of the original GLUT library include:
  • The library requires programmers to call glutMainLoop, a function which never returns. This makes it hard for programmers to integrate GLUT into a program or library which wishes to have control of its own event loop. A common patch to fix this is to introduce a new function, called glutCheckLoop (Mac OS X) or glutMainLoopEvent (freeglut/OpenGLUT), which runs only a single iteration of the GLUT event loop. Another common workaround is to run GLUT's event loop in a separate thread, although this may vary by operating system, and also may introduce synchronization
    Synchronization (computer science)
    In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. Process synchronization refers to the idea that multiple processes are to join up or handshake at a certain point, so as to reach an agreement or...

     issues or other problems: for example, the Mac OS X GLUT implementation requires that glutMainLoop be run in the main thread.
  • The fact that glutMainLoop never returns also means that a GLUT program cannot exit the event loop. freeglut
    Freeglut
    freeglut is an open source alternative to the OpenGL Utility Toolkit library. GLUT allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions...

     fixes this by introducing a new function, glutLeaveMainLoop.
  • The library terminates the process when the window is closed; for some applications this may not be desired. Thus, many implementations include an extra callback, such as glutWMCloseFunc.


Since it is no longer maintained (essentially replaced by the open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 freeglut
Freeglut
freeglut is an open source alternative to the OpenGL Utility Toolkit library. GLUT allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions...

) the above design issues are still not resolved in the original GLUT.

See also

  • OpenGL Utility Library (GLU)
  • OpenGL User Interface Library (GLUI)
  • freeglut
    Freeglut
    freeglut is an open source alternative to the OpenGL Utility Toolkit library. GLUT allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions...

  • Simple DirectMedia Layer
    Simple DirectMedia Layer
    Simple DirectMedia Layer is a cross-platform, free and open source multimedia library written in C that presents a simple interface to various platforms' graphics, sound, and input devices....

     (SDL)
  • libpolo
    Libpolo
    libpolo is an open source graphics, sound and network library written in C language, and designed for educational environments.It is aimed towards students learning the C and C++ language, and is very suitable for high school and first-year university courses....


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK