Defined logic for glutCreateSubWindow when negative position is allowed
Added check for if fgCreateWindow cannot allocate a window, it will produce an error. (cherry picked from commit0ed05f6458
) (cherry picked from commit0ed05f6458
) git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1776 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
d898bfe4c6
commit
d8e364d053
@ -75,6 +75,11 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
|
|||||||
/* Have the window object created */
|
/* Have the window object created */
|
||||||
SFG_Window *window = (SFG_Window *)calloc( 1, sizeof(SFG_Window) );
|
SFG_Window *window = (SFG_Window *)calloc( 1, sizeof(SFG_Window) );
|
||||||
|
|
||||||
|
if( !window )
|
||||||
|
{
|
||||||
|
fgError( "Out of memory. Could not create window." );
|
||||||
|
}
|
||||||
|
|
||||||
fgPlatformCreateWindow ( window );
|
fgPlatformCreateWindow ( window );
|
||||||
|
|
||||||
fghClearCallBacks( window );
|
fghClearCallBacks( window );
|
||||||
|
@ -177,12 +177,12 @@ int FGAPIENTRY glutCreateWindow( const char* title )
|
|||||||
* XXX application has not already done so. The "freeglut" community
|
* XXX application has not already done so. The "freeglut" community
|
||||||
* XXX decided not to go this route (freeglut-developer e-mail from
|
* 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 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" );
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" );
|
||||||
|
|
||||||
return fgCreateWindow( NULL, title, fgState.Position.Use,
|
return fgCreateWindow( NULL, title,
|
||||||
fgState.Position.X, fgState.Position.Y,
|
fgState.Position.Use, fgState.Position.X, fgState.Position.Y,
|
||||||
fgState.Size.Use, fgState.Size.X, fgState.Size.Y,
|
fgState.Size.Use, fgState.Size.X, fgState.Size.Y,
|
||||||
GL_FALSE, GL_FALSE )->ID;
|
GL_FALSE, GL_FALSE )->ID;
|
||||||
}
|
}
|
||||||
@ -199,33 +199,51 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
|
|||||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateSubWindow" );
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateSubWindow" );
|
||||||
parent = fgWindowByID( parentID );
|
parent = fgWindowByID( parentID );
|
||||||
freeglut_return_val_if_fail( parent != NULL, 0 );
|
freeglut_return_val_if_fail( parent != NULL, 0 );
|
||||||
if ( x < 0 )
|
|
||||||
|
if ( fgState.AllowNegativeWindowPosition )
|
||||||
{
|
{
|
||||||
x = parent->State.Width + x ;
|
/* XXX This results in different widths/heights than if AllowNegativeWindowPosition
|
||||||
if ( w >= 0 ) x -= w ;
|
* 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 ( w < 0 ) w = parent->State.Width + w ;
|
||||||
|
if ( h < 0 ) h = parent->State.Height + h ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( w < 0 ) w = parent->State.Width - x + w ;
|
window = fgCreateWindow( parent, "",
|
||||||
if ( w < 0 )
|
GL_TRUE, x, y,
|
||||||
{
|
GL_TRUE, w, h,
|
||||||
x += w ;
|
GL_FALSE, GL_FALSE );
|
||||||
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 );
|
|
||||||
ret = window->ID;
|
ret = window->ID;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user