3 * Program to invoke all the callbacks that "freeglut" supports
7 #include <GL/freeglut.h>
11 static int sequence_number = 0 ;
16 int window = glutGetWindow () ;
17 glClear( GL_COLOR_BUFFER_BIT );
19 printf ( "%6d Window %d Display Callback\n",
20 ++sequence_number, window ) ;
25 Reshape(int width, int height)
27 int window = glutGetWindow () ;
28 printf ( "%6d Window %d Reshape Callback: %d %d\n",
29 ++sequence_number, window, width, height ) ;
33 Key(unsigned char key, int x, int y)
35 int window = glutGetWindow () ;
36 printf ( "%6d Window %d Keyboard Callback: %d %d %d\n",
37 ++sequence_number, window, key, x, y ) ;
41 Special(int key, int x, int y)
43 int window = glutGetWindow () ;
44 printf ( "%6d Window %d Special Key Callback: %d %d %d\n",
45 ++sequence_number, window, key, x, y ) ;
51 int window = glutGetWindow () ;
52 printf ( "%6d Window %d Visibility Callback: %d\n",
53 ++sequence_number, window, vis ) ;
57 KeyUp(unsigned char key, int x, int y)
59 int window = glutGetWindow () ;
60 printf ( "%6d Window %d Key Release Callback: %d %d %d\n",
61 ++sequence_number, window, key, x, y ) ;
65 SpecialUp(int key, int x, int y)
67 int window = glutGetWindow () ;
68 printf ( "%6d Window %d Special Key Release Callback: %d %d %d\n",
69 ++sequence_number, window, key, x, y ) ;
73 Joystick( unsigned int a, int b, int c, int d)
75 int window = glutGetWindow () ;
76 printf ( "%6d Window %d Joystick Callback: %d %d %d %d\n",
77 ++sequence_number, window, a, b, c, d ) ;
81 Mouse(int button, int updown, int x, int y)
83 int window = glutGetWindow () ;
84 printf ( "%6d Window %d Mouse Click Callback: %d %d %d %d\n",
85 ++sequence_number, window, button, updown, x, y ) ;
89 MouseWheel(int wheel_number, int direction, int x, int y)
91 int window = glutGetWindow () ;
92 printf ( "%6d Window %d Mouse Wheel Callback: %d %d %d %d\n",
93 ++sequence_number, window, wheel_number, direction, x, y ) ;
99 int window = glutGetWindow () ;
100 printf ( "%6d Window %d Mouse Motion Callback: %d %d\n",
101 ++sequence_number, window, x, y ) ;
105 PassiveMotion(int x, int y)
107 int window = glutGetWindow () ;
108 printf ( "%6d Window %d Mouse Passive Motion Callback: %d %d\n",
109 ++sequence_number, window, x, y ) ;
115 int window = glutGetWindow () ;
116 printf ( "%6d Window %d Entry Callback: %d\n",
117 ++sequence_number, window, state ) ;
123 int window = glutGetWindow () ;
124 printf ( "%6d Window %d Close Callback\n",
125 ++sequence_number, window ) ;
131 main(int argc, char *argv[])
133 int freeglut_window, aux_window ;
135 glutInitWindowSize(500, 250);
136 glutInitWindowPosition ( 140, 140 );
137 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
138 glutInit(&argc, argv);
140 freeglut_window = glutCreateWindow( "Callback Demo" );
141 printf ( "Creating window %d as 'Callback Demo'\n", freeglut_window ) ;
143 glClearColor(1.0, 1.0, 1.0, 1.0);
145 glutDisplayFunc( Display );
146 glutReshapeFunc( Reshape );
147 glutKeyboardFunc( Key );
148 glutSpecialFunc( Special );
149 glutVisibilityFunc( Visibility );
150 glutKeyboardUpFunc( KeyUp );
151 glutSpecialUpFunc( SpecialUp );
152 glutJoystickFunc( Joystick, 10 );
153 glutMouseFunc ( Mouse ) ;
154 glutMouseWheelFunc ( MouseWheel ) ;
155 glutMotionFunc ( Motion ) ;
156 glutPassiveMotionFunc ( PassiveMotion ) ;
157 glutEntryFunc ( Entry ) ;
158 glutCloseFunc ( Close ) ;
160 aux_window = glutCreateWindow( "Second Window" );
161 printf ( "Creating window %d as 'Second Window'\n", aux_window ) ;
163 glClearColor(1.0, 1.0, 1.0, 1.0);
165 glutDisplayFunc( Display );
166 glutReshapeFunc( Reshape );
167 glutKeyboardFunc( Key );
168 glutSpecialFunc( Special );
169 glutVisibilityFunc( Visibility );
170 glutKeyboardUpFunc( KeyUp );
171 glutSpecialUpFunc( SpecialUp );
172 // glutJoystickFunc( Joystick, 10 );
173 glutMouseFunc ( Mouse ) ;
174 glutMouseWheelFunc ( MouseWheel ) ;
175 glutMotionFunc ( Motion ) ;
176 glutPassiveMotionFunc ( PassiveMotion ) ;
177 glutEntryFunc ( Entry ) ;
178 glutCloseFunc ( Close ) ;
182 printf ( "Back from the 'freeglut' main loop\n" ) ;
184 return 0; /* ANSI C requires main to return int. */