X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_window.c;h=69afdf8641a0e188896dbe8b9d00880d2645bd98;hb=fe573d6af98de430357a7321cd50f5e92e9a2aab;hp=58e95f49c81c8b383a4fad3022f70d68ac988a57;hpb=dbf924cc8664bbce41704d2af2df68627f2eab54;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 58e95f4..69afdf8 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -29,8 +29,10 @@ #include "freeglut_internal.h" #if defined(_WIN32_WCE) -#include -#pragma comment( lib, "Aygshell.lib" ) /* library pragmas are bad */ +# include +# ifdef FREEGLUT_LIB_PRAGMAS +# pragma comment( lib, "Aygshell.lib" ) +# endif static wchar_t* fghWstrFromStr(const char* str) { @@ -42,7 +44,6 @@ static wchar_t* fghWstrFromStr(const char* str) return wstr; } - #endif /* defined(_WIN32_WCE) */ /* @@ -172,10 +173,10 @@ XVisualInfo* fgChooseVisual( void ) * Setup the pixel format for a Win32 window */ #if TARGET_HOST_MS_WINDOWS -/* WRONG-- FIXME */ /* The following include file is available from SGI but is not standard: * #include * So we copy the necessary parts out of it. + * XXX: should local definitions for extensions be put in a separate include file? */ typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); @@ -399,7 +400,8 @@ void fgSetWindow ( SFG_Window *window ) * 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 @@ -433,10 +435,12 @@ void fgOpenWindow( SFG_Window* window, const char* title, fgState.DisplayMode &= ~GLUT_DOUBLE; } - /* - * GLUT also checks for multi-sampling, but I don't see that - * anywhere else in FREEGLUT so I won't bother with it for the moment. - */ + if( fgState.DisplayMode & GLUT_MULTISAMPLE ) + { + fgState.DisplayMode &= ~GLUT_MULTISAMPLE ; + window->Window.VisualInfo = fgChooseVisual( ); + fgState.DisplayMode |= GLUT_MULTISAMPLE; + } } FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.VisualInfo != NULL, @@ -474,6 +478,11 @@ void fgOpenWindow( SFG_Window* window, const char* title, 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 : @@ -546,9 +555,9 @@ void fgOpenWindow( SFG_Window* window, const char* title, 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; /* @@ -619,6 +628,8 @@ void fgOpenWindow( SFG_Window* window, const char* title, } else { + int worig = w, horig = h; + #if !defined(_WIN32_WCE) if ( ( ! isSubWindow ) && ( ! window->IsMenu ) ) { @@ -633,15 +644,27 @@ void fgOpenWindow( SFG_Window* window, const char* title, } #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; } /* @@ -787,9 +810,10 @@ int FGAPIENTRY glutCreateWindow( const char* title ) */ 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; } /* @@ -830,7 +854,7 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h ) 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;