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() -- Check when default position and size is {-1,-1}
45 * glutCreateSubWindow() -- Check 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 #define BUFFER_SIZES 6
70 int bufferSize[BUFFER_SIZES] = { 16, 12, 8, 4, 2, 1 };
71 GLboolean wantIndexedMode = FALSE;
76 * First we have to process the display mode settings...
79 * Why is there a semi-colon in this #define? The code
80 * that uses the macro seems to always add more semicolons...
82 #define ATTRIB(a) attributes[where++]=a;
83 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
85 if( fgState.DisplayMode & GLUT_INDEX )
87 ATTRIB_VAL( GLX_BUFFER_SIZE, 8 );
88 wantIndexedMode = TRUE;
93 ATTRIB_VAL( GLX_RED_SIZE, 1 );
94 ATTRIB_VAL( GLX_GREEN_SIZE, 1 );
95 ATTRIB_VAL( GLX_BLUE_SIZE, 1 );
96 if( fgState.DisplayMode & GLUT_ALPHA )
97 ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
100 if( fgState.DisplayMode & GLUT_DOUBLE )
101 ATTRIB( GLX_DOUBLEBUFFER );
103 if( fgState.DisplayMode & GLUT_STEREO )
104 ATTRIB( GLX_STEREO );
106 if( fgState.DisplayMode & GLUT_DEPTH )
107 ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
109 if( fgState.DisplayMode & GLUT_STENCIL )
110 ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
112 if( fgState.DisplayMode & GLUT_ACCUM )
114 ATTRIB_VAL( GLX_ACCUM_RED_SIZE, 1 );
115 ATTRIB_VAL( GLX_ACCUM_GREEN_SIZE, 1 );
116 ATTRIB_VAL( GLX_ACCUM_BLUE_SIZE, 1 );
117 if( fgState.DisplayMode & GLUT_ALPHA )
118 ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
122 * Push a null at the end of the list
126 if( wantIndexedMode == FALSE )
127 return glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
131 XVisualInfo* visualInfo;
135 * In indexed mode, we need to check how many bits of depth can we
136 * achieve. We do this by trying each possibility from the list
137 * given in the {bufferSize} array. If we match, we return to caller.
139 for( i=0; i<BUFFER_SIZES; i++ )
141 attributes[ 1 ] = bufferSize[ i ];
142 visualInfo = glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
144 if( visualInfo != NULL )
153 * Setup the pixel format for a Win32 window
155 #if TARGET_HOST_WIN32
156 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
157 unsigned char layer_type )
159 PIXELFORMATDESCRIPTOR* ppfd, pfd;
160 int flags, pixelformat;
162 freeglut_return_val_if_fail( window != NULL, 0 );
163 flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
164 if( fgState.DisplayMode & GLUT_DOUBLE )
165 flags |= PFD_DOUBLEBUFFER;
167 #pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
170 * Specify which pixel format do we opt for...
172 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
175 pfd.iPixelType = PFD_TYPE_RGBA;
186 pfd.cAccumRedBits = 0;
187 pfd.cAccumGreenBits = 0;
188 pfd.cAccumBlueBits = 0;
189 pfd.cAccumAlphaBits = 0;
192 pfd.cStencilBits = 0;
195 pfd.cStencilBits = 8;
198 pfd.iLayerType = layer_type;
201 pfd.dwVisibleMask = 0;
202 pfd.dwDamageMask = 0;
204 pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL );
207 pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
208 if( pixelformat == 0 )
213 return SetPixelFormat( window->Window.Device, pixelformat, ppfd );
218 * Sets the OpenGL context and the fgStructure "Current Window" pointer to
219 * the window structure passed in.
221 void fgSetWindow ( SFG_Window *window )
223 #if TARGET_HOST_UNIX_X11
227 window->Window.Handle,
228 window->Window.Context
230 #elif TARGET_HOST_WIN32
231 if( fgStructure.Window )
232 ReleaseDC( fgStructure.Window->Window.Handle,
233 fgStructure.Window->Window.Device );
237 window->Window.Device = GetDC( window->Window.Handle );
239 window->Window.Device,
240 window->Window.Context
244 fgStructure.Window = window;
249 * Opens a window. Requires a SFG_Window object created and attached
250 * to the freeglut structure. OpenGL context is created here.
252 void fgOpenWindow( SFG_Window* window, const char* title,
253 int x, int y, int w, int h,
254 GLboolean gameMode, int isSubWindow )
256 #if TARGET_HOST_UNIX_X11
257 XSetWindowAttributes winAttr;
258 XTextProperty textProperty;
259 XSizeHints sizeHints;
263 freeglut_assert_ready;
266 * XXX fgChooseVisual() is a common part of all three.
267 * XXX With a little thought, we should be able to greatly
270 if ( !fgState.BuildingAMenu )
271 window->Window.VisualInfo = fgChooseVisual();
272 else if ( fgStructure.MenuContext )
273 window->Window.VisualInfo = fgChooseVisual();
276 unsigned int current_DisplayMode = fgState.DisplayMode ;
277 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
278 window->Window.VisualInfo = fgChooseVisual();
279 fgState.DisplayMode = current_DisplayMode ;
282 if ( ! window->Window.VisualInfo )
285 * The "fgChooseVisual" returned a null meaning that the visual
286 * context is not available.
287 * Try a couple of variations to see if they will work.
289 if ( ! ( fgState.DisplayMode & GLUT_DOUBLE ) )
291 fgState.DisplayMode |= GLUT_DOUBLE ;
292 window->Window.VisualInfo = fgChooseVisual();
293 fgState.DisplayMode &= ~GLUT_DOUBLE ;
297 * GLUT also checks for multi-sampling, but I don't see that
298 * anywhere else in FREEGLUT so I won't bother with it for the moment.
302 assert( window->Window.VisualInfo != NULL );
305 * XXX HINT: the masks should be updated when adding/removing callbacks.
306 * XXX This might speed up message processing. Is that true?
308 * XXX A: Not appreciably, but it WILL make it easier to debug.
309 * XXX Try tracing old GLUT and try tracing freeglut. Old GLUT
310 * XXX turns off events that it doesn't need and is a whole lot
311 * XXX more pleasant to trace. (Hint: Think mouse-motion!)
313 * XXX It may make a difference in networked environments or on
314 * XXX some very slow systems, but I think that that is secondary
315 * XXX to making debugging easier.
317 winAttr.event_mask = StructureNotifyMask | SubstructureNotifyMask |
318 ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask |
319 KeyRelease | VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
320 PointerMotionMask | ButtonMotionMask;
321 winAttr.background_pixmap = None;
322 winAttr.background_pixel = 0;
323 winAttr.border_pixel = 0;
325 winAttr.colormap = XCreateColormap(
326 fgDisplay.Display, fgDisplay.RootWindow,
327 window->Window.VisualInfo->visual, AllocNone
330 mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
332 if ( fgState.BuildingAMenu )
334 winAttr.override_redirect = True;
335 mask |= CWOverrideRedirect;
338 window->Window.Handle = XCreateWindow(
340 window->Parent == NULL ? fgDisplay.RootWindow :
341 window->Parent->Window.Handle,
343 window->Window.VisualInfo->depth, InputOutput,
344 window->Window.VisualInfo->visual, mask,
349 * The GLX context creation, possibly trying the direct context rendering
350 * or else use the current context if the user has so specified
352 if ( fgState.BuildingAMenu )
355 * If there isn't already an OpenGL rendering context for menu
358 if ( !fgStructure.MenuContext )
360 fgStructure.MenuContext =
361 (SFG_MenuContext *)malloc ( sizeof(SFG_MenuContext) );
362 fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
363 fgStructure.MenuContext->Context = glXCreateContext(
364 fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
365 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
369 /* window->Window.Context = fgStructure.MenuContext->Context ; */
370 window->Window.Context = glXCreateContext(
371 fgDisplay.Display, window->Window.VisualInfo,
372 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
375 else if ( fgState.UseCurrentContext == TRUE )
377 window->Window.Context = glXGetCurrentContext();
379 if ( ! window->Window.Context )
380 window->Window.Context = glXCreateContext(
381 fgDisplay.Display, window->Window.VisualInfo,
382 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
386 window->Window.Context = glXCreateContext(
387 fgDisplay.Display, window->Window.VisualInfo,
388 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
391 if( fgState.ForceDirectContext &&
392 !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
393 fgError( "unable to force direct context rendering for window '%s'",
398 window->Window.Handle,
399 window->Window.Context
403 * XXX Assume the new window is visible by default
404 * XXX Is this a safe assumption?
406 window->State.Visible = TRUE;
409 if (fgState.Position.Use == TRUE)
410 sizeHints.flags |= USPosition;
411 if (fgState.Size.Use == TRUE)
412 sizeHints.flags |= USSize;
415 * Fill in the size hints values now (the x, y, width and height
416 * settings are obsolote, are there any more WMs that support them?)
417 * Unless the X servers actually stop supporting these, we should
418 * continue to fill them in. It is *not* our place to tell the user
419 * that they should replace a window manager that they like, and which
420 * works, just because *we* think that it's not "modern" enough.
425 sizeHints.height = h;
427 wmHints.flags = StateHint;
428 wmHints.initial_state =
429 (fgState.ForceIconic == FALSE) ? NormalState : IconicState;
432 * Prepare the window and iconified window names...
434 XStringListToTextProperty( (char **) &title, 1, &textProperty );
438 window->Window.Handle,
447 XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
448 &fgDisplay.DeleteWindow, 1 );
449 XMapWindow( fgDisplay.Display, window->Window.Handle );
451 #elif TARGET_HOST_WIN32
457 freeglut_assert_ready;
460 * Grab the window class we have registered on glutInit():
462 atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
465 if( gameMode != FALSE )
467 assert( window->Parent == NULL );
470 * Set the window creation flags appropriately to make the window
473 flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
477 if ( ( !isSubWindow ) && ( ! window->IsMenu ) )
480 * Update the window dimensions, taking account of window
481 * decorations. "freeglut" is to create the window with the
482 * outside of its border at (x,y) and with dimensions (w,h).
484 w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
485 h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 +
486 GetSystemMetrics( SM_CYCAPTION );
489 if( fgState.Position.Use == FALSE )
494 if( fgState.Size.Use == FALSE )
501 * There's a small difference between creating the top, child and
504 flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
506 if ( window->IsMenu )
508 else if( window->Parent == NULL )
509 flags |= WS_OVERLAPPEDWINDOW;
514 window->Window.Handle = CreateWindow(
519 (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
524 if( !( window->Window.Handle ) )
525 fgError( "Failed to create a window (%s)!", title );
527 ShowWindow( window->Window.Handle,
528 fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
529 UpdateWindow( window->Window.Handle );
530 ShowCursor( TRUE ); /* XXX Old comments say "hide cusror"! */
534 window->Window.DoubleBuffered =
535 ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
537 if ( ! window->Window.DoubleBuffered )
539 glDrawBuffer ( GL_FRONT ) ;
540 glReadBuffer ( GL_FRONT ) ;
542 fgSetWindow( window );
546 * Closes a window, destroying the frame and OpenGL context
548 void fgCloseWindow( SFG_Window* window )
550 freeglut_assert_ready;
552 #if TARGET_HOST_UNIX_X11
554 glXDestroyContext( fgDisplay.Display, window->Window.Context );
555 XDestroyWindow( fgDisplay.Display, window->Window.Handle );
556 XFlush( fgDisplay.Display );
558 #elif TARGET_HOST_WIN32
561 window->Window.Handle,
571 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
574 * Creates a new top-level freeglut window
576 int FGAPIENTRY glutCreateWindow( const char* title )
579 * Create a new window and return its unique ID number
581 return( fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
582 fgState.Size.X, fgState.Size.Y, FALSE )->ID );
586 * This function creates a sub window.
588 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
590 SFG_Window* window = NULL;
591 SFG_Window* parent = NULL;
593 freeglut_assert_ready;
596 * Find a parent to the newly created window...
598 parent = fgWindowByID( parentID );
601 * Fail if the parent has not been found
603 freeglut_return_val_if_fail( parent != NULL, 0 );
606 * Create the new window
608 window = fgCreateWindow( parent, "", x, y, w, h, FALSE );
611 * Return the new window's ID
613 return( window->ID );
617 * Destroys a window and all of its subwindows
619 void FGAPIENTRY glutDestroyWindow( int windowID )
621 fgExecutionState ExecState = fgState.ExecState ;
624 * Grab the freeglut window pointer from the structure
626 SFG_Window* window = fgWindowByID( windowID );
627 freeglut_return_if_fail( window != NULL );
630 * There is a function that performs all needed steps
631 * defined in freeglut_structure.c. Let's use it:
633 fgAddToWindowDestroyList( window, TRUE );
636 * Since the "fgAddToWindowDestroyList" function could easily have set the "ExecState"
637 * to stop, let's set it back to what it was.
639 fgState.ExecState = ExecState ;
643 * This function selects the current window
645 void FGAPIENTRY glutSetWindow( int ID )
647 SFG_Window* window = NULL;
650 * Make sure we don't get called too early
652 freeglut_assert_ready;
655 * Be wise. Be wise. Be wise. Be quick.
657 if( fgStructure.Window != NULL )
658 if( fgStructure.Window->ID == ID )
662 * Now we are sure there is sense in looking for the window
664 window = fgWindowByID( ID );
667 * In the case of an utter failure...
672 * ...issue a warning message and keep rolling on
674 fgWarning( "glutSetWindow(): window ID %i not found!", ID );
678 fgSetWindow ( window ) ;
682 * This function returns the ID number of the current window, 0 if none exists
684 int FGAPIENTRY glutGetWindow( void )
686 freeglut_assert_ready;
689 * Do we have a current window selected?
691 if( fgStructure.Window == NULL )
694 * Nope. Return zero to mark the state.
700 * Otherwise, return the ID of the current window
702 return( fgStructure.Window->ID );
706 * This function makes the current window visible
708 void FGAPIENTRY glutShowWindow( void )
710 freeglut_assert_ready; freeglut_assert_window;
712 #if TARGET_HOST_UNIX_X11
714 * Showing the window is done via mapping under X
716 XMapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
717 XFlush( fgDisplay.Display );
719 #elif TARGET_HOST_WIN32
721 * Restore the window's originial position and size
723 ShowWindow( fgStructure.Window->Window.Handle, SW_SHOW );
728 * Since the window is visible, we need to redisplay it ...
730 fgStructure.Window->State.Redisplay = TRUE;
735 * This function hides the current window
737 void FGAPIENTRY glutHideWindow( void )
739 freeglut_assert_ready; freeglut_assert_window;
741 #if TARGET_HOST_UNIX_X11
743 * The way we hide a window depends on if we're dealing
744 * with a top-level or children one...
746 if( fgStructure.Window->Parent == NULL )
749 * This is a top-level window
751 XWithdrawWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
756 * Nope, it's a child window
758 XUnmapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
762 * Flush the X state now
764 XFlush( fgDisplay.Display );
766 #elif TARGET_HOST_WIN32
770 ShowWindow( fgStructure.Window->Window.Handle, SW_HIDE );
775 * Since the window is hidden, we don't need to redisplay it ...
777 fgStructure.Window->State.Redisplay = FALSE;
781 * Iconify the current window (top-level windows only)
783 void FGAPIENTRY glutIconifyWindow( void )
785 freeglut_assert_ready; freeglut_assert_window;
787 #if TARGET_HOST_UNIX_X11
789 * Iconify the window and flush the X state
791 XIconifyWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
792 XFlush( fgDisplay.Display );
794 #elif TARGET_HOST_WIN32
796 * Minimize the current window (this should be the same as X window iconifying)
798 ShowWindow( fgStructure.Window->Window.Handle, SW_MINIMIZE );
803 * Since the window is just an icon, we don't need to redisplay it ...
805 fgStructure.Window->State.Redisplay = FALSE;
810 * Set the current window's title
812 void FGAPIENTRY glutSetWindowTitle( const char* title )
814 freeglut_assert_ready; freeglut_assert_window;
817 * Works only for top-level windows
819 if( fgStructure.Window->Parent != NULL )
822 #if TARGET_HOST_UNIX_X11
827 * Prepare the text properties
829 text.value = (unsigned char *) title;
830 text.encoding = XA_STRING;
832 text.nitems = strlen( title );
839 fgStructure.Window->Window.Handle,
844 * Have the X display state flushed
846 XFlush( fgDisplay.Display );
849 #elif TARGET_HOST_WIN32
851 * This seems to be a bit easier under Win32
853 SetWindowText( fgStructure.Window->Window.Handle, title );
859 * Set the current window's iconified title
861 void FGAPIENTRY glutSetIconTitle( const char* title )
863 freeglut_assert_ready; freeglut_assert_window;
866 * Works only for top-level windows
868 if( fgStructure.Window->Parent != NULL )
871 #if TARGET_HOST_UNIX_X11
876 * Prepare the text properties
878 text.value = (unsigned char *) title;
879 text.encoding = XA_STRING;
881 text.nitems = strlen( title );
888 fgStructure.Window->Window.Handle,
893 * Have the X display state flushed
895 XFlush( fgDisplay.Display );
898 #elif TARGET_HOST_WIN32
900 * This seems to be a bit easier under Win32
902 SetWindowText( fgStructure.Window->Window.Handle, title );
908 * Change the current window's size
910 void FGAPIENTRY glutReshapeWindow( int width, int height )
912 freeglut_assert_ready; freeglut_assert_window;
914 #if TARGET_HOST_UNIX_X11
916 * Resize the window and flush the X state
918 XResizeWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, width, height );
919 XFlush( fgDisplay.Display );
921 #elif TARGET_HOST_WIN32
927 * First off, grab the current window's position
929 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
933 if ( fgStructure.Window->Parent == NULL ) /* If this is not a subwindow ... */
936 * Adjust the size of the window to allow for the size of the frame, if we are not a menu
938 if ( ! fgStructure.Window->IsMenu )
940 width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
941 height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION );
944 else /* This is a subwindow, get the parent window's position and subtract it off */
946 GetWindowRect ( fgStructure.Window->Parent->Window.Handle, &winRect ) ;
947 x -= winRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) ;
948 y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) ;
952 * Resize the window, forcing a redraw to happen
955 fgStructure.Window->Window.Handle,
967 * Change the current window's position
969 void FGAPIENTRY glutPositionWindow( int x, int y )
971 freeglut_assert_ready; freeglut_assert_window;
973 #if TARGET_HOST_UNIX_X11
975 * Reposition the window and flush the X state
977 XMoveWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, x, y );
978 XFlush( fgDisplay.Display );
980 #elif TARGET_HOST_WIN32
985 * First off, grab the current window's position
987 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
990 * Reposition the window, forcing a redraw to happen
993 fgStructure.Window->Window.Handle,
996 winRect.right - winRect.left,
997 winRect.bottom - winRect.top,
1006 * Lowers the current window (by Z order change)
1008 void FGAPIENTRY glutPushWindow( void )
1010 freeglut_assert_ready; freeglut_assert_window;
1012 #if TARGET_HOST_UNIX_X11
1014 * Lower the current window
1016 XLowerWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
1018 #elif TARGET_HOST_WIN32
1020 * Set the new window's Z position, not affecting the rest of the settings:
1023 fgStructure.Window->Window.Handle,
1026 SWP_NOSIZE | SWP_NOMOVE
1033 * Raises the current window (by Z order change)
1035 void FGAPIENTRY glutPopWindow( void )
1037 freeglut_assert_ready; freeglut_assert_window;
1039 #if TARGET_HOST_UNIX_X11
1041 * Raise the current window
1043 XRaiseWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
1045 #elif TARGET_HOST_WIN32
1047 * Set the new window's Z position, not affecting the rest of the settings:
1050 fgStructure.Window->Window.Handle,
1053 SWP_NOSIZE | SWP_NOMOVE
1060 * Resize the current window so that it fits the whole screen
1062 void FGAPIENTRY glutFullScreen( void )
1064 freeglut_assert_ready; freeglut_assert_window;
1066 #if TARGET_HOST_UNIX_X11
1073 fgStructure.Window->Window.Handle,
1075 fgDisplay.ScreenWidth,
1076 fgDisplay.ScreenHeight
1078 XFlush( fgDisplay.Display );
1080 XTranslateCoordinates(
1082 fgStructure.Window->Window.Handle,
1083 fgDisplay.RootWindow,
1091 fgStructure.Window->Window.Handle,
1094 XFlush( fgDisplay.Display );
1097 #elif TARGET_HOST_WIN32
1099 fgStructure.Window->Window.Handle,
1101 fgDisplay.ScreenWidth,
1102 fgDisplay.ScreenHeight,
1109 * A.Donev: Set and retrieve the window's user data
1111 void* FGAPIENTRY glutGetWindowData( void )
1113 return(fgStructure.Window->UserData);
1116 void FGAPIENTRY glutSetWindowData(void* data)
1118 fgStructure.Window->UserData=data;
1121 /*** END OF FILE ***/