}
fgStructure.GameModeWindow = fgCreateWindow(
- NULL, "FREEGLUT", 0, 0,
- fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, GL_FALSE
+ NULL, "FREEGLUT", GL_TRUE, 0, 0,
+ GL_TRUE, fgState.GameModeSize.X, fgState.GameModeSize.Y,
+ GL_TRUE, GL_FALSE
);
fgStructure.GameModeWindow->State.Width = fgState.GameModeSize.X;
* Defined in freeglut_structure.c, freeglut_window.c.
*/
SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
- int x, int y, int w, int h,
+ GLboolean positionUse, int x, int y,
+ GLboolean sizeUse, int w, int h,
GLboolean gameMode, GLboolean isMenu );
void fgSetWindow ( SFG_Window *window );
void fgOpenWindow( SFG_Window* window, const char* title,
- int x, int y, int w, int h, GLboolean gameMode,
- GLboolean isSubWindow );
+ GLboolean positionUse, int x, int y,
+ GLboolean sizeUse, int w, int h,
+ GLboolean gameMode, GLboolean isSubWindow );
void fgCloseWindow( SFG_Window* window );
void fgAddToWindowDestroyList ( SFG_Window* window );
void fgCloseWindows ();
}
window->State.NeedToResize = GL_TRUE;
- window->State.Width = fgState.Size.X;
- window->State.Height = fgState.Size.Y;
+ if( ( window->State.Width < 0 ) || ( window->State.Height < 0 ) )
+ {
+ SFG_Window *current_window = fgStructure.CurrentWindow;
+
+ fgSetWindow( window );
+ window->State.Width = glutGet( GLUT_WINDOW_WIDTH );
+ window->State.Height = glutGet( GLUT_WINDOW_HEIGHT );
+ fgSetWindow( current_window );
+ }
ReleaseDC( window->Window.Handle, window->Window.Device );
case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
- case GLUT_INIT_WINDOW_X: return fgState.Position.X ;
- case GLUT_INIT_WINDOW_Y: return fgState.Position.Y ;
- case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.X ;
- case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Y ;
+ case GLUT_INIT_WINDOW_X: return fgState.Position.Use ?
+ fgState.Position.X : -1 ;
+ case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ?
+ fgState.Position.Y : -1 ;
+ case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ?
+ fgState.Size.X : -1 ;
+ case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ?
+ fgState.Size.Y : -1 ;
case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
#if TARGET_HOST_POSIX_X11
* If parent is set to NULL, the window created will be a topmost one.
*/
SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
- int x, int y, int w, int h,
+ GLboolean positionUse, int x, int y,
+ GLboolean sizeUse, int w, int h,
GLboolean gameMode, GLboolean isMenu )
{
/* Have the window object created */
* Open the window now. The fgOpenWindow() function is system
* dependant, and resides in freeglut_window.c. Uses fgState.
*/
- fgOpenWindow( window, title, x, y, w, h, gameMode,
+ fgOpenWindow( window, title, positionUse, x, y, sizeUse, w, h, gameMode,
(GLboolean)(parent ? GL_TRUE : GL_FALSE) );
return window;
/* Create a window for the menu to reside in. */
- fgCreateWindow( NULL, "freeglut menu", x, y, w, h, GL_FALSE, GL_TRUE );
+ fgCreateWindow( NULL, "freeglut menu", GL_TRUE, x, y, GL_TRUE, w, h,
+ GL_FALSE, GL_TRUE );
menu->Window = fgStructure.CurrentWindow;
glutDisplayFunc( fgDisplayMenu );
* to the freeglut structure. OpenGL context is created here.
*/
void fgOpenWindow( SFG_Window* window, const char* title,
- int x, int y, int w, int h,
+ GLboolean positionUse, int x, int y,
+ GLboolean sizeUse, int w, int h,
GLboolean gameMode, GLboolean isSubWindow )
{
#if TARGET_HOST_POSIX_X11
mask |= CWOverrideRedirect;
}
+ if( ! positionUse )
+ x = y = -1; /* default window position */
+ if( ! sizeUse )
+ w = h = 300; /* default window size */
+
window->Window.Handle = XCreateWindow(
fgDisplay.Display,
window->Parent == NULL ? fgDisplay.RootWindow :
window->State.Visible = GL_TRUE;
sizeHints.flags = 0;
- if ( fgState.Position.Use )
+ if ( positionUse )
sizeHints.flags |= USPosition;
- if ( fgState.Size.Use )
+ if ( sizeUse )
sizeHints.flags |= USSize;
/*
}
else
{
+ int worig = w, horig = h;
+
#if !defined(_WIN32_WCE)
if ( ( ! isSubWindow ) && ( ! window->IsMenu ) )
{
}
#endif /* defined(_WIN32_WCE) */
- if( ! fgState.Position.Use )
+ if( ! positionUse )
{
x = CW_USEDEFAULT;
y = CW_USEDEFAULT;
}
- if( ! fgState.Size.Use )
+ /* setting State.Width/Height to call resize callback later */
+ if( ! sizeUse )
+ {
+ if( ! window->IsMenu )
+ {
+ w = CW_USEDEFAULT;
+ h = CW_USEDEFAULT;
+ }
+ else /* fail safe - Windows can make a window of size (0, 0) */
+ w = h = 300; /* default window size */
+ window->State.Width = window->State.Height = -1;
+ }
+ else
{
- w = CW_USEDEFAULT;
- h = CW_USEDEFAULT;
+ window->State.Width = worig;
+ window->State.Height = horig;
}
/*
*/
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" );
- return fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
- fgState.Size.X, fgState.Size.Y, GL_FALSE,
- GL_FALSE )->ID;
+ 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;
}
/*
h = -h ;
}
- window = fgCreateWindow( parent, "", x, y, 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;