X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffreeglut_main_mswin.c;h=8ea57b0a6ad69c35d09ce567eb8c397194eac7bc;hb=ef90e5c72102f31823452430eb0b704dd3a44113;hp=81013d36f2fc1eef24c970d56762e63ba9678d68;hpb=6ff4a7eb4780b498d9630d343d6302b76af8e8c5;p=freeglut diff --git a/src/mswin/freeglut_main_mswin.c b/src/mswin/freeglut_main_mswin.c index 81013d3..8ea57b0 100644 --- a/src/mswin/freeglut_main_mswin.c +++ b/src/mswin/freeglut_main_mswin.c @@ -26,13 +26,32 @@ */ #include -#include "freeglut_internal_mswin.h" +#include "../Common/freeglut_internal.h" extern void fghRedrawWindow ( SFG_Window *window ); +extern void fgNewWGLCreateContext( SFG_Window* window ); +extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, + unsigned char layer_type ); -void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height ) +#ifdef WM_TOUCH +typedef BOOL (WINAPI *pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int); +typedef BOOL (WINAPI *pCloseTouchInputHandle)(HTOUCHINPUT); +static pGetTouchInputInfo fghGetTouchInputInfo = (pGetTouchInputInfo)0xDEADBEEF; +static pCloseTouchInputHandle fghCloseTouchInputHandle = (pCloseTouchInputHandle)0xDEADBEEF; +#endif + +/* + * Helper functions for getting client area from the window rect + * and the window rect from the client area given the style of the window + * (or a valid window pointer from which the style can be queried). + */ +extern void fghComputeWindowRectFromClientArea_QueryWindow( const SFG_Window *window, RECT *clientRect, BOOL posIsOutside ); +extern RECT fghGetClientArea ( const SFG_Window *window, BOOL wantPosOutside ); + + +void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) { RECT windowRect; @@ -80,7 +99,7 @@ void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height ) } -void fghcbPlatformDisplayWindow ( SFG_Window *window ) +void fgPlatformDisplayWindow ( SFG_Window *window ) { RedrawWindow( window->Window.Handle, NULL, NULL, @@ -89,13 +108,23 @@ void fghcbPlatformDisplayWindow ( SFG_Window *window ) } -void fghPlatformSleepForEvents( long msec ) +unsigned long fgPlatformSystemTime ( void ) +{ +#if defined(_WIN32_WCE) + return GetTickCount(); +#else + return timeGetTime(); +#endif +} + + +void fgPlatformSleepForEvents( long msec ) { MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT ); } -void fghProcessSingleEvent ( void ) +void fgPlatformProcessSingleEvent ( void ) { MSG stMsg; @@ -123,7 +152,7 @@ void fghProcessSingleEvent ( void ) -void fghMainLoopPreliminaryWork ( void ) +void fgPlatformMainLoopPreliminaryWork ( void ) { SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ; @@ -154,7 +183,7 @@ void fghMainLoopPreliminaryWork ( void ) /* * Determine a GLUT modifer mask based on MS-WINDOWS system info. */ -static int fghGetModifiers (void) +static int fgPlatformGetModifiers (void) { return ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) || @@ -168,8 +197,8 @@ static int fghGetModifiers (void) /* * The window procedure for handling Win32 events */ -LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, - LPARAM lParam ) +LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, + LPARAM lParam ) { static unsigned char lControl = 0, rControl = 0, lShift = 0, rShift = 0, lAlt = 0, rAlt = 0; @@ -307,10 +336,10 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, /* The window structure is passed as the creation structure parameter... */ window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams); FREEGLUT_INTERNAL_ERROR_EXIT ( ( window != NULL ), "Cannot create window", - "fgWindowProc" ); + "fgPlatformWindowProc" ); window->Window.Handle = hWnd; - window->Window.Device = GetDC( hWnd ); + window->Window.pContext.Device = GetDC( hWnd ); if( window->IsMenu ) { unsigned int current_DisplayMode = fgState.DisplayMode; @@ -321,7 +350,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, fgState.DisplayMode = current_DisplayMode; if( fgStructure.MenuContext ) - wglMakeCurrent( window->Window.Device, + wglMakeCurrent( window->Window.pContext.Device, fgStructure.MenuContext->MContext ); else @@ -329,11 +358,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, fgStructure.MenuContext = (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) ); fgStructure.MenuContext->MContext = - wglCreateContext( window->Window.Device ); + wglCreateContext( window->Window.pContext.Device ); } /* window->Window.Context = wglGetCurrentContext (); */ - window->Window.Context = wglCreateContext( window->Window.Device ); + window->Window.Context = wglCreateContext( window->Window.pContext.Device ); } else { @@ -343,13 +372,13 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, if( ! fgState.UseCurrentContext ) window->Window.Context = - wglCreateContext( window->Window.Device ); + wglCreateContext( window->Window.pContext.Device ); else { window->Window.Context = wglGetCurrentContext( ); if( ! window->Window.Context ) window->Window.Context = - wglCreateContext( window->Window.Device ); + wglCreateContext( window->Window.pContext.Device ); } #if !defined(_WIN32_WCE) @@ -372,7 +401,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, fgSetWindow( current_window ); } - ReleaseDC( window->Window.Handle, window->Window.Device ); + ReleaseDC( window->Window.Handle, window->Window.pContext.Device ); #if defined(_WIN32_WCE) /* Take over button handling */ @@ -417,6 +446,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, /* printf("WM_SETFOCUS: %p\n", window ); */ lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); INVOKE_WCB( *window, Entry, ( GLUT_ENTERED ) ); + + UpdateWindow ( hWnd ); break; case WM_KILLFOCUS: @@ -497,7 +528,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, } SetFocus(window->Window.Handle); - fgState.Modifiers = fghGetModifiers( ); + fgState.Modifiers = fgPlatformGetModifiers( ); if( ( wParam & MK_LBUTTON ) || ( wParam & MK_MBUTTON ) || @@ -607,7 +638,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, break; fgSetWindow( window ); - fgState.Modifiers = fghGetModifiers( ); + fgState.Modifiers = fgPlatformGetModifiers( ); INVOKE_WCB( *window, Mouse, @@ -641,7 +672,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, break; fgSetWindow( window ); - fgState.Modifiers = fghGetModifiers( ); + fgState.Modifiers = fgPlatformGetModifiers( ); /* * XXX Should use WHEEL_DELTA instead of 120 @@ -702,7 +733,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, * Remember the current modifiers state. This is done here in order * to make sure the VK_DELETE keyboard callback is executed properly. */ - fgState.Modifiers = fghGetModifiers( ); + fgState.Modifiers = fgPlatformGetModifiers( ); GetCursorPos( &mouse_pos ); ScreenToClient( window->Window.Handle, &mouse_pos ); @@ -792,7 +823,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, * Remember the current modifiers state. This is done here in order * to make sure the VK_DELETE keyboard callback is executed properly. */ - fgState.Modifiers = fghGetModifiers( ); + fgState.Modifiers = fgPlatformGetModifiers( ); GetCursorPos( &mouse_pos ); ScreenToClient( window->Window.Handle, &mouse_pos ); @@ -877,7 +908,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, if( (fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE) && (HIWORD(lParam) & KF_REPEAT) ) break; - fgState.Modifiers = fghGetModifiers( ); + fgState.Modifiers = fgPlatformGetModifiers( ); INVOKE_WCB( *window, Keyboard, ( (char)wParam, window->State.MouseX, window->State.MouseY )