#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <string.h>
static int sequence_number = 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);
if (mods&GLUT_ACTIVE_CTRL)
strcat(text,"CTRL");
if (mods&GLUT_ACTIVE_SHIFT)
+ {
if (text[0])
strcat(text,"+SHIFT");
else
strcat(text,"SHIFT");
+ }
if (mods&GLUT_ACTIVE_ALT)
+ {
if (text[0])
strcat(text,"+ALT");
else
strcat(text,"ALT");
+ }
if (!text[0])
strcat(text,"none");
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] );
static void
Warning(const char *fmt, va_list ap)
{
- printf("%6d Warning callback:\n");
+ printf("%6d Warning callback:\n",++sequence_number);
/* print warning message */
vprintf(fmt, ap);
Error(const char *fmt, va_list ap)
{
char dummy_string[STRING_LENGTH];
- printf("%6d Error callback:\n");
+ printf("%6d Error callback:\n",++sequence_number);
/* print warning message */
vprintf(fmt, ap);
+ printf("\n");
/* terminate program, after pause for input so user can see */
printf ( "Please enter something to exit: " );
}
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;
}
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 () ;
}
glutPositionFunc( Position );
glutKeyboardFunc( Key );
glutSpecialFunc( Special );
- glutVisibilityFunc( Visibility );
glutKeyboardUpFunc( KeyUp );
glutSpecialUpFunc( SpecialUp );
if (first)
glutEntryFunc ( Entry ) ;
glutCloseFunc ( Close ) ;
glutOverlayDisplayFunc ( OverlayDisplay ) ;
- glutWindowStatusFunc ( WindowStatus ) ;
glutSpaceballMotionFunc ( SpaceMotion ) ;
glutSpaceballRotateFunc ( SpaceRotation ) ;
glutSpaceballButtonFunc ( SpaceButton ) ;
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
/* callbacks, settings and menus for this window */
SetWindowCallbacks( 1 );
glutIgnoreKeyRepeat(GL_TRUE);
+ glutSetIconTitle("Icon Test - Callback Demo");
subMenuA = glutCreateMenu( MenuCallback );
glutAddMenuEntry( "Sub menu A1 (01)", 11 );
/* 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: " );