3 * A skeleton/template GLUT program
5 * Written by Brian Paul and in the public domain.
10 * Revision 1.1 2001/08/21 14:25:31 brianp
11 * simple multi-window GLUT test prog
13 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
16 * Revision 1.2 1998/11/07 14:20:14 brianp
17 * added simple rotation, animation of cube
19 * Revision 1.1 1998/11/07 14:14:37 brianp
32 static GLint Window
[2];
34 static GLfloat Xrot
= 0, Yrot
= 0, Zrot
= 0;
35 static GLboolean Anim
= GL_TRUE
;
38 static void Idle( void )
44 glutSetWindow(Window
[0]);
46 glutSetWindow(Window
[1]);
51 static void Display0( void )
53 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
55 glEnable(GL_LIGHTING
);
57 glEnable(GL_DEPTH_TEST
);
60 glRotatef(Xrot
, 1, 0, 0);
61 glRotatef(Yrot
, 0, 1, 0);
62 glRotatef(Zrot
, 0, 0, 1);
73 static void Display1( void )
75 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
78 glRotatef(Xrot
, 1, 0, 0);
79 glRotatef(Yrot
, 0, 1, 0);
80 glRotatef(Zrot
, 0, 0, 1);
82 glShadeModel(GL_FLAT
);
84 glBegin(GL_TRIANGLE_STRIP
);
100 static void Reshape( int width
, int height
)
102 glViewport( 0, 0, width
, height
);
103 glMatrixMode( GL_PROJECTION
);
105 glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
106 glMatrixMode( GL_MODELVIEW
);
108 glTranslatef( 0.0, 0.0, -15.0 );
112 static void Key( unsigned char key
, int x
, int y
)
114 const GLfloat step
= 3.0;
141 int main( int argc
, char *argv
[] )
143 glutInit( &argc
, argv
);
145 glutInitWindowPosition( 0, 0 );
146 glutInitWindowSize( 400, 400 );
147 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
);
148 Window
[0] = glutCreateWindow(argv
[0]);
150 glutReshapeFunc( Reshape
);
151 glutKeyboardFunc( Key
);
152 glutDisplayFunc( Display0
);
154 printf("GL_RENDERER[0] = %s\n", (char *) glGetString(GL_RENDERER
));
156 glutInitWindowPosition( 500, 0 );
157 glutInitWindowSize( 400, 400 );
158 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
);
159 Window
[1] = glutCreateWindow(argv
[0]);
161 glutReshapeFunc( Reshape
);
162 glutKeyboardFunc( Key
);
163 glutDisplayFunc( Display1
);
165 printf("GL_RENDERER[1] = %s\n", (char *) glGetString(GL_RENDERER
));