diff --git a/.gitattributes b/.gitattributes index 5d91165..2bfe4b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -34,6 +34,8 @@ freeglut/freeglut/include/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/install-sh svn_keywords=Author+Date+Id+Revision freeglut/freeglut/mkinstalldirs svn_keywords=Author+Date+Id+Revision freeglut/freeglut/progs/Makefile.am svn_keywords=Author+Date+Id+Revision +freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c svn_keywords=Author+Date+Id+Revision +freeglut/freeglut/progs/demos/CallbackMaker/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/progs/demos/Fractals/Fractals.dsp svn_keywords=Author+Date+Id+Revision freeglut/freeglut/progs/demos/Fractals/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/progs/demos/Fractals/fractals.c svn_keywords=Author+Date+Id+Revision diff --git a/freeglut/freeglut/configure.in b/freeglut/freeglut/configure.in index b9e8577..f23725e 100644 --- a/freeglut/freeglut/configure.in +++ b/freeglut/freeglut/configure.in @@ -55,6 +55,7 @@ AC_OUTPUT(\ doc/Makefile \ progs/Makefile \ progs/demos/Makefile \ + progs/demos/CallbackMaker/Makefile \ progs/demos/Fractals/Makefile \ progs/demos/Fractals_random/Makefile \ progs/demos/Lorenz/Makefile \ diff --git a/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c b/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c new file mode 100644 index 0000000..3aede72 --- /dev/null +++ b/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c @@ -0,0 +1,185 @@ +/* CallbackMaker.c */ +/* + * Program to invoke all the callbacks that "freeglut" supports + */ + + +#include +#include +#include + +static int sequence_number = 0 ; + +static void +Display(void) +{ + int window = glutGetWindow () ; + glClear( GL_COLOR_BUFFER_BIT ); + + printf ( "%6d Window %d Display Callback\n", + ++sequence_number, window ) ; + glutSwapBuffers(); +} + +static void +Reshape(int width, int height) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Reshape Callback: %d %d\n", + ++sequence_number, window, width, height ) ; +} + +static void +Key(unsigned char key, int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Keyboard Callback: %d %d %d\n", + ++sequence_number, window, key, x, y ) ; +} + +static void +Special(int key, int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Special Key Callback: %d %d %d\n", + ++sequence_number, window, key, x, y ) ; +} + +static void +Visibility(int vis) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Visibility Callback: %d\n", + ++sequence_number, window, vis ) ; +} + +static void +KeyUp(unsigned char key, int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Key Release Callback: %d %d %d\n", + ++sequence_number, window, key, x, y ) ; +} + +static void +SpecialUp(int key, int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Special Key Release Callback: %d %d %d\n", + ++sequence_number, window, key, x, y ) ; +} + +static void +Joystick( unsigned int a, int b, int c, int d) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Joystick Callback: %d %d %d %d\n", + ++sequence_number, window, a, b, c, d ) ; +} + +static void +Mouse(int button, int updown, int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Mouse Click Callback: %d %d %d %d\n", + ++sequence_number, window, button, updown, x, y ) ; +} + +static void +MouseWheel(int wheel_number, int direction, int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Mouse Wheel Callback: %d %d %d %d\n", + ++sequence_number, window, wheel_number, direction, x, y ) ; +} + +static void +Motion(int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Mouse Motion Callback: %d %d\n", + ++sequence_number, window, x, y ) ; +} + +static void +PassiveMotion(int x, int y) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Mouse Passive Motion Callback: %d %d\n", + ++sequence_number, window, x, y ) ; +} + +static void +Entry(int state) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Entry Callback: %d\n", + ++sequence_number, window, state ) ; +} + +static void +Close(void) +{ + int window = glutGetWindow () ; + printf ( "%6d Window %d Close Callback\n", + ++sequence_number, window ) ; +} + + + +int +main(int argc, char *argv[]) +{ + int freeglut_window, aux_window ; + + glutInitWindowSize(500, 250); + glutInitWindowPosition ( 140, 140 ); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE ); + glutInit(&argc, argv); + + freeglut_window = glutCreateWindow( "Callback Demo" ); + printf ( "Creating window %d as 'Callback Demo'\n", freeglut_window ) ; + + glClearColor(1.0, 1.0, 1.0, 1.0); + + glutDisplayFunc( Display ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( Special ); + glutVisibilityFunc( Visibility ); + glutKeyboardUpFunc( KeyUp ); + glutSpecialUpFunc( SpecialUp ); +// glutJoystickFunc( Joystick, 10 ); + glutMouseFunc ( Mouse ) ; + glutMouseWheelFunc ( MouseWheel ) ; + glutMotionFunc ( Motion ) ; + glutPassiveMotionFunc ( PassiveMotion ) ; + glutEntryFunc ( Entry ) ; + glutCloseFunc ( Close ) ; + + aux_window = glutCreateWindow( "Second Window" ); + printf ( "Creating window %d as 'Second Window'\n", aux_window ) ; + + glClearColor(1.0, 1.0, 1.0, 1.0); + + glutDisplayFunc( Display ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( Special ); + glutVisibilityFunc( Visibility ); + glutKeyboardUpFunc( KeyUp ); + glutSpecialUpFunc( SpecialUp ); +// glutJoystickFunc( Joystick, 10 ); + glutMouseFunc ( Mouse ) ; + glutMouseWheelFunc ( MouseWheel ) ; + glutMotionFunc ( Motion ) ; + glutPassiveMotionFunc ( PassiveMotion ) ; + glutEntryFunc ( Entry ) ; + glutCloseFunc ( Close ) ; + + glutMainLoop(); + + printf ( "Back from the 'freeglut' main loop\n" ) ; + + return 0; /* ANSI C requires main to return int. */ +} diff --git a/freeglut/freeglut/progs/demos/CallbackMaker/Makefile.am b/freeglut/freeglut/progs/demos/CallbackMaker/Makefile.am new file mode 100644 index 0000000..a516e0d --- /dev/null +++ b/freeglut/freeglut/progs/demos/CallbackMaker/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = CallbackMaker.c +noinst_PROGRAMS = CallbackMaker +CallbackMaker_SOURCES = CallbackMaker.c +CallbackMaker_LDFLAGS = -export-dynamic ../../../src/lib@LIBRARY@.la +CallbackMaker_CFLAGS = -I$(top_srcdir)/include $(X_CFLAGS) diff --git a/freeglut/freeglut/progs/demos/Fractals_random/fractals_random.c b/freeglut/freeglut/progs/demos/Fractals_random/fractals_random.c index 9c4575f..f0ea3e0 100644 --- a/freeglut/freeglut/progs/demos/Fractals_random/fractals_random.c +++ b/freeglut/freeglut/progs/demos/Fractals_random/fractals_random.c @@ -63,12 +63,9 @@ static void draw_level ( int num, double m00, double m01, double m10, double m11 for ( i = 0; i < 10; i++ ) { - int random = rand( ); - double new_x; - double new_y; - random = (((random >> 10)) & 2) + (((random >> 20) ) & 1); - new_x = affine[random].a00 * current_x + affine[random].a01 * current_y + affine[random].b0 ; - new_y = affine[random].a10 * current_x + affine[random].a11 * current_y + affine[random].b1 ; + int random = ( rand( ) >> 10 ) % num_trans; + double new_x = affine[random].a00 * current_x + affine[random].a01 * current_y + affine[random].b0 ; + double new_y = affine[random].a10 * current_x + affine[random].a11 * current_y + affine[random].b1 ; glVertex2d ( new_x, new_y ) ; current_x = new_x ; diff --git a/freeglut/freeglut/progs/demos/Makefile.am b/freeglut/freeglut/progs/demos/Makefile.am index 6fc9380..3a501d4 100644 --- a/freeglut/freeglut/progs/demos/Makefile.am +++ b/freeglut/freeglut/progs/demos/Makefile.am @@ -1,2 +1,2 @@ EXTRA_DIST = demos.dsw -SUBDIRS = Fractals Fractals_random Lorenz One +SUBDIRS = CallbackMaker Fractals Fractals_random Lorenz One