autotools: Android port
[freeglut] / src / Common / freeglut_display.c
index 086d24a..6421be4 100644 (file)
-/*\r
- * freeglut_display.c\r
- *\r
- * Display message posting, context buffer swapping.\r
- *\r
- * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.\r
- * Written by Pawel W. Olszta, <olszta@sourceforge.net>\r
- * Creation date: Fri Dec 3 1999\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
- * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-#include <GL/freeglut.h>\r
-#include "freeglut_internal.h"\r
-\r
-\r
-/* Function prototypes */\r
-extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow );\r
-\r
-\r
-#if TARGET_HOST_POSIX_X11\r
-void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )\r
-{\r
-    glXSwapBuffers( pDisplayPtr->Display, CurrentWindow->Window.Handle );\r
-}\r
-#endif\r
-\r
-/* -- INTERFACE FUNCTIONS -------------------------------------------------- */\r
-\r
-/*\r
- * Marks the current window to have the redisplay performed when possible...\r
- */\r
-void FGAPIENTRY glutPostRedisplay( void )\r
-{\r
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );\r
-    if ( ! fgStructure.CurrentWindow )\r
-       {\r
-      fgError ( " ERROR:  Function <%s> called"\r
-                " with no current window defined.", "glutPostRedisplay" ) ;\r
-       }\r
-\r
-    fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;\r
-}\r
-\r
-/*\r
- * Swaps the buffers for the current window (if any)\r
- */\r
-void FGAPIENTRY glutSwapBuffers( void )\r
-{\r
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );\r
-    FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );\r
-\r
-    /*\r
-     * "glXSwapBuffers" already performs an implicit call to "glFlush". What\r
-     * about "SwapBuffers"?\r
-     */\r
-    glFlush( );\r
-    if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )\r
-        return;\r
-\r
-    fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow );\r
-\r
-    /* GLUT_FPS env var support */\r
-    if( fgState.FPSInterval )\r
-    {\r
-        GLint t = glutGet( GLUT_ELAPSED_TIME );\r
-        fgState.SwapCount++;\r
-        if( fgState.SwapTime == 0 )\r
-            fgState.SwapTime = t;\r
-        else if( t - fgState.SwapTime > fgState.FPSInterval )\r
-        {\r
-            float time = 0.001f * ( t - fgState.SwapTime );\r
-            float fps = ( float )fgState.SwapCount / time;\r
-            fprintf( stderr,\r
-                     "freeglut: %d frames in %.2f seconds = %.2f FPS\n",\r
-                     fgState.SwapCount, time, fps );\r
-            fgState.SwapTime = t;\r
-            fgState.SwapCount = 0;\r
-        }\r
-    }\r
-}\r
-\r
-/*\r
- * Mark appropriate window to be displayed\r
- */\r
-void FGAPIENTRY glutPostWindowRedisplay( int windowID )\r
-{\r
-    SFG_Window* window;\r
-\r
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );\r
-    window = fgWindowByID( windowID );\r
-    freeglut_return_if_fail( window );\r
-    window->State.Redisplay = GL_TRUE;\r
-}\r
-\r
-/*** END OF FILE ***/\r
+/*
+ * freeglut_display.c
+ *
+ * Display message posting, context buffer swapping.
+ *
+ * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
+ * Written by Pawel W. Olszta, <olszta@sourceforge.net>
+ * Creation date: Fri Dec 3 1999
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <GL/freeglut.h>
+#include "freeglut_internal.h"
+
+
+/* Function prototypes */
+extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow );
+
+
+/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
+
+/*
+ * Marks the current window to have the redisplay performed when possible...
+ */
+void FGAPIENTRY glutPostRedisplay( void )
+{
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
+    if ( ! fgStructure.CurrentWindow )
+       {
+      fgError ( " ERROR:  Function <%s> called"
+                " with no current window defined.", "glutPostRedisplay" ) ;
+       }
+
+    fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
+}
+
+/*
+ * Swaps the buffers for the current window (if any)
+ */
+void FGAPIENTRY glutSwapBuffers( void )
+{
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
+    FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
+
+    /*
+     * "glXSwapBuffers" already performs an implicit call to "glFlush". What
+     * about "SwapBuffers"?
+     */
+    glFlush( );
+    if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )
+        return;
+
+    fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow );
+
+    /* GLUT_FPS env var support */
+    if( fgState.FPSInterval )
+    {
+        GLint t = glutGet( GLUT_ELAPSED_TIME );
+        fgState.SwapCount++;
+        if( fgState.SwapTime == 0 )
+            fgState.SwapTime = t;
+        else if( t - fgState.SwapTime > fgState.FPSInterval )
+        {
+            float time = 0.001f * ( t - fgState.SwapTime );
+            float fps = ( float )fgState.SwapCount / time;
+            fprintf( stderr,
+                     "freeglut: %d frames in %.2f seconds = %.2f FPS\n",
+                     fgState.SwapCount, time, fps );
+            fgState.SwapTime = t;
+            fgState.SwapCount = 0;
+        }
+    }
+}
+
+/*
+ * Mark appropriate window to be displayed
+ */
+void FGAPIENTRY glutPostWindowRedisplay( int windowID )
+{
+    SFG_Window* window;
+
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
+    window = fgWindowByID( windowID );
+    freeglut_return_if_fail( window );
+    window->State.Redisplay = GL_TRUE;
+}
+
+/*** END OF FILE ***/