4 * Window management methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #define G_LOG_DOMAIN "freeglut-window"
34 #include "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
38 * TODO BEFORE THE STABLE RELEASE:
40 * fgChooseVisual() -- OK, but what about glutInitDisplayString()?
41 * fgSetupPixelFormat -- ignores the display mode settings
42 * fgOpenWindow() -- check the Win32 version, -iconic handling!
43 * fgCloseWindow() -- check the Win32 version
44 * glutCreateWindow() -- see what happens when default position and size is {-1,-1}
45 * glutCreateSubWindow() -- see what happens when default position and size is {-1,-1}
46 * glutDestroyWindow() -- check the Win32 version
47 * glutSetWindow() -- check the Win32 version
48 * glutGetWindow() -- OK
49 * glutSetWindowTitle() -- check the Win32 version
50 * glutSetIconTitle() -- check the Win32 version
51 * glutShowWindow() -- check the Win32 version
52 * glutHideWindow() -- check the Win32 version
53 * glutIconifyWindow() -- check the Win32 version
54 * glutReshapeWindow() -- check the Win32 version
55 * glutPositionWindow() -- check the Win32 version
56 * glutPushWindow() -- check the Win32 version
57 * glutPopWindow() -- check the Win32 version
60 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
63 * Chooses a visual basing on the current display mode settings
65 #if TARGET_HOST_UNIX_X11
67 XVisualInfo* fgChooseVisual( void )
69 int bufferSize[] = { 16, 12, 8, 4, 2, 1 };
70 GLboolean wantIndexedMode = FALSE;
75 * First we have to process the display mode settings...
77 # define ATTRIB(a) attributes[where++]=a;
80 * Decide if we want a true or indexed color visual:
82 if( !(fgState.DisplayMode & GLUT_INDEX) )
85 * We are sure that there will be R, B and B components requested:
88 ATTRIB( GLX_RED_SIZE ); ATTRIB( 1 );
89 ATTRIB( GLX_GREEN_SIZE ); ATTRIB( 1 );
90 ATTRIB( GLX_BLUE_SIZE ); ATTRIB( 1 );
93 * Check if the A component is required, too:
95 if( fgState.DisplayMode & GLUT_ALPHA )
97 ATTRIB( GLX_ALPHA_SIZE ); ATTRIB( 1 );
103 * We've got an indexed color request
105 ATTRIB( GLX_BUFFER_SIZE ); ATTRIB( 8 );
108 * Set the 'I want indexed mode' switch
110 wantIndexedMode = TRUE;
114 * We can have double or single buffered contexts created
116 if( fgState.DisplayMode & GLUT_DOUBLE )
118 ATTRIB( GLX_DOUBLEBUFFER );
122 * Stereoscopy seems a nice thing to have
124 if( fgState.DisplayMode & GLUT_STEREO )
126 ATTRIB( GLX_STEREO );
130 * Depth buffer is almost always required
132 if( fgState.DisplayMode & GLUT_DEPTH )
134 ATTRIB( GLX_DEPTH_SIZE ); ATTRIB( 1 );
140 if( fgState.DisplayMode & GLUT_STENCIL )
142 ATTRIB( GLX_STENCIL_SIZE ); ATTRIB( 1 );
146 * And finally the accumulation buffers
148 if( fgState.DisplayMode & GLUT_ACCUM )
150 ATTRIB( GLX_ACCUM_RED_SIZE ); ATTRIB( 1 );
151 ATTRIB( GLX_ACCUM_GREEN_SIZE ); ATTRIB( 1 );
152 ATTRIB( GLX_ACCUM_BLUE_SIZE ); ATTRIB( 1 );
155 * Check if the A component is required, too:
157 if( fgState.DisplayMode & GLUT_ALPHA )
159 ATTRIB( GLX_ACCUM_ALPHA_SIZE ); ATTRIB( 1 );
164 * Push a null at the end of the list
169 * OKi now, we've got two cases -- RGB(A) and index mode visuals
171 if( wantIndexedMode == FALSE )
174 * The easier one. And more common, too.
176 return( glXChooseVisual( fgDisplay.Display, fgDisplay.Screen, attributes ) );
180 XVisualInfo* visualInfo;
184 * In indexed mode, we need to check how many bits of depth can we achieve
190 * The GLX_BUFFER_SIZE value comes always first, so:
192 attributes[ 1 ] = bufferSize[ i ];
195 * Check if such visual is possible
197 visualInfo = glXChooseVisual( fgDisplay.Display, fgDisplay.Screen, attributes );
200 * The buffer size are sorted in descendant order, so choose the first:
202 if( visualInfo != NULL )
203 return( visualInfo );
207 * If we are still here, it means that the visual info was not found
215 * Setup the pixel format for a Win32 window
217 #if TARGET_HOST_WIN32
218 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, unsigned char layer_type )
220 PIXELFORMATDESCRIPTOR* ppfd, pfd;
221 int flags, pixelformat;
224 * Check if the window seems valid
226 freeglut_return_val_if_fail( window != NULL, 0 );
229 * The pixel format should allow us to draw to the window using OpenGL
231 flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
234 * It might be the case for us to use double buffering
236 if( fgState.DisplayMode & GLUT_DOUBLE )
237 flags |= PFD_DOUBLEBUFFER;
240 * Specify which pixel format do we opt for...
242 # pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
244 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
247 pfd.iPixelType = PFD_TYPE_RGBA;
258 pfd.cAccumRedBits = 0;
259 pfd.cAccumGreenBits = 0;
260 pfd.cAccumBlueBits = 0;
261 pfd.cAccumAlphaBits = 0;
264 pfd.cStencilBits = 0;
267 pfd.cStencilBits = 8;
270 pfd.iLayerType = layer_type;
273 pfd.dwVisibleMask = 0;
274 pfd.dwDamageMask = 0;
277 * Fill in the color bits...
279 pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL );
283 * Choose the pixel format that matches our demand
285 pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
286 if( pixelformat == 0 )
290 * We might have been called to check if the pixel format exists only
296 * Finally, set the window's pixel format
298 return ( SetPixelFormat( window->Window.Device, pixelformat, ppfd ) ) ;
303 * Sets the OpenGL context and the fgStructure "Current Window" pointer to the window
304 * structure passed in.
306 void fgSetWindow ( SFG_Window *window )
308 #if TARGET_HOST_UNIX_X11
310 * Make the selected window's GLX context the current one
314 window->Window.Handle,
315 window->Window.Context
318 #elif TARGET_HOST_WIN32
320 * Release the previous' context's device context
322 if( fgStructure.Window != NULL )
323 ReleaseDC( fgStructure.Window->Window.Handle, fgStructure.Window->Window.Device );
328 * We will care about releasing the device context later
330 window->Window.Device = GetDC( window->Window.Handle );
333 * Set the new current context:
336 window->Window.Device,
337 window->Window.Context
343 * Remember that we have changed the current window state
345 fgStructure.Window = window;
350 * Opens a window. Requires a SFG_Window object created and attached
351 * to the freeglut structure. OpenGL context is created here.
353 void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, int h, GLboolean gameMode, int isSubWindow )
355 #if TARGET_HOST_UNIX_X11
356 XSetWindowAttributes winAttr;
357 XTextProperty textProperty;
358 XSizeHints sizeHints;
362 freeglut_assert_ready;
365 * Here we are upon the stage. Have the visual selected.
367 if ( fgState.BuildingAMenu )
370 * If there isn't already an OpenGL rendering context for menu windows, make one
372 if ( !fgStructure.MenuContext )
374 unsigned int current_DisplayMode = fgState.DisplayMode ;
375 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
376 window->Window.VisualInfo = fgChooseVisual();
377 fgState.DisplayMode = current_DisplayMode ;
380 window->Window.VisualInfo = fgChooseVisual();
383 window->Window.VisualInfo = fgChooseVisual();
385 if ( ! window->Window.VisualInfo )
388 * The "fgChooseVisual" returned a null meaning that the visual context is not available.
389 * Try a couple of variations to see if they will work.
391 if ( ! ( fgState.DisplayMode & GLUT_DOUBLE ) )
394 * Single buffering--try it doubled
396 fgState.DisplayMode |= GLUT_DOUBLE ;
397 window->Window.VisualInfo = fgChooseVisual();
401 * GLUT also checks for multi-sampling, but I don't see that anywhere else in FREEGLUT
402 * so I won't bother with it for the moment.
406 assert( window->Window.VisualInfo != NULL );
409 * Have the windows attributes set
411 * HINT: the masks should be updated when adding/removing callbacks.
412 * This might speed up message processing. Is that true?
414 winAttr.event_mask = StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
415 ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
416 VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
417 PointerMotionMask | ButtonMotionMask;
418 winAttr.background_pixmap = None;
419 winAttr.background_pixel = 0;
420 winAttr.border_pixel = 0;
423 * The color map is required, too
425 winAttr.colormap = XCreateColormap(
426 fgDisplay.Display, fgDisplay.RootWindow,
427 window->Window.VisualInfo->visual, AllocNone
431 * This tells the XCreateWindow() what attributes are we supplying it with
433 mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
436 * If this is a menu window we want the window manager to ignore it.
438 if ( fgState.BuildingAMenu )
440 winAttr.override_redirect = True;
441 mask |= CWOverrideRedirect;
445 * Have the window created now
447 window->Window.Handle = XCreateWindow(
449 window->Parent == NULL ? fgDisplay.RootWindow : window->Parent->Window.Handle,
451 window->Window.VisualInfo->depth, InputOutput,
452 window->Window.VisualInfo->visual, mask,
457 * The GLX context creation, possibly trying the direct context rendering
458 * or else use the current context if the user has so specified
460 if ( fgState.BuildingAMenu )
463 * If there isn't already an OpenGL rendering context for menu windows, make one
465 if ( !fgStructure.MenuContext )
467 fgStructure.MenuContext = (SFG_MenuContext *)malloc ( sizeof(SFG_MenuContext) ) ;
468 fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo ;
469 fgStructure.MenuContext->Context = glXCreateContext(
470 fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
471 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
475 /* window->Window.Context = fgStructure.MenuContext->Context ; */
476 window->Window.Context = glXCreateContext(
477 fgDisplay.Display, window->Window.VisualInfo,
478 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
481 else if ( fgState.UseCurrentContext == TRUE )
483 window->Window.Context = glXGetCurrentContext();
485 if ( ! window->Window.Context )
486 window->Window.Context = glXCreateContext(
487 fgDisplay.Display, window->Window.VisualInfo,
488 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
492 window->Window.Context = glXCreateContext(
493 fgDisplay.Display, window->Window.VisualInfo,
494 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
498 * Make sure the context is direct when the user wants it forced
500 if( fgState.ForceDirectContext && !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
501 fgError( "unable to force direct context rendering for window '%s'", title );
504 * Set the new context as the current one. That's all about the window creation.
508 window->Window.Handle,
509 window->Window.Context
513 * Assume the new window is visible by default
515 window->State.Visible = TRUE;
518 * For the position and size hints -- make sure we are passing valid values
522 if (fgState.Position.Use == TRUE) sizeHints.flags |= USPosition;
523 if (fgState.Size.Use == TRUE) sizeHints.flags |= USSize;
526 * Fill in the size hints values now (the x, y, width and height
527 * settings are obsolote, are there any more WMs that support them?)
529 sizeHints.x = x; sizeHints.y = y;
530 sizeHints.width = w; sizeHints.height = h;
533 * We can have forced all new windows start in iconified state:
535 wmHints.flags = StateHint;
536 wmHints.initial_state = (fgState.ForceIconic == FALSE) ? NormalState : IconicState;
539 * Prepare the window and iconified window names...
541 XStringListToTextProperty( (char **) &title, 1, &textProperty );
544 * Set the window's properties now
548 window->Window.Handle,
559 * Make sure we are informed about the window deletion commands
561 XSetWMProtocols( fgDisplay.Display, window->Window.Handle, &fgDisplay.DeleteWindow, 1 );
564 * Finally, have the window mapped to our display
566 XMapWindow( fgDisplay.Display, window->Window.Handle );
568 #elif TARGET_HOST_WIN32
574 freeglut_assert_ready;
577 * Grab the window class we have registered on glutInit():
579 atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
582 if( gameMode == FALSE )
584 if ( ( !isSubWindow ) && ( ! window->IsMenu ) )
587 * Update the window dimensions, taking account of window decorations.
588 * "freeglut" is to create the window with the outside of its border at (x,y)
589 * and with dimensions (w,h).
591 w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
592 h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION );
596 * Check if the user wants us to use the default position/size
598 if( fgState.Position.Use == FALSE ) { x = CW_USEDEFAULT; y = CW_USEDEFAULT; }
599 if( fgState.Size .Use == FALSE ) { w = CW_USEDEFAULT; h = CW_USEDEFAULT; }
602 * There's a small difference between creating the top, child and game mode windows
604 flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
607 * If we're a menu, set our flags to include WS_POPUP to remove decorations
609 if ( window->IsMenu )
611 else if( window->Parent == NULL )
612 flags |= WS_OVERLAPPEDWINDOW;
619 * In game mode, the story is a little bit different...
621 assert( window->Parent == NULL );
624 * Set the window creation flags appropriately to make the window entirely visible:
626 flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
630 * Create the window now, passing the freeglut window structure as the parameter
632 window->Window.Handle = CreateWindow(
637 (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
644 * Make sure window was created
646 assert( window->Window.Handle != NULL );
649 * Show and update the main window. Hide the mouse cursor.
651 ShowWindow( window->Window.Handle, fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
652 UpdateWindow( window->Window.Handle );
658 * Save the window's single- or double-buffering state
660 window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
663 * If it's not double-buffered, make sure the rendering is done to the front buffer.
665 if ( ! window->Window.DoubleBuffered )
667 glDrawBuffer ( GL_FRONT ) ;
668 glReadBuffer ( GL_FRONT ) ;
672 * Set the newly created window as the current one
674 fgSetWindow( window );
678 * Closes a window, destroying the frame and OpenGL context
680 void fgCloseWindow( SFG_Window* window )
682 freeglut_assert_ready;
684 #if TARGET_HOST_UNIX_X11
686 * As easy as kill bunnies with axes. Destroy the context first:
688 glXDestroyContext( fgDisplay.Display, window->Window.Context );
691 * Then have the window killed:
693 XDestroyWindow( fgDisplay.Display, window->Window.Handle );
696 * Finally, flush the rests down the stream
698 XFlush( fgDisplay.Display );
700 #elif TARGET_HOST_WIN32
702 * Send the WM_CLOSE message to the window now
705 window->Window.Handle,
715 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
718 * Creates a new top-level freeglut window
720 int FGAPIENTRY glutCreateWindow( const char* title )
723 * Create a new window and return its unique ID number
725 return( fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
726 fgState.Size.X, fgState.Size.Y, FALSE )->ID );
730 * This function creates a sub window.
732 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
734 SFG_Window* window = NULL;
735 SFG_Window* parent = NULL;
737 freeglut_assert_ready;
740 * Find a parent to the newly created window...
742 parent = fgWindowByID( parentID );
745 * Fail if the parent has not been found
747 freeglut_return_val_if_fail( parent != NULL, 0 );
750 * Create the new window
752 window = fgCreateWindow( parent, "", x, y, w, h, FALSE );
755 * Return the new window's ID
757 return( window->ID );
761 * Destroys a window and all of its subwindows
763 void FGAPIENTRY glutDestroyWindow( int windowID )
765 fgExecutionState ExecState = fgState.ExecState ;
768 * Grab the freeglut window pointer from the structure
770 SFG_Window* window = fgWindowByID( windowID );
771 freeglut_return_if_fail( window != NULL );
774 * There is a function that performs all needed steps
775 * defined in freeglut_structure.c. Let's use it:
777 fgAddToWindowDestroyList( window, TRUE );
780 * Since the "fgAddToWindowDestroyList" function could easily have set the "ExecState"
781 * to stop, let's set it back to what it was.
783 fgState.ExecState = ExecState ;
787 * This function selects the current window
789 void FGAPIENTRY glutSetWindow( int ID )
791 SFG_Window* window = NULL;
794 * Make sure we don't get called too early
796 freeglut_assert_ready;
799 * Be wise. Be wise. Be wise. Be quick.
801 if( fgStructure.Window != NULL )
802 if( fgStructure.Window->ID == ID )
806 * Now we are sure there is sense in looking for the window
808 window = fgWindowByID( ID );
811 * In the case of an utter failure...
816 * ...issue a warning message and keep rolling on
818 fgWarning( "glutSetWindow(): window ID %i not found!", ID );
822 fgSetWindow ( window ) ;
826 * This function returns the ID number of the current window, 0 if none exists
828 int FGAPIENTRY glutGetWindow( void )
830 freeglut_assert_ready;
833 * Do we have a current window selected?
835 if( fgStructure.Window == NULL )
838 * Nope. Return zero to mark the state.
844 * Otherwise, return the ID of the current window
846 return( fgStructure.Window->ID );
850 * This function makes the current window visible
852 void FGAPIENTRY glutShowWindow( void )
854 freeglut_assert_ready; freeglut_assert_window;
856 #if TARGET_HOST_UNIX_X11
858 * Showing the window is done via mapping under X
860 XMapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
861 XFlush( fgDisplay.Display );
863 #elif TARGET_HOST_WIN32
865 * Restore the window's originial position and size
867 ShowWindow( fgStructure.Window->Window.Handle, SW_SHOW );
872 * Since the window is visible, we need to redisplay it ...
874 fgStructure.Window->State.Redisplay = TRUE;
879 * This function hides the current window
881 void FGAPIENTRY glutHideWindow( void )
883 freeglut_assert_ready; freeglut_assert_window;
885 #if TARGET_HOST_UNIX_X11
887 * The way we hide a window depends on if we're dealing
888 * with a top-level or children one...
890 if( fgStructure.Window->Parent == NULL )
893 * This is a top-level window
895 XWithdrawWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
900 * Nope, it's a child window
902 XUnmapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
906 * Flush the X state now
908 XFlush( fgDisplay.Display );
910 #elif TARGET_HOST_WIN32
914 ShowWindow( fgStructure.Window->Window.Handle, SW_HIDE );
919 * Since the window is hidden, we don't need to redisplay it ...
921 fgStructure.Window->State.Redisplay = FALSE;
925 * Iconify the current window (top-level windows only)
927 void FGAPIENTRY glutIconifyWindow( void )
929 freeglut_assert_ready; freeglut_assert_window;
931 #if TARGET_HOST_UNIX_X11
933 * Iconify the window and flush the X state
935 XIconifyWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
936 XFlush( fgDisplay.Display );
938 #elif TARGET_HOST_WIN32
940 * Minimize the current window (this should be the same as X window iconifying)
942 ShowWindow( fgStructure.Window->Window.Handle, SW_MINIMIZE );
947 * Since the window is just an icon, we don't need to redisplay it ...
949 fgStructure.Window->State.Redisplay = FALSE;
954 * Set the current window's title
956 void FGAPIENTRY glutSetWindowTitle( const char* title )
958 freeglut_assert_ready; freeglut_assert_window;
961 * Works only for top-level windows
963 if( fgStructure.Window->Parent != NULL )
966 #if TARGET_HOST_UNIX_X11
971 * Prepare the text properties
973 text.value = (unsigned char *) title;
974 text.encoding = XA_STRING;
976 text.nitems = strlen( title );
983 fgStructure.Window->Window.Handle,
988 * Have the X display state flushed
990 XFlush( fgDisplay.Display );
993 #elif TARGET_HOST_WIN32
995 * This seems to be a bit easier under Win32
997 SetWindowText( fgStructure.Window->Window.Handle, title );
1003 * Set the current window's iconified title
1005 void FGAPIENTRY glutSetIconTitle( const char* title )
1007 freeglut_assert_ready; freeglut_assert_window;
1010 * Works only for top-level windows
1012 if( fgStructure.Window->Parent != NULL )
1015 #if TARGET_HOST_UNIX_X11
1020 * Prepare the text properties
1022 text.value = (unsigned char *) title;
1023 text.encoding = XA_STRING;
1025 text.nitems = strlen( title );
1032 fgStructure.Window->Window.Handle,
1037 * Have the X display state flushed
1039 XFlush( fgDisplay.Display );
1042 #elif TARGET_HOST_WIN32
1044 * This seems to be a bit easier under Win32
1046 SetWindowText( fgStructure.Window->Window.Handle, title );
1052 * Change the current window's size
1054 void FGAPIENTRY glutReshapeWindow( int width, int height )
1056 freeglut_assert_ready; freeglut_assert_window;
1058 #if TARGET_HOST_UNIX_X11
1060 * Resize the window and flush the X state
1062 XResizeWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, width, height );
1063 XFlush( fgDisplay.Display );
1065 #elif TARGET_HOST_WIN32
1071 * First off, grab the current window's position
1073 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
1077 if ( fgStructure.Window->Parent == NULL ) /* If this is not a subwindow ... */
1080 * Adjust the size of the window to allow for the size of the frame, if we are not a menu
1082 if ( ! fgStructure.Window->IsMenu )
1084 width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
1085 height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION );
1088 else /* This is a subwindow, get the parent window's position and subtract it off */
1090 GetWindowRect ( fgStructure.Window->Parent->Window.Handle, &winRect ) ;
1091 x -= winRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) ;
1092 y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) ;
1096 * Resize the window, forcing a redraw to happen
1099 fgStructure.Window->Window.Handle,
1111 * Change the current window's position
1113 void FGAPIENTRY glutPositionWindow( int x, int y )
1115 freeglut_assert_ready; freeglut_assert_window;
1117 #if TARGET_HOST_UNIX_X11
1119 * Reposition the window and flush the X state
1121 XMoveWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, x, y );
1122 XFlush( fgDisplay.Display );
1124 #elif TARGET_HOST_WIN32
1129 * First off, grab the current window's position
1131 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
1134 * Reposition the window, forcing a redraw to happen
1137 fgStructure.Window->Window.Handle,
1140 winRect.right - winRect.left,
1141 winRect.bottom - winRect.top,
1150 * Lowers the current window (by Z order change)
1152 void FGAPIENTRY glutPushWindow( void )
1154 freeglut_assert_ready; freeglut_assert_window;
1156 #if TARGET_HOST_UNIX_X11
1158 * Lower the current window
1160 XLowerWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
1162 #elif TARGET_HOST_WIN32
1164 * Set the new window's Z position, not affecting the rest of the settings:
1167 fgStructure.Window->Window.Handle,
1170 SWP_NOSIZE | SWP_NOMOVE
1177 * Raises the current window (by Z order change)
1179 void FGAPIENTRY glutPopWindow( void )
1181 freeglut_assert_ready; freeglut_assert_window;
1183 #if TARGET_HOST_UNIX_X11
1185 * Raise the current window
1187 XRaiseWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
1189 #elif TARGET_HOST_WIN32
1191 * Set the new window's Z position, not affecting the rest of the settings:
1194 fgStructure.Window->Window.Handle,
1197 SWP_NOSIZE | SWP_NOMOVE
1204 * Resize the current window so that it fits the whole screen
1206 void FGAPIENTRY glutFullScreen( void )
1208 freeglut_assert_ready; freeglut_assert_window;
1211 * Just have the window repositioned and resized
1213 glutPositionWindow( 0, 0 );
1216 fgDisplay.ScreenWidth,
1217 fgDisplay.ScreenHeight
1222 * A.Donev: Set and retrieve the window's user data
1224 void* FGAPIENTRY glutGetWindowData( void )
1226 return(fgStructure.Window->UserData);
1229 void FGAPIENTRY glutSetWindowData(void* data)
1231 fgStructure.Window->UserData=data;
1234 /*** END OF FILE ***/