X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffreeglut_window_mswin.c;h=d4c5fd7c3b15e397923d5af659a0104d2e6775d1;hb=4c83751ce90624de7cb03a04f389300a2318e61f;hp=e5062b49c8ee10d253f3b37f37dc1531eacf129a;hpb=625d4f9446481f4a1684314cb559df7976090578;p=freeglut diff --git a/src/mswin/freeglut_window_mswin.c b/src/mswin/freeglut_window_mswin.c index e5062b4..d4c5fd7 100644 --- a/src/mswin/freeglut_window_mswin.c +++ b/src/mswin/freeglut_window_mswin.c @@ -25,6 +25,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#define FREEGLUT_BUILDING_LIB #include #include "../Common/freeglut_internal.h" @@ -169,9 +170,9 @@ void fgNewWGLCreateContext( SFG_Window* window ) return; } - wglMakeCurrent( window->Window.Device, window->Window.Context ); + wglMakeCurrent( window->Window.pContext.Device, window->Window.Context ); - if ( !fghIsExtensionSupported( window->Window.Device, "WGL_ARB_create_context" ) ) + if ( !fghIsExtensionSupported( window->Window.pContext.Device, "WGL_ARB_create_context" ) ) { return; } @@ -185,7 +186,7 @@ void fgNewWGLCreateContext( SFG_Window* window ) fgError( "wglCreateContextAttribsARB not found" ); } - context = wglCreateContextAttribsARB( window->Window.Device, 0, attributes ); + context = wglCreateContextAttribsARB( window->Window.pContext.Device, 0, attributes ); if ( context == NULL ) { fghContextCreationError(); @@ -296,7 +297,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, if (checkOnly) current_hDC = CreateDC(TEXT("DISPLAY"), NULL ,NULL ,NULL); else - current_hDC = window->Window.Device; + current_hDC = window->Window.pContext.Device; fghFillPFD( ppfd, current_hDC, layer_type ); pixelformat = ChoosePixelFormat( current_hDC, ppfd ); @@ -313,12 +314,12 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, /* create a dummy window */ ZeroMemory(&wndCls, sizeof(wndCls)); wndCls.lpfnWndProc = DefWindowProc; - wndCls.hInstance = fgDisplay.Instance; + wndCls.hInstance = fgDisplay.pDisplay.Instance; wndCls.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; wndCls.lpszClassName = _T("FREEGLUT_dummy"); RegisterClass( &wndCls ); - hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.Instance, 0 ); + hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.pDisplay.Instance, 0 ); hDC=GetDC(hWnd); SetPixelFormat( hDC, pixelformat, ppfd ); @@ -350,7 +351,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, wglDeleteContext(rc); ReleaseDC(hWnd, hDC); DestroyWindow(hWnd); - UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.Instance); + UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.pDisplay.Instance); } success = ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( current_hDC, pixelformat, ppfd ) ); @@ -370,13 +371,13 @@ void fgPlatformSetWindow ( SFG_Window *window ) { if( fgStructure.CurrentWindow ) ReleaseDC( fgStructure.CurrentWindow->Window.Handle, - fgStructure.CurrentWindow->Window.Device ); + fgStructure.CurrentWindow->Window.pContext.Device ); if ( window ) { - window->Window.Device = GetDC( window->Window.Handle ); + window->Window.pContext.Device = GetDC( window->Window.Handle ); wglMakeCurrent( - window->Window.Device, + window->Window.pContext.Device, window->Window.Context ); } @@ -571,7 +572,7 @@ static BOOL CALLBACK m_proc(HMONITOR mon, /* * this function returns the origin of the screen identified by - * fgDisplay.DisplayName, and 0 otherwise. + * fgDisplay.pDisplay.DisplayName, and 0 otherwise. * This is used in fgOpenWindow to open the gamemode window on the screen * identified by the -display command line argument. The function should * not be called otherwise. @@ -582,12 +583,12 @@ static void get_display_origin(int *xp,int *yp) *xp = 0; *yp = 0; - if( fgDisplay.DisplayName ) + if( fgDisplay.pDisplay.DisplayName ) { m_proc_t st; st.x=xp; st.y=yp; - st.name=fgDisplay.DisplayName; + st.name=fgDisplay.pDisplay.DisplayName; EnumDisplayMonitors(0,0,m_proc,(LPARAM)&st); } } @@ -599,7 +600,7 @@ static void get_display_origin(int *xp,int *yp) *xp = 0; *yp = 0; - if( fgDisplay.DisplayName ) + if( fgDisplay.pDisplay.DisplayName ) { fgWarning( "for working -display support FreeGLUT must be compiled with WINVER >= 0x0500"); } @@ -624,7 +625,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, ATOM atom; /* Grab the window class we have registered on glutInit(): */ - atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc ); + atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc ); FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Info Not Found", "fgOpenWindow" ); @@ -748,7 +749,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, 0,0, 240,320, NULL, NULL, - fgDisplay.Instance, + fgDisplay.pDisplay.Instance, (LPVOID) window ); @@ -770,7 +771,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, x, y, w, h, (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle, (HMENU) NULL, - fgDisplay.Instance, + fgDisplay.pDisplay.Instance, (LPVOID) window ); #endif /* defined(_WIN32_WCE) */ @@ -978,10 +979,10 @@ void fgPlatformGlutFullScreen( SFG_Window *win ) /* store current window rect */ - GetWindowRect( win->Window.Handle, &win->State.OldRect ); + GetWindowRect( win->Window.Handle, &win->State.pWState.OldRect ); /* store current window style */ - win->State.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE); + win->State.pWState.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE); /* remove decorations from style and add popup style*/ s &= ~WS_OVERLAPPEDWINDOW; @@ -992,7 +993,7 @@ void fgPlatformGlutFullScreen( SFG_Window *win ) /* For fullscreen mode, find the monitor that is covered the most * by the window and get its rect as the resize target. */ - hMonitor= MonitorFromRect(&win->State.OldRect, MONITOR_DEFAULTTONEAREST); + hMonitor= MonitorFromRect(&win->State.pWState.OldRect, MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(mi); GetMonitorInfo(hMonitor, &mi); rect = mi.rcMonitor; @@ -1048,16 +1049,16 @@ void fgPlatformGlutLeaveFullScreen( SFG_Window *win ) } /* restore style of window before making it fullscreen */ - SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.OldStyle); + SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.pWState.OldStyle); SetWindowPos(win->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); /* Then resize */ SetWindowPos(win->Window.Handle, HWND_TOP, - win->State.OldRect.left, - win->State.OldRect.top, - win->State.OldRect.right - win->State.OldRect.left, - win->State.OldRect.bottom - win->State.OldRect.top, + win->State.pWState.OldRect.left, + win->State.pWState.OldRect.top, + win->State.pWState.OldRect.right - win->State.pWState.OldRect.left, + win->State.pWState.OldRect.bottom - win->State.pWState.OldRect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER ); @@ -1078,3 +1079,11 @@ void fgPlatformGlutFullScreenToggle( SFG_Window *win ) } +/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */ + +int FGAPIENTRY __glutCreateWindowWithExit( const char *title, void (__cdecl *exit_function)(int) ) +{ + __glutExitFunc = exit_function; + return glutCreateWindow( title ); +} +