Make Android work again - adapt to recent changes and fix use of GL-nonES function
[freeglut] / src / android / fg_main_android.c
index ce3f585..41a1d3f 100644 (file)
@@ -330,7 +330,6 @@ void handle_cmd(struct android_app* app, int32_t cmd) {
     /* The window is being shown, get it ready. */\r
     LOGI("handle_cmd: APP_CMD_INIT_WINDOW %p", app->window);\r
     fgDisplay.pDisplay.single_native_window = app->window;\r
-    window->State.WorkMask |= GLUT_INIT_WORK;\r
     /* start|resume: glPlatformOpenWindow was waiting for Handle to be\r
        defined and will now continue processing */\r
     break;\r
@@ -415,7 +414,7 @@ void fgPlatformProcessSingleEvent ( void )
   if (window != NULL && window->Window.Handle != NULL) {\r
     int32_t width = ANativeWindow_getWidth(window->Window.Handle);\r
     int32_t height = ANativeWindow_getHeight(window->Window.Handle);\r
-    fghOnReshapeNotify(width,height);\r
+    fghOnReshapeNotify(window,width,height,GL_FALSE);\r
   }\r
 \r
   /* Read pending event. */\r
@@ -437,7 +436,7 @@ void fgPlatformProcessSingleEvent ( void )
   /* If we're not in RESUME state, Android paused us, so wait */\r
   struct android_app* app = fgDisplay.pDisplay.app;\r
   if (app->destroyRequested != 1 && app->activityState != APP_CMD_RESUME) {\r
-      INVOKE_WCB(*window, Pause, ());\r
+      INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE));\r
 \r
     int FOREVER = -1;\r
     while (app->destroyRequested != 1 && (app->activityState != APP_CMD_RESUME)) {\r
@@ -465,14 +464,14 @@ void fgPlatformProcessSingleEvent ( void )
        * be not possible to ensure InitContext CB gets called before\r
        * Resume CB like that.. so maybe just force calling initContext CB\r
        * here is best. Or we could force work on the window in question..\r
-       * 1) save old work mask, 2) set mask to init only, 3) call fgPlatformProcessWork directly\r
+       * 1) save old work mask, 2) set mask to init only, 3) call fgProcessWork directly\r
        * 4) set work mask back to the one saved in step 1.\r
        */\r
       if (!FETCH_WCB(*window, InitContext))\r
           fgWarning("Resuming application, but no callback to reload context resources (glutInitContextFunc)");\r
     }\r
 \r
-    INVOKE_WCB(*window, Resume, ());\r
+    INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME));\r
   }\r
 }\r
 \r
@@ -488,43 +487,24 @@ void fgPlatformMainLoopPreliminaryWork ( void )
 }\r
 \r
 \r
-/* Step through the work list */\r
-void fgPlatformProcessWork(SFG_Window *window)\r
+/* deal with work list items */\r
+void fgPlatformInitWork(SFG_Window* window)\r
 {\r
-    unsigned int workMask = window->State.WorkMask;\r
-    /* Now clear it so that any callback generated by the actions below can set work again */\r
-    window->State.WorkMask = 0;\r
+    /* notify windowStatus/visibility */\r
+    INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );\r
 \r
-    /* This is before the first display callback: call a few callbacks to inform user of window size, position, etc\r
-     * we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when\r
-     * they are opened, and work is done before displaying in the mainloop.\r
+    /* Position callback, always at 0,0 */\r
+    fghOnPositionNotify(window, 0, 0, GL_TRUE);\r
+\r
+    /* Size gets notified on window creation with size detection in mainloop above\r
+     * XXX CHECK: does this messages happen too early like on windows,\r
+     * so client code cannot have registered a callback yet and the message\r
+     * is thus never received by client?\r
      */\r
-    if (workMask & GLUT_INIT_WORK)\r
-    {\r
-        /* notify windowStatus/visibility */\r
-        INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );\r
-\r
-        /* Position callback, always at 0,0 */\r
-        fghOnPositionNotify(window, 0, 0, GL_TRUE);\r
-\r
-        /* Size gets notified on window creation with size detection in mainloop above\r
-         * XXX CHECK: does this messages happen too early like on windows,\r
-         * so client code cannot have registered a callback yet and the message\r
-         * is thus never received by client?\r
-         */\r
-\r
-        /* Call init context callback */\r
-        INVOKE_WCB( *window, InitContext, ());\r
-\r
-        /* Lastly, check if we have a display callback, error out if not\r
-         * This is the right place to do it, as the redisplay will be\r
-         * next right after we exit this function, so there is no more\r
-         * opportunity for the user to register a callback for this window.\r
-         */\r
-        if (!FETCH_WCB(*window, Display))\r
-            fgError ( "ERROR:  No display callback registered for window %d\n", window->ID );\r
-    }\r
+}\r
 \r
+void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask)\r
+{\r
     if (workMask & GLUT_FULL_SCREEN_WORK)\r
         fgPlatformFullScreenToggle( window );\r
     if (workMask & GLUT_POSITION_WORK)\r
@@ -538,29 +518,29 @@ void fgPlatformProcessWork(SFG_Window *window)
         else\r
             fgPlatformPopWindow( window );\r
     }\r
+}\r
 \r
-    if (workMask & GLUT_VISIBILITY_WORK)\r
+void fgPlatformVisibilityWork(SFG_Window* window)\r
+{\r
+    /* Visibility status of window should get updated in the window message handlers\r
+     * For now, none of these functions called below do anything, so don't worry\r
+     * about it\r
+     */\r
+    SFG_Window *win = window;\r
+    switch (window->State.DesiredVisibility)\r
     {\r
-        /* Visibility status of window should get updated in the window message handlers\r
-         * For now, none of these functions called below do anything, so don't worry\r
-         * about it\r
-         */\r
-        SFG_Window *win = window;\r
-        switch (window->State.DesiredVisibility)\r
-        {\r
-        case DesireHiddenState:\r
-            fgPlatformHideWindow( window );\r
-            break;\r
-        case DesireIconicState:\r
-            /* Call on top-level window */\r
-            while (win->Parent)\r
-                win = win->Parent;\r
-            fgPlatformIconifyWindow( win );\r
-            break;\r
-        case DesireNormalState:\r
-            fgPlatformShowWindow( window );\r
-            break;\r
-        }\r
+    case DesireHiddenState:\r
+        fgPlatformHideWindow( window );\r
+        break;\r
+    case DesireIconicState:\r
+        /* Call on top-level window */\r
+        while (win->Parent)\r
+            win = win->Parent;\r
+        fgPlatformIconifyWindow( win );\r
+        break;\r
+    case DesireNormalState:\r
+        fgPlatformShowWindow( window );\r
+        break;\r
     }\r
 }\r
 \r