added cursor changing to resizer demo, for testing
[freeglut] / src / fg_state.c
index 208b5e2..458941f 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 ---------------------------------------------------- */
@@ -60,9 +61,6 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
 {
     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
 
-    /*
-     * XXX In chronological code add order.  (WHY in that order?)
-     */
     switch( eWhat )
     {
     case GLUT_INIT_WINDOW_X:
@@ -111,6 +109,27 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
       fgState.SampleNumber = value;
       break;
 
+    case GLUT_SKIP_STALE_MOTION_EVENTS:
+      fgState.SkipStaleMotion = value;
+      break;
+
+    case GLUT_GEOMETRY_VISUALIZE_NORMALS:
+      if( fgStructure.CurrentWindow != NULL )
+        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;
@@ -127,13 +146,18 @@ 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();
     }
 
     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
 
-    /* XXX In chronological code add order.  (WHY in that order?) */
     switch( eWhat )
     {
     /* Following values are stored in fgState and fgDisplay global structures */
@@ -198,6 +222,14 @@ int FGAPIENTRY glutGet( GLenum eWhat )
     case GLUT_MULTISAMPLE:
       return fgState.SampleNumber;
 
+    case GLUT_SKIP_STALE_MOTION_EVENTS:
+      return fgState.SkipStaleMotion;
+
+    case GLUT_GEOMETRY_VISUALIZE_NORMALS:
+      if( fgStructure.CurrentWindow == NULL )
+        return GL_FALSE;
+      return fgStructure.CurrentWindow->State.VisualizeNormals;
+
     default:
         return fgPlatformGlutGet ( eWhat );
         break;