prepared callbackmaker for testing position callback

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1476 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2012-11-23 07:06:57 +00:00
parent 4f66100b51
commit a0b41213a5

View File

@ -14,45 +14,26 @@ static int sequence_number = 0 ;
int windows[2] = {0}; int windows[2] = {0};
/* define status vars showing whether given callback has been called for given window */ /* define status vars showing whether given callback has been called for given window */
#define CALLBACK_CALLED_VAR(name) int name##_called[2] = {0}; #define CALLBACK_CALLED_VAR(name) int name##_called[2] = {0};
#define CALLBACK_1_VAR(name,field) int name##_##field[2], name##_seq[2] = {-1}; #define CALLBACK_0V(name) int name##_seq[2] = {-1}; CALLBACK_CALLED_VAR(name);
#define CALLBACK_2_VARS(name,field1,field2) int name##_##field1[2], name##_##field2[2], name##_seq[2] = {-1}; #define CALLBACK_1V(name,field) int name##_##field[2] = {-1}; CALLBACK_0V(name);
#define CALLBACK_3_VARS(name,field1,field2,field3) int name##_##field1[2], name##_##field2[2], name##_##field3[2], name##_seq[2] = {-1}; #define CALLBACK_2V(name,field1,field2) int name##_##field2[2] = {-1}; CALLBACK_1V(name,field1);
#define CALLBACK_4_VARS(name,field1,field2,field3,field4) int name##_##field1[2], name##_##field2[2], name##_##field3[2], name##_##field4[2], name##_seq[2] = {-1}; #define CALLBACK_3V(name,field1,field2,field3) int name##_##field3[2] = {-1}; CALLBACK_2V(name,field1,field2);
CALLBACK_CALLED_VAR(reshape); #define CALLBACK_4V(name,field1,field2,field3,field4) int name##_##field4[2] = {-1}; CALLBACK_3V(name,field1,field2,field3);
CALLBACK_2_VARS(reshape,width,height); CALLBACK_2V(reshape,width,height);
CALLBACK_CALLED_VAR(key); CALLBACK_2V(position,top,left);
CALLBACK_3_VARS(key,key,x,y); CALLBACK_3V(key,key,x,y);
CALLBACK_CALLED_VAR(keyup); CALLBACK_3V(keyup,key,x,y);
CALLBACK_3_VARS(keyup,key,x,y); CALLBACK_3V(special,key,x,y);
CALLBACK_CALLED_VAR(special); CALLBACK_3V(specialup,key,x,y);
CALLBACK_3_VARS(special,key,x,y); CALLBACK_1V(visibility,vis);
CALLBACK_CALLED_VAR(specialup); CALLBACK_4V(joystick,a,b,c,d);
CALLBACK_3_VARS(specialup,key,x,y); CALLBACK_4V(mouse,button,updown,x,y);
CALLBACK_CALLED_VAR(visibility); CALLBACK_4V(mousewheel,number,direction,x,y);
CALLBACK_1_VAR(visibility,vis); CALLBACK_2V(motion,x,y);
CALLBACK_CALLED_VAR(joystick); CALLBACK_2V(passivemotion,x,y);
CALLBACK_4_VARS(joystick,a,b,c,d); CALLBACK_0V(entry);
CALLBACK_CALLED_VAR(mouse); CALLBACK_0V(close);
CALLBACK_4_VARS(mouse,button,updown,x,y);
CALLBACK_CALLED_VAR(mousewheel);
CALLBACK_4_VARS(mousewheel,number,direction,x,y);
CALLBACK_CALLED_VAR(motion);
CALLBACK_2_VARS(motion,x,y);
CALLBACK_CALLED_VAR(passivemotion);
CALLBACK_2_VARS(passivemotion,x,y);
CALLBACK_CALLED_VAR(entry);
CALLBACK_CALLED_VAR(close);
/*CALLBACK_CALLED_VAR(overlaydisplay);
CALLBACK_CALLED_VAR(windowstatus);
CALLBACK_CALLED_VAR(spacemotion);
CALLBACK_CALLED_VAR(spacerotation);
CALLBACK_CALLED_VAR(spacebutton);
CALLBACK_CALLED_VAR(buttonbox);
CALLBACK_CALLED_VAR(dials);
CALLBACK_CALLED_VAR(tabletmotion);
CALLBACK_CALLED_VAR(tabletbutton);
CALLBACK_CALLED_VAR(menustatus);*/
/* menudestroy is registered on each menu, not a window */ /* menudestroy is registered on each menu, not a window */
int menudestroy_called = 0 ; int menudestroy_called = 0 ;
/* menustatus and menustate are global callbacks, set for all menus at the same time */ /* menustatus and menustate are global callbacks, set for all menus at the same time */
@ -112,6 +93,11 @@ Display(void)
bitmapPrintf ( "Reshape %d: %d %d\n", reshape_seq[winIdx], reshape_width[winIdx], reshape_height[winIdx] ); bitmapPrintf ( "Reshape %d: %d %d\n", reshape_seq[winIdx], reshape_width[winIdx], reshape_height[winIdx] );
} }
if ( position_called[winIdx] )
{
bitmapPrintf ( "Position %d: %d %d\n", position_seq[winIdx], position_left[winIdx], position_top[winIdx] );
}
if ( key_called[winIdx] ) if ( key_called[winIdx] )
{ {
bitmapPrintf ( "Key %d: %d(%c) %d %d\n", key_seq[winIdx], key_key[winIdx], key_key[winIdx], key_x[winIdx], key_y[winIdx] ); bitmapPrintf ( "Key %d: %d(%c) %d %d\n", key_seq[winIdx], key_key[winIdx], key_key[winIdx], key_x[winIdx], key_y[winIdx] );
@ -216,6 +202,20 @@ Reshape(int width, int height)
glutPostRedisplay () ; glutPostRedisplay () ;
} }
static void
Position(int left, int top)
{
int winIdx;
int window = getWindowAndIdx(&winIdx);
printf ( "%6d Window %d Reshape Callback: %d %d\n",
++sequence_number, window, left, top ) ;
position_called[winIdx] = 1 ;
position_left[winIdx] = left ;
position_top[winIdx] = top ;
position_seq[winIdx] = sequence_number ;
glutPostRedisplay () ;
}
static void static void
Key(unsigned char key, int x, int y) Key(unsigned char key, int x, int y)
{ {
@ -539,6 +539,7 @@ main(int argc, char *argv[])
/* callbacks and settings specific to this window */ /* callbacks and settings specific to this window */
glutDisplayFunc( Display ); glutDisplayFunc( Display );
glutReshapeFunc( Reshape ); glutReshapeFunc( Reshape );
glutPositionFunc( Position );
glutKeyboardFunc( Key ); glutKeyboardFunc( Key );
glutSpecialFunc( Special ); glutSpecialFunc( Special );
glutVisibilityFunc( Visibility ); glutVisibilityFunc( Visibility );
@ -597,6 +598,7 @@ main(int argc, char *argv[])
/* callbacks and settings specific to this window */ /* callbacks and settings specific to this window */
glutDisplayFunc( Display ); glutDisplayFunc( Display );
glutReshapeFunc( Reshape ); glutReshapeFunc( Reshape );
glutPositionFunc( Position );
glutKeyboardFunc( Key ); glutKeyboardFunc( Key );
glutSpecialFunc( Special ); glutSpecialFunc( Special );
glutVisibilityFunc( Visibility ); glutVisibilityFunc( Visibility );