X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2FCallbackMaker%2FCallbackMaker.c;h=43c31baccfb30130f13f2f3040696095084e2303;hb=a7362e5d688d2d2873d6bab49b86302aa588f1bf;hp=125248250dac373756df7a7673430b0bdf777512;hpb=cc8230fde8220aeab13bbc2457cb32c0fcc19d5e;p=freeglut diff --git a/progs/demos/CallbackMaker/CallbackMaker.c b/progs/demos/CallbackMaker/CallbackMaker.c index 1252482..43c31ba 100644 --- a/progs/demos/CallbackMaker/CallbackMaker.c +++ b/progs/demos/CallbackMaker/CallbackMaker.c @@ -25,6 +25,7 @@ int windows[CALLBACKMAKER_N_WINDOWS] = {0}; CALLBACK_2V(reshape,width,height); CALLBACK_2V(position,top,left); CALLBACK_1V(visibility,vis); +CALLBACK_1V(windowStatus,state); CALLBACK_4V(key,key,x,y,mod); CALLBACK_4V(keyup,key,x,y,mod); CALLBACK_4V(special,key,x,y,mod); @@ -122,6 +123,11 @@ Display(void) bitmapPrintf ( "Visibility %d: %d\n", visibility_seq[winIdx], visibility_vis[winIdx] ); } + if ( windowStatus_called[winIdx] ) + { + bitmapPrintf ( "WindowStatus %d: %d\n", windowStatus_seq[winIdx], windowStatus_state[winIdx] ); + } + if ( reshape_called[winIdx] ) { bitmapPrintf ( "Reshape %d: %d %d\n", reshape_seq[winIdx], reshape_width[winIdx], reshape_height[winIdx] ); @@ -233,19 +239,6 @@ Error(const char *fmt, va_list ap) } static void -Visibility(int vis) -{ - int winIdx; - int window = getWindowAndIdx(&winIdx); - printf ( "%6d Window %d Visibility Callback: %d\n", - ++sequence_number, window, vis ) ; - visibility_called[winIdx] = 1 ; - visibility_vis[winIdx] = vis ; - visibility_seq[winIdx] = sequence_number ; - glutPostRedisplay () ; -} - -static void Reshape(int width, int height) { int winIdx; @@ -449,11 +442,28 @@ OverlayDisplay(void) } static void +Visibility(int vis) +{ + int winIdx; + int window = getWindowAndIdx(&winIdx); + printf ( "%6d Window %d Visibility Callback: %d\n", + ++sequence_number, window, vis ) ; + visibility_called[winIdx] = 1 ; + visibility_vis[winIdx] = vis ; + visibility_seq[winIdx] = sequence_number ; + glutPostRedisplay () ; +} + +static void WindowStatus(int state) { - int window = getWindowAndIdx(NULL); + int winIdx; + int window = getWindowAndIdx(&winIdx); printf ( "%6d Window %d WindowStatus Callback: %d\n", ++sequence_number, window, state ) ; + windowStatus_called[winIdx] = 1 ; + windowStatus_state[winIdx] = state ; + windowStatus_seq[winIdx] = sequence_number ; glutPostRedisplay () ; } @@ -576,7 +586,6 @@ static void SetWindowCallbacks( int first ) glutPositionFunc( Position ); glutKeyboardFunc( Key ); glutSpecialFunc( Special ); - glutVisibilityFunc( Visibility ); glutKeyboardUpFunc( KeyUp ); glutSpecialUpFunc( SpecialUp ); if (first) @@ -588,7 +597,6 @@ static void SetWindowCallbacks( int first ) glutEntryFunc ( Entry ) ; glutCloseFunc ( Close ) ; glutOverlayDisplayFunc ( OverlayDisplay ) ; - glutWindowStatusFunc ( WindowStatus ) ; glutSpaceballMotionFunc ( SpaceMotion ) ; glutSpaceballRotateFunc ( SpaceRotation ) ; glutSpaceballButtonFunc ( SpaceButton ) ; @@ -596,6 +604,11 @@ static void SetWindowCallbacks( int first ) glutDialsFunc ( Dials ) ; glutTabletMotionFunc ( TabletMotion ) ; glutTabletButtonFunc ( TabletButton ) ; + /* glutVisibilityFunc is deprecated in favor of glutWindowStatusFunc, which provides more detail. + * Setting one of these overwrites the other (see docs). + */ + glutVisibilityFunc ( Visibility ); /* This will thus never be called, as glutWindowStatusFunc is set afterwards */ + glutWindowStatusFunc ( WindowStatus ) ; } int @@ -686,8 +699,9 @@ main(int argc, char *argv[]) glClearColor(0.7f, 0.7f, 0.7f, 1.0); - /* callbacks and menus for this window */ + /* callbacks, settings and menus for this window */ SetWindowCallbacks( 0 ); + glutSetCursor(GLUT_CURSOR_CROSSHAIR); /* Cursors are per window */ glutSetMenu(subMenuA); glutAttachMenu( GLUT_RIGHT_BUTTON ); @@ -701,6 +715,8 @@ main(int argc, char *argv[]) /* callbacks and menus for this window */ SetWindowCallbacks( 0 ); + glutSetCursor(GLUT_CURSOR_INHERIT); /* Inherit cursor look from parent (this is default on window creation) - comment the below to see in action */ + glutSetCursor(GLUT_CURSOR_CYCLE); printf ( "Please enter something to continue: " );