some cleanup
[freeglut] / progs / demos / CallbackMaker / CallbackMaker.c
index 0d4dbb7..0cee827 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <string.h>
 
 static int sequence_number = 0 ;
 
@@ -80,15 +81,19 @@ Mod2Text(int mods, char *text)
     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");
@@ -213,7 +218,7 @@ Display(void)
 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);
@@ -223,7 +228,7 @@ static void
 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);
@@ -635,6 +640,8 @@ main(int argc, char *argv[])
    * what we demonstrate here.
    */
   glutSetKeyRepeat(GLUT_KEY_REPEAT_ON);
+  /* global setting: default font for any menus created after this call (we call it again below to demo) */
+  glutSetOption(GLUT_MENU_FONT,(int)GLUT_BITMAP_HELVETICA_12);
 
   /* Set other global callback (global as in not associated with any specific menu or window) */
   glutIdleFunc ( Idle );
@@ -659,6 +666,9 @@ main(int argc, char *argv[])
   glutAddMenuEntry( "Sub menu A3 (03)", 13 );
   glutMenuDestroyFunc ( MenuDestroy );  /* callback specific to this menu */
 
+  /* change font for any menus created after this call */
+  glutSetOption(GLUT_MENU_FONT,(int)GLUT_BITMAP_8_BY_13);
+
   subMenuB = glutCreateMenu( MenuCallback );
   glutAddMenuEntry( "Sub menu B1 (04)", 14 );
   glutAddMenuEntry( "Sub menu B2 (05)", 15 );
@@ -677,6 +687,8 @@ main(int argc, char *argv[])
   glutMenuDestroyFunc ( MenuDestroy );  /* callback specific to this menu */
 
   glutAttachMenu( GLUT_LEFT_BUTTON );
+  /* You can also change the font of the current menu: */
+  glutSetMenuFont(GLUT_BITMAP_TIMES_ROMAN_10);
 
 
   /* Position second window right next to the first */