* Setup the pixel format for a Win32 window
*/
#if TARGET_HOST_WIN32
-gboolean fgSetupPixelFormat( SFG_Window* window, gboolean checkOnly )
+GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly )
{
PIXELFORMATDESCRIPTOR* ppfd, pfd;
- gint flags, pixelformat;
+ int flags, pixelformat;
/*
* Check if the window seems valid
pfd.cAccumGreenBits = 0;
pfd.cAccumBlueBits = 0;
pfd.cAccumAlphaBits = 0;
+#if 0
pfd.cDepthBits = 32;
pfd.cStencilBits = 0;
+#else
+ pfd.cDepthBits = 24;
+ pfd.cStencilBits = 8;
+#endif
pfd.cAuxBuffers = 0;
pfd.iLayerType = PFD_MAIN_PLANE;
pfd.bReserved = 0;
* Opens a window. Requires a SFG_Window object created and attached
* 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 gameMode )
+void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, int h, GLboolean gameMode, int isSubWindow )
{
#if TARGET_HOST_UNIX_X11
XSetWindowAttributes winAttr;
* This might speed up message processing. Is that true?
*/
winAttr.event_mask = StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
- ButtonPressMask | ButtonReleaseMask | KeyPressMask |
+ ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
PointerMotionMask | ButtonMotionMask;
winAttr.background_pixmap = None;
*/
sizeHints.flags = 0;
- sizeHints.flags |= (fgState.Position.Use == TRUE) ? USPosition : PPosition;
- sizeHints.flags |= (fgState.Size.Use == TRUE) ? USSize : PSize;
+ if (fgState.Position.Use == TRUE) sizeHints.flags |= USPosition;
+ if (fgState.Size.Use == TRUE) sizeHints.flags |= USSize;
/*
* Fill in the size hints values now (the x, y, width and height
XMapWindow( fgDisplay.Display, window->Window.Handle );
/*
- * This somehow fixes the glutGet() GLUT_WINDOW_X and GLUT_WINDOW_Y problem...
- */
- XMoveWindow( fgDisplay.Display, window->Window.Handle, x, y );
-
- /*
* In game mode, move the viewport a bit to hide the decorations.
* This code depends on the XFree86 video mode extensions.
*/
if( gameMode == TRUE )
{
+ /*
+ * This somehow fixes the glutGet() GLUT_WINDOW_X and GLUT_WINDOW_Y problem...
+ */
+ XMoveWindow( fgDisplay.Display, window->Window.Handle, x, y );
+
# ifdef X_XF86VidModeSetViewPort
/*
#elif TARGET_HOST_WIN32
WNDCLASS wc;
- gint flags;
+ int flags;
ATOM atom;
- HWND hWnd;
freeglut_assert_ready;
* Grab the window class we have registered on glutInit():
*/
atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
- g_assert( atom != 0 );
+ assert( atom != 0 );
if( gameMode == FALSE )
{
+ if ( !isSubWindow )
+ {
/*
* Update the window position and dimensions, taking account of window decorations
*/
- x -= (GetSystemMetrics( SM_CXSIZEFRAME ) - 1);
- y -= (GetSystemMetrics( SM_CYSIZEFRAME ) - 1);
- w += (GetSystemMetrics( SM_CXSIZEFRAME ) - 1)*2;
- h += (GetSystemMetrics( SM_CYSIZEFRAME ) - 1)*2 + GetSystemMetrics( SM_CYCAPTION );
- /*
+ x -= (GetSystemMetrics( SM_CXSIZEFRAME ) );
+ y -= (GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) );
+ if ( y < 0 ) y = 0 ;
+ w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
+ h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION );
+ }
+
+ /*
* Check if the user wants us to use the default position/size
*/
if( fgState.Position.Use == FALSE ) { x = CW_USEDEFAULT; y = CW_USEDEFAULT; }
/*
* In game mode, the story is a little bit different...
*/
- g_assert( window->Parent == NULL );
+ assert( window->Parent == NULL );
/*
* Set the window creation flags appropriately to make the window entirely visible:
/*
* Make sure window was created
*/
- g_assert( window->Window.Handle != NULL );
+ assert( window->Window.Handle != NULL );
/*
* Show and update the main window. Hide the mouse cursor.
int FGAPIENTRY glutCreateWindow( const char* title )
{
/*
- * Create a new window and return it's unique ID number
+ * Create a new window and return its unique ID number
*/
return( fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
fgState.Size.X, fgState.Size.Y, FALSE )->ID );
}
/*
- * Destroys a window and all of it's subwindows
+ * Destroys a window and all of its subwindows
*/
void FGAPIENTRY glutDestroyWindow( int windowID )
{
* There is a function that performs all needed steps
* defined in freeglut_structure.c. Let's use it:
*/
- fgDestroyWindow( window, TRUE );
+ fgAddToWindowDestroyList( window, TRUE );
}
/*
#elif TARGET_HOST_WIN32
{
RECT winRect;
+ int x, y ;
/*
* First off, grab the current window's position
*/
GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
+ x = winRect.left ;
+ y = winRect.top ;
+
+ if ( fgStructure.Window->Parent == NULL ) /* If this is not a subwindow ... */
+ {
+ /*
+ * Adjust the size of the window to allow for the size of the frame
+ */
+ width += (GetSystemMetrics( SM_CXSIZEFRAME ) - 1)*2;
+ height += (GetSystemMetrics( SM_CYSIZEFRAME ) - 1)*2 + GetSystemMetrics( SM_CYCAPTION );
+ }
+ else /* This is a subwindow, get the parent window's position and subtract it off */
+ {
+ GetWindowRect ( fgStructure.Window->Parent->Window.Handle, &winRect ) ;
+ x -= winRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) ;
+ y -= winRect.top + GetSystemMetrics( SM_CXSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) ;
+ }
/*
* Resize the window, forcing a redraw to happen
*/
MoveWindow(
fgStructure.Window->Window.Handle,
- winRect.left,
- winRect.top,
+ x,
+ y,
width,
height,
TRUE
*/
GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
- /*
+ if ( fgStructure.Window->Parent == NULL ) /* If this is not a subwindow ... */
+ {
+ /*
+ * Adjust the position of the window to allow for the size of the frame
+ */
+ x -= (GetSystemMetrics( SM_CXSIZEFRAME ) - 1);
+ y -= (GetSystemMetrics( SM_CYSIZEFRAME ) - 1 + GetSystemMetrics( SM_CYCAPTION ));
+ if ( y < 0 ) y = 0 ;
+ }
+
+ /*
* Reposition the window, forcing a redraw to happen
*/
MoveWindow(