An open source, cross-platform, OpenGL tutor.

home screenshots documentation download

contact

home > documentation > project implementation with glut


Project Implementation With GLUT

With the aid of GLUT (GL Utility Toolkit), projects that have been created in Glitch can easily be implemented as "stand-alone" executable programs. This section contains a template for doing this.

Steps:

1.

Open a new terminal session.

 

2.

Launch your favorite editor, such as vim or gedit.

 

3.

Copy the following code, making substations where necessary.

/* Linux:    #include <GL/glut.h>
 * Mac OS X: #include <GLUT/glut.h>
 */
#include <GL/glut.h>


[INSERT THE VARIABLES FROM THE VARIABLES SECTION HERE]


void init( void )
{
    glClearColor( 0.0, 0.0, 0.0, 1.0 );
    glColor3f( 1.0, 1.0, 1.0 );

    
[INSERT THE COMMANDS FROM THE INITIALIZATION SECTION HERE]
}

void display( void )
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    
[INSERT THE COMMANDS FROM THE DISPLAY SECTION HERE]

    glFlush();
}

int main( int argc, char** argv )
{
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_SINGLE | GLUT_RGBA );
    glutInitWindowSize( 500, 500 );
    glutCreateWindow( argv[0] );
    glutDisplayFunc( display );

    init();

    glutMainLoop();

    return 0;
}

 

4.

Save the file (e.g. test.c) and exit.

 

5.

Compile the file using your favorite C compiler. Examples:

Linux:
gcc -o test test.c -lglut -lGL -lGLU -lXmu -lX11 -lXi -lXext -L/usr/X11R6/lib

Mac OS X:
cc -o test test.c -framework OpenGL -framework GLUT -framework Foundation

 

6.

If your program compiled successfully, then you may now execute it:

./test



Last Updated: March 4, 2004