X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_window.c;h=366bbf31120ccfb8565911991452dfe8c9c62636;hb=af47c3f93c7834b4006c49ec9df6a6ffdd3025de;hp=1a65c1f8460a0badde83e4ab2711b65f4d33c976;hpb=99d53f15a4216240088132f6af9cb194b519b1cc;p=freeglut diff --git a/src/fg_window.c b/src/fg_window.c index 1a65c1f..366bbf3 100644 --- a/src/fg_window.c +++ b/src/fg_window.c @@ -1,5 +1,5 @@ /* - * freeglut_window.c + * fg_window.c * * Window management methods. * @@ -106,7 +106,7 @@ void fghContextCreationError( void ) */ void fgSetWindow ( SFG_Window *window ) { - fgPlatformSetWindow ( window ); + fgPlatformSetWindow ( window ); fgStructure.CurrentWindow = window; } @@ -120,22 +120,26 @@ void fgOpenWindow( SFG_Window* window, const char* title, GLboolean sizeUse, int w, int h, GLboolean gameMode, GLboolean isSubWindow ) { - fgPlatformOpenWindow( window, title, - positionUse, x, y, - sizeUse, w, h, - gameMode, isSubWindow ); + fgPlatformOpenWindow( window, title, + positionUse, x, y, + sizeUse, w, h, + gameMode, isSubWindow ); fgSetWindow( window ); +#ifndef EGL_VERSION_1_0 window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0; -#ifndef EGL_VERSION_1_0 /* No glDrawBuffer/glReadBuffer in GLES */ if ( ! window->Window.DoubleBuffered ) { glDrawBuffer ( GL_FRONT ); glReadBuffer ( GL_FRONT ); } +#else + /* - EGL is always double-buffered */ + /* - No glDrawBuffer/glReadBuffer in GLES */ + window->Window.DoubleBuffered = 1; #endif window->Window.attribute_v_coord = -1; window->Window.attribute_v_normal = -1; @@ -158,7 +162,7 @@ void fgCloseWindow( SFG_Window* window ) if (fgStructure.GameModeWindow != NULL && fgStructure.GameModeWindow->ID==window->ID) glutLeaveGameMode(); - fgPlatformCloseWindow ( window ); + fgPlatformCloseWindow ( window ); } @@ -173,12 +177,12 @@ int FGAPIENTRY glutCreateWindow( const char* title ) * XXX application has not already done so. The "freeglut" community * XXX decided not to go this route (freeglut-developer e-mail from * XXX Steve Baker, 12/16/04, 4:22 PM CST, "Re: [Freeglut-developer] - * XXX Desired 'freeglut' behaviour when there is no current window" + * XXX Desired 'freeglut' behaviour when there is no current window") */ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" ); - return fgCreateWindow( NULL, title, fgState.Position.Use, - fgState.Position.X, fgState.Position.Y, + return fgCreateWindow( NULL, title, + fgState.Position.Use, fgState.Position.X, fgState.Position.Y, fgState.Size.Use, fgState.Size.X, fgState.Size.Y, GL_FALSE, GL_FALSE )->ID; } @@ -195,33 +199,51 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h ) FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateSubWindow" ); parent = fgWindowByID( parentID ); freeglut_return_val_if_fail( parent != NULL, 0 ); - if ( x < 0 ) - { - x = parent->State.Width + x ; - if ( w >= 0 ) x -= w ; - } - if ( w < 0 ) w = parent->State.Width - x + w ; - if ( w < 0 ) + if ( fgState.AllowNegativeWindowPosition ) { - x += w ; - w = -w ; - } + /* XXX This results in different widths/heights than if AllowNegativeWindowPosition + * XXX was false. The "freeglut" community defined this logic. + * XXX (freeglut-developer e-mail from Diederick C. Niehorster, 11/15/2015, 4:06 PM EST. + * XXX "Re: [Freeglut-developer] glutInitWindowPosition with negative coordinate(s)") + */ - if ( y < 0 ) - { - y = parent->State.Height + y ; - if ( h >= 0 ) y -= h ; + if ( w < 0 ) w = parent->State.Width + w ; + if ( h < 0 ) h = parent->State.Height + h ; } - - if ( h < 0 ) h = parent->State.Height - y + h ; - if ( h < 0 ) + else { - y += h ; - h = -h ; + if ( ( x < 0 ) ) + { + x = parent->State.Width + x ; + if ( w > 0 ) x -= w ; + } + + if ( w < 0 ) w = parent->State.Width - x + w ; + if ( w < 0 ) + { + x += w ; + w = -w ; + } + + if ( ( y < 0 ) ) + { + y = parent->State.Height + y ; + if ( h > 0 ) y -= h ; + } + + if ( h < 0 ) h = parent->State.Height - y + h ; + if ( h < 0 ) + { + y += h ; + h = -h ; + } } - window = fgCreateWindow( parent, "", GL_TRUE, x, y, GL_TRUE, w, h, GL_FALSE, GL_FALSE ); + window = fgCreateWindow( parent, "", + GL_TRUE, x, y, + GL_TRUE, w, h, + GL_FALSE, GL_FALSE ); ret = window->ID; return ret; @@ -295,7 +317,7 @@ void FGAPIENTRY glutShowWindow( void ) fgStructure.CurrentWindow->State.WorkMask |= GLUT_VISIBILITY_WORK; fgStructure.CurrentWindow->State.DesiredVisibility = DesireNormalState; - fgStructure.CurrentWindow->State.Redisplay = GL_TRUE; + fgStructure.CurrentWindow->State.WorkMask |= GLUT_DISPLAY_WORK; } /* @@ -309,7 +331,7 @@ void FGAPIENTRY glutHideWindow( void ) fgStructure.CurrentWindow->State.WorkMask |= GLUT_VISIBILITY_WORK; fgStructure.CurrentWindow->State.DesiredVisibility = DesireHiddenState; - fgStructure.CurrentWindow->State.Redisplay = GL_FALSE; + fgStructure.CurrentWindow->State.WorkMask &= ~GLUT_DISPLAY_WORK; } /* @@ -323,7 +345,7 @@ void FGAPIENTRY glutIconifyWindow( void ) fgStructure.CurrentWindow->State.WorkMask |= GLUT_VISIBILITY_WORK; fgStructure.CurrentWindow->State.DesiredVisibility = DesireIconicState; - fgStructure.CurrentWindow->State.Redisplay = GL_FALSE; + fgStructure.CurrentWindow->State.WorkMask &= ~GLUT_DISPLAY_WORK; } /* @@ -335,7 +357,7 @@ void FGAPIENTRY glutSetWindowTitle( const char* title ) FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetWindowTitle" ); if( ! fgStructure.CurrentWindow->Parent ) { - fgPlatformGlutSetWindowTitle ( title ); + fgPlatformGlutSetWindowTitle ( title ); } } @@ -349,7 +371,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title ) if( ! fgStructure.CurrentWindow->Parent ) { - fgPlatformGlutSetIconTitle ( title ); + fgPlatformGlutSetIconTitle ( title ); } } @@ -445,7 +467,7 @@ void FGAPIENTRY glutFullScreen( void ) } if (!win->State.IsFullscreen) - win->State.WorkMask |= GLUT_FULL_SCREEN_WORK; + win->State.WorkMask |= GLUT_FULL_SCREEN_WORK; } /*