can now set the font used for a menu
[freeglut] / src / fg_state.c
index 5f8c08a..6a9387d 100644 (file)
@@ -44,6 +44,7 @@
 extern int fgPlatformGlutGet ( GLenum eWhat );
 extern int fgPlatformGlutDeviceGet ( GLenum eWhat );
 extern int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size);
+extern SFG_Font* fghFontByID( void* font );
 
 
 /* -- LOCAL DEFINITIONS ---------------------------------------------------- */
@@ -120,6 +121,18 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
         fgStructure.CurrentWindow->State.VisualizeNormals = value;
       break;
 
+    case GLUT_MENU_FONT:
+        {
+            void* fontID = (void*)value;
+            SFG_Font* font;
+            font = fghFontByID( fontID );
+            if (!font)
+                fgWarning("glutSetOption(GLUT_MENU_FONT,...): bitmap font 0x%08x not found. Make sure you're not passing a stroke font. Ignoring...\n",fontID);
+            else
+                fgState.MenuFont = fontID;
+        }
+      break;
+
     default:
         fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
         break;
@@ -136,6 +149,12 @@ int FGAPIENTRY glutGet( GLenum eWhat )
     case GLUT_INIT_STATE:
         return fgState.Initialised;
 
+    /* Although internally the time store is 64bits wide, the return value
+     * here still wraps every 49.7 days. Integer overflows cancel however
+     * when subtracting an initial start time, unless the total time exceeds
+     * 32-bit, so you can still work with this.
+     * XXX: a glutGet64 to return the time might be an idea...
+     */
     case GLUT_ELAPSED_TIME:
         return (int) fgElapsedTime();
     }