OpenGL utility toolkit

GLUT ( Open' GL U' tility T oolkit ) is a utility library of which the royalties are held by Mark J. Kilgard, offering a set of routines for the management of the windows OpenGL and the interactions with the operating system (management keyboard, mouse, etc) independently of this one and of the manager of windows. It is primarily used for the creation of demonstration programs.

Presentation

Library GLUT was written by Mark J. Kilgard, author of OpenGL Programming for the X Window System and of The CG Tutorial: The Definitive Guides to Programmable Real-Time Graphics , when he worked for Silicon Graphics.

GLUT was written with an aim of producing portable code between different the operating systems and teaching end. Its simplicity makes it possible not to be concerned with a system part, relatively complex, and to concentrate on the bottom of the OpenGL program itself. The creation of a program with GLUT takes only some lines of code. In addition, it respects conventions and the syntax of OpenGL; the names of function begin with the prefix “glut” and the macros by “GLUT” (OpenGL uses the prefixes “gl” and “GL”).

In addition to the encapsulation of the basic functions of a manager of window, GLUT proposes routines for the drawing of some simple objects with three dimensions like the sphere, the cube, the cone, the torus or famous the Théière of Newell.

library GLUT is not from now on any more under development and stopped with version 3.7 in May 1998. The libraries Open Source Freeglut and OpenGLUT (which derives from freeglut) replace GLUT today. They réimplémentent the API GLUT and bring some evolutions there. The creation of these alternate libraries is due to the blur concerning the license of GLUT, which according to some would not allow the redistribution of modified code.

Example

Here a sample program using GLUT and OpenGL (compatible with freeglut and OpenGLUT). The result is a simple window with a multicoloured triangle in the center.

  1. include

void reshape (int W, int H) { yew (H == 0) H = 1;

glViewport (0, 0, (GLsizei) W, (GLsizei) H);

glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (45.0, (GLfloat) W (GLfloat) H, 0.1,1000.0);

glMatrixMode (GL_MODELVIEW); glLoadIdentity ();

glutPostRedisplay (); }

void display () { /* erases the plugs of color and depth; re-initialized the matrix of modeling-visualization * glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity ();

/* draws a triangle whose colors red, green and blue are allotted to the three tops * glTranslatef (0.0, 0.0,-5.0); glBegin (GL_TRIANGLES); glColor3f (1.0f, 0.0f, 0.0f); glVertex3f (- 1.0f, -1.0f, 0.0f);

glColor3f (0.0f, 1.0f, 0.0f); glVertex3f (1.0f, -1.0f, 0.0f);

glColor3f (0.0f, 0.0f, 1.0f); glVertex3f (0.0f, 1.0f, 0.0f); glEnd (); }

int hand (int argc, tank *argv) { /* initialization of GLUT * glutInit (&argc, argv);

/* creation of a window OpenGL RVBA with in simple buffer memory with a plug of depth * glutInitDisplayMode (GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH); glutInitWindowSize (350, 300); glutCreateWindow (" A OpenGL window with GLUT");

/* initialization of the functions callback called by glut for respectively the redimensioning of the window and returned scene * glutReshapeFunc (reshape); glutDisplayFunc (display);

/* enters the loop of events * glutMainLoop (); return 0; }

Random links:Marcel Granet | Radio operator L | Route main road 53bis | Ehud | The Revenge on the clown | 80_AVANT_JÉSUS_CHRIST