100 likes | 241 Views
CPSC 453 Tutorial. Xin Liu Sep 24, 2013. freeglut. A variant of glut Two functions: Manage windows Interact with users Keyboard Mouse Joystick Not a necessary tool Useful for education. Initialization Functions. void glutInit ( int * argcp , char ** argv );
E N D
CPSC 453 Tutorial Xin Liu Sep 24, 2013
freeglut • A variant of glut • Two functions: • Manage windows • Interact with users • Keyboard • Mouse • Joystick • Not a necessary tool • Useful for education
Initialization Functions • void glutInit(int *argcp, char **argv); • voidglutInitWindowPosition ( int x, int y ); • void glutInitWindowSize ( int width, int height ); • void glutInitDisplayMode(unsigned int mode);
Event Processing Functions • void glutMainLoop ( void );
Window Management • intglutCreateWindow(char *name); • intglutCreateSubWindow(intwin, intx, int y, int width, int height); • void glutSetWindow(int win); • intglutGetWindow(void); • void glutDestroyWindow(int win); • void glutSetWindowTitle(char *name); • void glutPositionWindow(int x, int y); • void glutReshapeWindow(int width, int height); • void glutFullScreen(void); • void glutLeaveFullScreen ( void );
Display Functions • void glutSwapBuffers(void); • void glutPostRedisplay(void);
Window Callback Registration • void glutDisplayFunc(void (*func)(void)); • void glutReshapeFunc(void (*func)(int width, int height)); • void glutPositionFunc ( void (* callback)( int x, int y) );
Keyboard Callback Registration • void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y)); • void glutKeyboardUpFunc ( void (*func) ( unsigned char key, int x, int y ) ); • void glutSpecialFunc(void (*func)(int key, int x, int y)); • GLUT_KEY_F1 F1 function key. • GLUT_KEY_F2 F2 function key. • GLUT_KEY_F12 F12 function key. • GLUT_KEY_LEFT Left directional key. • GLUT_KEY_UP Up directional key. • GLUT_KEY_RIGHT Right directional key. • GLUT_KEY_DOWN Down directional key. • GLUT_KEY_PAGE UP Page up directional key. • GLUT_KEY_PAGE DOWN Page down directional key. • GLUT_KEY_HOME Home directional key. • GLUT_KEY_END End directional key. • GLUT_KEY_INSERT Inset directional key. • void glutSpecialUpFunc ( void (*func) ( int key, int x, int y ) );
Mouse Callback Registration • void glutMouseFunc(void (*func)(int button, int state, int x, int y)); • The button parameter is one of GLUT LEFT BUTTON, GLUT MIDDLE BUTTON, or GLUT RIGHT BUTTON. • The state parameter is either GLUT UP or GLUT DOWN • void glutMotionFunc(void (*func)(int x, int y)); • Mouse moves while one or more mouse buttons are pressed • void glutPassiveMotionFunc(void (*func)(int x, int y));
Timer Callback Registration • void glutTimerFunc(unsigned intmsecs, void (*func)(int value), value);