static pCloseTouchInputHandle fghCloseTouchInputHandle = (pCloseTouchInputHandle)0xDEADBEEF;\r
#endif\r
\r
+extern void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height );\r
+extern void fghcbPlatformDisplayWindow ( SFG_Window *window );\r
+extern void fghPlatformSleepForEvents( long msec );\r
+extern void fghProcessSingleEvent ( void );\r
+\r
+\r
/*\r
* TODO BEFORE THE STABLE RELEASE:\r
*\r
* callback is hooked, the viewport size is updated to\r
* match the new window size.\r
*/\r
-static void fghReshapeWindow ( SFG_Window *window, int width, int height )\r
-{\r
- SFG_Window *current_window = fgStructure.CurrentWindow;\r
-\r
- freeglut_return_if_fail( window != NULL );\r
-\r
#if TARGET_HOST_POSIX_X11\r
-\r
+static void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height )\r
+{\r
XResizeWindow( fgDisplay.Display, window->Window.Handle,\r
width, height );\r
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */\r
+}\r
+#endif\r
\r
-#elif TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)\r
- {\r
- RECT windowRect;\r
-\r
- /*\r
- * For windowed mode, get the current position of the\r
- * window and resize taking the size of the frame\r
- * decorations into account.\r
- */\r
-\r
- /* "GetWindowRect" returns the pixel coordinates of the outside of the window */\r
- GetWindowRect( window->Window.Handle, &windowRect );\r
+static void fghReshapeWindow ( SFG_Window *window, int width, int height )\r
+{\r
+ SFG_Window *current_window = fgStructure.CurrentWindow;\r
\r
- /* Create rect in FreeGLUT format, (X,Y) topleft outside window, WxH of client area */\r
- windowRect.right = windowRect.left+width;\r
- windowRect.bottom = windowRect.top+height;\r
+ freeglut_return_if_fail( window != NULL );\r
\r
- if (window->Parent == NULL)\r
- /* get the window rect from this to feed to SetWindowPos, correct for window decorations */\r
- fghComputeWindowRectFromClientArea_QueryWindow(window,&windowRect,TRUE);\r
- else\r
- {\r
- /* correct rect for position client area of parent window\r
- * (SetWindowPos input for child windows is in coordinates\r
- * relative to the parent's client area).\r
- * Child windows don't have decoration, so no need to correct\r
- * for them.\r
- */\r
- RECT parentRect;\r
- parentRect = fghGetClientArea( window->Parent, FALSE );\r
- windowRect.left -= parentRect.left;\r
- windowRect.right -= parentRect.left;\r
- windowRect.top -= parentRect.top;\r
- windowRect.bottom -= parentRect.top;\r
- }\r
- \r
- /* Do the actual resizing */\r
- SetWindowPos( window->Window.Handle,\r
- HWND_TOP,\r
- windowRect.left, windowRect.top,\r
- windowRect.right - windowRect.left,\r
- windowRect.bottom- windowRect.top,\r
- SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |\r
- SWP_NOZORDER\r
- );\r
- }\r
-#endif\r
+ fghPlatformReshapeWindow ( window, width, height );\r
\r
if( FETCH_WCB( *window, Reshape ) )\r
INVOKE_WCB( *window, Reshape, ( width, height ) );\r
/*\r
* A static helper function to execute display callback for a window\r
*/\r
+#if TARGET_HOST_POSIX_X11\r
+static void fghcbPlatformDisplayWindow ( SFG_Window *window )\r
+{\r
+ fghRedrawWindow ( window ) ;\r
+}\r
+#endif\r
+\r
static void fghcbDisplayWindow( SFG_Window *window,\r
SFG_Enumerator *enumerator )\r
{\r
window->State.Visible )\r
{\r
window->State.Redisplay = GL_FALSE;\r
-\r
-#if TARGET_HOST_POSIX_X11\r
- fghRedrawWindow ( window ) ;\r
-#elif TARGET_HOST_MS_WINDOWS\r
-\r
- RedrawWindow(\r
- window->Window.Handle, NULL, NULL,\r
- RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW\r
- );\r
-#endif\r
+ fghcbPlatformDisplayWindow ( window );\r
}\r
\r
fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );\r
* Does the magic required to relinquish the CPU until something interesting\r
* happens.\r
*/\r
-static void fghSleepForEvents( void )\r
-{\r
- long msec;\r
-\r
- if( fgState.IdleCallback || fghHavePendingRedisplays( ) )\r
- return;\r
-\r
- msec = fghNextTimer( );\r
- /* XXX Use GLUT timers for joysticks... */\r
- /* XXX Dumb; forces granularity to .01sec */\r
- if( fghHaveJoystick( ) && ( msec > 10 ) ) \r
- msec = 10;\r
\r
#if TARGET_HOST_POSIX_X11\r
+static void fghPlatformSleepForEvents( long msec )\r
+{\r
/*\r
* Possibly due to aggressive use of XFlush() and friends,\r
* it is possible to have our socket drained but still have\r
fgWarning ( "freeglut select() error: %d", errno );\r
#endif\r
}\r
-#elif TARGET_HOST_MS_WINDOWS\r
- MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );\r
+}\r
#endif\r
+\r
+static void fghSleepForEvents( void )\r
+{\r
+ long msec;\r
+\r
+ if( fgState.IdleCallback || fghHavePendingRedisplays( ) )\r
+ return;\r
+\r
+ msec = fghNextTimer( );\r
+ /* XXX Use GLUT timers for joysticks... */\r
+ /* XXX Dumb; forces granularity to .01sec */\r
+ if( fghHaveJoystick( ) && ( msec > 10 ) ) \r
+ msec = 10;\r
+\r
+ fghPlatformSleepForEvents ( msec );\r
}\r
\r
#if TARGET_HOST_POSIX_X11\r
\r
return ret;\r
}\r
-#endif\r
\r
\r
-#if TARGET_HOST_POSIX_X11 && _DEBUG\r
\r
static const char* fghTypeToString( int type )\r
{\r
}\r
}\r
\r
-#endif\r
-\r
-/* -- INTERFACE FUNCTIONS -------------------------------------------------- */\r
\r
-/*\r
- * Executes a single iteration in the freeglut processing loop.\r
- */\r
-void FGAPIENTRY glutMainLoopEvent( void )\r
+void fghProcessSingleEvent ( void )\r
{\r
-#if TARGET_HOST_POSIX_X11\r
SFG_Window* window;\r
XEvent event;\r
\r
break;\r
}\r
}\r
+}\r
+#endif\r
\r
-#elif TARGET_HOST_MS_WINDOWS\r
-\r
- MSG stMsg;\r
-\r
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );\r
-\r
- while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )\r
- {\r
- if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )\r
- {\r
- if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )\r
- {\r
- fgDeinitialize( );\r
- exit( 0 );\r
- }\r
- else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )\r
- fgState.ExecState = GLUT_EXEC_STATE_STOP;\r
-\r
- return;\r
- }\r
+/* -- INTERFACE FUNCTIONS -------------------------------------------------- */\r
\r
- TranslateMessage( &stMsg );\r
- DispatchMessage( &stMsg );\r
- }\r
-#endif\r
+/*\r
+ * Executes a single iteration in the freeglut processing loop.\r
+ */\r
+void FGAPIENTRY glutMainLoopEvent( void )\r
+{\r
+ fghProcessSingleEvent ();\r
\r
if( fgState.Timers.First )\r
fghCheckTimers( );\r
+/*\r
+ * freeglut_main_mswin.c\r
+ *\r
+ * The Windows-specific mouse cursor related stuff.\r
+ *\r
+ * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.\r
+ * Written by John F. Fay, <fayjf@sourceforge.net>\r
+ * Creation date: Sat Jan 21, 2012\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_mswin.h"\r
+\r
+\r
+\r
+\r
+void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height )\r
+{\r
+ RECT windowRect;\r
+\r
+ /*\r
+ * For windowed mode, get the current position of the\r
+ * window and resize taking the size of the frame\r
+ * decorations into account.\r
+ */\r
+\r
+ /* "GetWindowRect" returns the pixel coordinates of the outside of the window */\r
+ GetWindowRect( window->Window.Handle, &windowRect );\r
+\r
+ /* Create rect in FreeGLUT format, (X,Y) topleft outside window, WxH of client area */\r
+ windowRect.right = windowRect.left+width;\r
+ windowRect.bottom = windowRect.top+height;\r
+\r
+ if (window->Parent == NULL)\r
+ /* get the window rect from this to feed to SetWindowPos, correct for window decorations */\r
+ fghComputeWindowRectFromClientArea_QueryWindow(window,&windowRect,TRUE);\r
+ else\r
+ {\r
+ /* correct rect for position client area of parent window\r
+ * (SetWindowPos input for child windows is in coordinates\r
+ * relative to the parent's client area).\r
+ * Child windows don't have decoration, so no need to correct\r
+ * for them.\r
+ */\r
+ RECT parentRect;\r
+ parentRect = fghGetClientArea( window->Parent, FALSE );\r
+ windowRect.left -= parentRect.left;\r
+ windowRect.right -= parentRect.left;\r
+ windowRect.top -= parentRect.top;\r
+ windowRect.bottom -= parentRect.top;\r
+ }\r
+ \r
+ /* Do the actual resizing */\r
+ SetWindowPos( window->Window.Handle,\r
+ HWND_TOP,\r
+ windowRect.left, windowRect.top,\r
+ windowRect.right - windowRect.left,\r
+ windowRect.bottom- windowRect.top,\r
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |\r
+ SWP_NOZORDER\r
+ );\r
+}\r
+\r
+\r
+void fghcbPlatformDisplayWindow ( SFG_Window *window )\r
+{\r
+ RedrawWindow(\r
+ window->Window.Handle, NULL, NULL,\r
+ RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW\r
+ );\r
+}\r
+\r
+\r
+void fghPlatformSleepForEvents( long msec )\r
+{\r
+ MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );\r
+}\r
+\r
+\r
+void fghProcessSingleEvent ( void )\r
+{\r
+ MSG stMsg;\r
+\r
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );\r
+\r
+ while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )\r
+ {\r
+ if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )\r
+ {\r
+ if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )\r
+ {\r
+ fgDeinitialize( );\r
+ exit( 0 );\r
+ }\r
+ else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )\r
+ fgState.ExecState = GLUT_EXEC_STATE_STOP;\r
+\r
+ return;\r
+ }\r
+\r
+ TranslateMessage( &stMsg );\r
+ DispatchMessage( &stMsg );\r
+ }\r
+}\r
+\r
+\r