X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_window.c;h=0542017bee12ef62831027a918913b0c36d865aa;hb=34f0aa01c95a8e6843069d5b9e4b2e7a7bbe1e53;hp=897b03cd185770d9a4ef3f4368f7fa60daceee8a;hpb=e6b149a66a5d6f7539855ca7922791cd22348f43;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 897b03c..0542017 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -177,7 +177,7 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShar static int fghIsLegacyContextVersionRequested( void ) { - return fgState.MajorVersion == 1 && fgState.MinorVersion == 0; + return fgState.MajorVersion < 2 || (fgState.MajorVersion == 2 && fgState.MinorVersion <= 1); } static int fghIsLegacyContextRequested( void ) @@ -443,10 +443,17 @@ static GLXContext fghCreateNewContext( SFG_Window* window ) /* new context creation */ int attributes[9]; - CreateContextAttribsProc createContextAttribs; + CreateContextAttribsProc createContextAttribs = (CreateContextAttribsProc) fghGetProcAddress( "glXCreateContextAttribsARB" ); + + /* glXCreateContextAttribsARB not found, yet the user has requested the new context creation */ + if ( !createContextAttribs && !fghIsLegacyContextRequested() ) { + fgWarning( "OpenGL >2.1 context requested but glXCreateContextAttribsARB is not available! Falling back to legacy context creation" ); + fgState.MajorVersion = 2; + fgState.MinorVersion = 1; + } /* If nothing fancy has been required, simply use the old context creation GLX API entry */ - if ( fghIsLegacyContextRequested() ) + if ( fghIsLegacyContextRequested() || !createContextAttribs ) { context = glXCreateNewContext( dpy, config, render_type, share_list, direct ); if ( context == NULL ) { @@ -462,11 +469,6 @@ static GLXContext fghCreateNewContext( SFG_Window* window ) fghFillContextAttributes( attributes ); - createContextAttribs = (CreateContextAttribsProc) fghGetProcAddress( "glXCreateContextAttribsARB" ); - if ( createContextAttribs == NULL ) { - fgError( "glXCreateContextAttribsARB not found" ); - } - context = createContextAttribs( dpy, config, share_list, direct, attributes ); if ( context == NULL ) { fghContextCreationError(); @@ -1076,7 +1078,7 @@ static void get_display_origin(int *xp,int *yp) #if TARGET_HOST_POSIX_X11 static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg) { - Window window = arg; + Window window = (Window)arg; return (event->type == MapNotify) && (event->xmap.window == window); } #endif @@ -1092,7 +1094,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, GLboolean gameMode, GLboolean isSubWindow ) { #if TARGET_HOST_POSIX_X11 - XVisualInfo * visualInfo; + XVisualInfo * visualInfo = NULL; XSetWindowAttributes winAttr; XTextProperty textProperty; XSizeHints sizeHints; @@ -1297,7 +1299,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, XFree(visualInfo); if( !isSubWindow) - XPeekIfEvent( fgDisplay.Display, &eventReturnBuffer, &fghWindowIsVisible, window->Window.Handle ); + XPeekIfEvent( fgDisplay.Display, &eventReturnBuffer, &fghWindowIsVisible, (XPointer)(window->Window.Handle) ); #elif TARGET_HOST_MS_WINDOWS @@ -1367,7 +1369,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, if( gameMode ) { /* if in gamemode, query the origin of specified by the -display - * parameter command line (if any) and offset the upper-left corner + * command line parameter (if any) and offset the upper-left corner * of the window so we create the window on that screen. * The -display argument doesn't do anything if not trying to enter * gamemode. @@ -2000,6 +2002,7 @@ void FGAPIENTRY glutFullScreen( void ) } { +#if(WINVER >= 0x0500) /* Windows 2000 or later */ DWORD s; RECT rect; HMONITOR hMonitor; @@ -2031,6 +2034,22 @@ void FGAPIENTRY glutFullScreen( void ) mi.cbSize = sizeof(mi); GetMonitorInfo(hMonitor, &mi); rect = mi.rcMonitor; +#else /* if (WINVER >= 0x0500) */ + RECT rect; + + /* For fullscreen mode, force the top-left corner to 0,0 + * and adjust the window rectangle so that the client area + * covers the whole screen. + */ + + rect.left = 0; + rect.top = 0; + rect.right = fgDisplay.ScreenWidth; + rect.bottom = fgDisplay.ScreenHeight; + + AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | + WS_CLIPCHILDREN, FALSE ); +#endif /* (WINVER >= 0x0500) */ /* * then resize window @@ -2048,7 +2067,7 @@ void FGAPIENTRY glutFullScreen( void ) SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER ); - + win->State.IsFullscreen = GL_TRUE; } #endif