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 #include <GL/freeglut.h>
33 #include "freeglut_internal.h"
37 #pragma comment( lib, "Aygshell.lib" )
39 wchar_t* wstr_from_str(const char* str)
41 int i,len=strlen(str);
42 wchar_t* wstr = (wchar_t*)malloc(2*len+2);
50 #endif /* TARGET_HOST_WINCE */
53 * TODO BEFORE THE STABLE RELEASE:
55 * fgChooseVisual() -- OK, but what about glutInitDisplayString()?
56 * fgSetupPixelFormat -- ignores the display mode settings
57 * fgOpenWindow() -- check the Win32 version, -iconic handling!
58 * fgCloseWindow() -- check the Win32 version
59 * glutCreateWindow() -- Check when default position and size is {-1,-1}
60 * glutCreateSubWindow() -- Check when default position and size is {-1,-1}
61 * glutDestroyWindow() -- check the Win32 version
62 * glutSetWindow() -- check the Win32 version
63 * glutGetWindow() -- OK
64 * glutSetWindowTitle() -- check the Win32 version
65 * glutSetIconTitle() -- check the Win32 version
66 * glutShowWindow() -- check the Win32 version
67 * glutHideWindow() -- check the Win32 version
68 * glutIconifyWindow() -- check the Win32 version
69 * glutReshapeWindow() -- check the Win32 version
70 * glutPositionWindow() -- check the Win32 version
71 * glutPushWindow() -- check the Win32 version
72 * glutPopWindow() -- check the Win32 version
75 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
78 * Chooses a visual basing on the current display mode settings
80 #if TARGET_HOST_UNIX_X11
82 XVisualInfo* fgChooseVisual( void )
84 #define BUFFER_SIZES 6
85 int bufferSize[BUFFER_SIZES] = { 16, 12, 8, 4, 2, 1 };
86 GLboolean wantIndexedMode = GL_FALSE;
91 * First we have to process the display mode settings...
94 * XXX Why is there a semi-colon in this #define? The code
95 * XXX that uses the macro seems to always add more semicolons...
97 #define ATTRIB(a) attributes[where++]=a;
98 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
100 if( fgState.DisplayMode & GLUT_INDEX )
102 ATTRIB_VAL( GLX_BUFFER_SIZE, 8 );
103 wantIndexedMode = GL_TRUE;
108 ATTRIB_VAL( GLX_RED_SIZE, 1 );
109 ATTRIB_VAL( GLX_GREEN_SIZE, 1 );
110 ATTRIB_VAL( GLX_BLUE_SIZE, 1 );
111 if( fgState.DisplayMode & GLUT_ALPHA )
112 ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
115 if( fgState.DisplayMode & GLUT_DOUBLE )
116 ATTRIB( GLX_DOUBLEBUFFER );
118 if( fgState.DisplayMode & GLUT_STEREO )
119 ATTRIB( GLX_STEREO );
121 if( fgState.DisplayMode & GLUT_DEPTH )
122 ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
124 if( fgState.DisplayMode & GLUT_STENCIL )
125 ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
127 if( fgState.DisplayMode & GLUT_ACCUM )
129 ATTRIB_VAL( GLX_ACCUM_RED_SIZE, 1 );
130 ATTRIB_VAL( GLX_ACCUM_GREEN_SIZE, 1 );
131 ATTRIB_VAL( GLX_ACCUM_BLUE_SIZE, 1 );
132 if( fgState.DisplayMode & GLUT_ALPHA )
133 ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
137 * Push a null at the end of the list
141 if( ! wantIndexedMode )
142 return glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
146 XVisualInfo* visualInfo;
150 * In indexed mode, we need to check how many bits of depth can we
151 * achieve. We do this by trying each possibility from the list
152 * given in the {bufferSize} array. If we match, we return to caller.
154 for( i=0; i<BUFFER_SIZES; i++ )
156 attributes[ 1 ] = bufferSize[ i ];
157 visualInfo = glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
159 if( visualInfo != NULL )
168 * Setup the pixel format for a Win32 window
170 #if TARGET_HOST_WIN32
171 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
172 unsigned char layer_type )
174 #if TARGET_HOST_WINCE
177 PIXELFORMATDESCRIPTOR* ppfd, pfd;
178 int flags, pixelformat;
180 freeglut_return_val_if_fail( window != NULL, 0 );
181 flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
182 if( fgState.DisplayMode & GLUT_DOUBLE )
183 flags |= PFD_DOUBLEBUFFER;
185 #if defined(_MSC_VER)
186 #pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
190 * Specify which pixel format do we opt for...
192 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
195 pfd.iPixelType = PFD_TYPE_RGBA;
206 pfd.cAccumRedBits = 0;
207 pfd.cAccumGreenBits = 0;
208 pfd.cAccumBlueBits = 0;
209 pfd.cAccumAlphaBits = 0;
212 pfd.cStencilBits = 0;
215 pfd.cStencilBits = 8;
218 pfd.iLayerType = layer_type;
221 pfd.dwVisibleMask = 0;
222 pfd.dwDamageMask = 0;
224 pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL );
227 pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
228 if( pixelformat == 0 )
233 return SetPixelFormat( window->Window.Device, pixelformat, ppfd );
234 #endif /* TARGET_HOST_WINCE */
239 * Sets the OpenGL context and the fgStructure "Current Window" pointer to
240 * the window structure passed in.
242 void fgSetWindow ( SFG_Window *window )
244 #if TARGET_HOST_UNIX_X11
248 window->Window.Handle,
249 window->Window.Context
251 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
252 if( fgStructure.Window )
253 ReleaseDC( fgStructure.Window->Window.Handle,
254 fgStructure.Window->Window.Device );
258 window->Window.Device = GetDC( window->Window.Handle );
260 window->Window.Device,
261 window->Window.Context
265 fgStructure.Window = window;
270 * Opens a window. Requires a SFG_Window object created and attached
271 * to the freeglut structure. OpenGL context is created here.
273 void fgOpenWindow( SFG_Window* window, const char* title,
274 int x, int y, int w, int h,
275 GLboolean gameMode, GLboolean isSubWindow )
277 #if TARGET_HOST_UNIX_X11
278 XSetWindowAttributes winAttr;
279 XTextProperty textProperty;
280 XSizeHints sizeHints;
284 freeglut_assert_ready;
287 * XXX fgChooseVisual() is a common part of all three.
288 * XXX With a little thought, we should be able to greatly
291 if( !window->IsMenu )
292 window->Window.VisualInfo = fgChooseVisual( );
293 else if( fgStructure.MenuContext )
294 window->Window.VisualInfo = fgChooseVisual( );
297 /* XXX Why are menus double- and depth-buffered? */
298 unsigned int current_DisplayMode = fgState.DisplayMode ;
299 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
300 window->Window.VisualInfo = fgChooseVisual( );
301 fgState.DisplayMode = current_DisplayMode ;
304 if( ! window->Window.VisualInfo )
307 * The "fgChooseVisual" returned a null meaning that the visual
308 * context is not available.
309 * Try a couple of variations to see if they will work.
311 if( !( fgState.DisplayMode & GLUT_DOUBLE ) )
313 fgState.DisplayMode |= GLUT_DOUBLE ;
314 window->Window.VisualInfo = fgChooseVisual( );
315 fgState.DisplayMode &= ~GLUT_DOUBLE;
319 * GLUT also checks for multi-sampling, but I don't see that
320 * anywhere else in FREEGLUT so I won't bother with it for the moment.
325 * XXX This seems to be abusing an assert() for error-checking.
326 * XXX It is possible that the visual simply can't be found,
327 * XXX in which case we should print an error and return a 0
328 * XXX for the window id, I think.
330 assert( window->Window.VisualInfo != NULL );
334 * XXX HINT: the masks should be updated when adding/removing callbacks.
335 * XXX This might speed up message processing. Is that true?
337 * XXX A: Not appreciably, but it WILL make it easier to debug.
338 * XXX Try tracing old GLUT and try tracing freeglut. Old GLUT
339 * XXX turns off events that it doesn't need and is a whole lot
340 * XXX more pleasant to trace. (Think mouse-motion! Tons of
341 * XXX ``bonus'' GUI events stream in.)
344 StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
345 ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
346 VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
347 PointerMotionMask | ButtonMotionMask;
348 winAttr.background_pixmap = None;
349 winAttr.background_pixel = 0;
350 winAttr.border_pixel = 0;
352 winAttr.colormap = XCreateColormap(
353 fgDisplay.Display, fgDisplay.RootWindow,
354 window->Window.VisualInfo->visual, AllocNone
357 mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
361 winAttr.override_redirect = True;
362 mask |= CWOverrideRedirect;
365 window->Window.Handle = XCreateWindow(
367 window->Parent == NULL ? fgDisplay.RootWindow :
368 window->Parent->Window.Handle,
370 window->Window.VisualInfo->depth, InputOutput,
371 window->Window.VisualInfo->visual, mask,
376 * The GLX context creation, possibly trying the direct context rendering
377 * or else use the current context if the user has so specified
382 * If there isn't already an OpenGL rendering context for menu
385 if( !fgStructure.MenuContext )
387 fgStructure.MenuContext =
388 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
389 fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
390 fgStructure.MenuContext->Context = glXCreateContext(
391 fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
392 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
396 /* window->Window.Context = fgStructure.MenuContext->Context; */
397 window->Window.Context = glXCreateContext(
398 fgDisplay.Display, window->Window.VisualInfo,
399 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
402 else if( fgState.UseCurrentContext )
404 window->Window.Context = glXGetCurrentContext( );
406 if( ! window->Window.Context )
407 window->Window.Context = glXCreateContext(
408 fgDisplay.Display, window->Window.VisualInfo,
409 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
413 window->Window.Context = glXCreateContext(
414 fgDisplay.Display, window->Window.VisualInfo,
415 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
418 #if !defined( __FreeBSD__ ) && !defined( __NetBSD__ )
419 if( !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
421 if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
422 fgError( "Unable to force direct context rendering for window '%s'",
424 else if( fgState.DirectContext == GLUT_TRY_DIRECT_CONTEXT )
425 fgWarning( "Unable to create direct context rendering for window '%s'\nThis may hurt performance.",
432 window->Window.Handle,
433 window->Window.Context
437 * XXX Assume the new window is visible by default
438 * XXX Is this a safe assumption?
440 window->State.Visible = GL_TRUE;
443 if ( fgState.Position.Use )
444 sizeHints.flags |= USPosition;
445 if ( fgState.Size.Use )
446 sizeHints.flags |= USSize;
449 * Fill in the size hints values now (the x, y, width and height
450 * settings are obsolete, are there any more WMs that support them?)
451 * Unless the X servers actually stop supporting these, we should
452 * continue to fill them in. It is *not* our place to tell the user
453 * that they should replace a window manager that they like, and which
454 * works, just because *we* think that it's not "modern" enough.
456 #if TARGET_HOST_WINCE /* Since this is in the X11 branch, it's pretty dumb */
459 sizeHints.width = 320;
460 sizeHints.height = 240;
465 sizeHints.height = h;
466 #endif /* TARGET_HOST_WINCE */
468 wmHints.flags = StateHint;
469 wmHints.initial_state = fgState.ForceIconic ? IconicState : NormalState;
470 /* Prepare the window and iconified window names... */
471 XStringListToTextProperty( (char **) &title, 1, &textProperty );
475 window->Window.Handle,
485 XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
486 &fgDisplay.DeleteWindow, 1 );
488 XMapWindow( fgDisplay.Display, window->Window.Handle );
490 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
497 freeglut_assert_ready;
499 /* Grab the window class we have registered on glutInit(): */
500 atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );
505 assert( window->Parent == NULL );
508 * Set the window creation flags appropriately to make the window
511 flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
515 #if !TARGET_HOST_WINCE
516 if ( ( ! isSubWindow ) && ( ! window->IsMenu ) )
519 * Update the window dimensions, taking account of window
520 * decorations. "freeglut" is to create the window with the
521 * outside of its border at (x,y) and with dimensions (w,h).
523 w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
524 h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 +
525 GetSystemMetrics( SM_CYCAPTION );
527 #endif /* TARGET_HOST_WINCE */
529 if( ! fgState.Position.Use )
534 if( ! fgState.Size.Use )
541 * There's a small difference between creating the top, child and
544 flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
546 if ( window->IsMenu )
549 exFlags |= WS_EX_TOOLWINDOW;
551 #if !TARGET_HOST_WINCE
552 else if( window->Parent == NULL )
553 flags |= WS_OVERLAPPEDWINDOW;
559 #if TARGET_HOST_WINCE
561 wchar_t* wstr = wstr_from_str(title);
563 window->Window.Handle = CreateWindow(
566 WS_VISIBLE | WS_POPUP,
576 SHFullScreen(window->Window.Handle, SHFS_HIDESTARTICON);
577 SHFullScreen(window->Window.Handle, SHFS_HIDESIPBUTTON);
578 SHFullScreen(window->Window.Handle, SHFS_HIDETASKBAR);
579 MoveWindow(window->Window.Handle, 0, 0, 240, 320, TRUE);
580 ShowWindow(window->Window.Handle, SW_SHOW);
581 UpdateWindow(window->Window.Handle);
584 window->Window.Handle = CreateWindowEx(
590 (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
595 #endif /* TARGET_HOST_WINCE */
597 if( !( window->Window.Handle ) )
598 fgError( "Failed to create a window (%s)!", title );
600 #if TARGET_HOST_WINCE
601 ShowWindow( window->Window.Handle, SW_SHOW );
603 ShowWindow( window->Window.Handle,
604 fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
605 #endif /* TARGET_HOST_WINCE */
607 UpdateWindow( window->Window.Handle );
608 ShowCursor( TRUE ); /* XXX Old comments say "hide cusror"! */
612 fgSetWindow( window );
614 window->Window.DoubleBuffered =
615 ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0;
617 if ( ! window->Window.DoubleBuffered )
619 glDrawBuffer ( GL_FRONT );
620 glReadBuffer ( GL_FRONT );
625 * Closes a window, destroying the frame and OpenGL context
627 void fgCloseWindow( SFG_Window* window )
629 freeglut_assert_ready;
631 #if TARGET_HOST_UNIX_X11
633 glXDestroyContext( fgDisplay.Display, window->Window.Context );
634 XDestroyWindow( fgDisplay.Display, window->Window.Handle );
635 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
637 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
639 /* Make sure we don't close a window with current context active */
640 if( fgStructure.Window == window )
641 wglMakeCurrent( NULL, NULL );
644 * Step through the list of windows. If the rendering context
645 * is not being used by another window, then we delete it.
651 for( iter = (SFG_Window *)fgStructure.Windows.First;
653 iter = (SFG_Window *)iter->Node.Next )
655 if( ( iter->Window.Context == window->Window.Context ) &&
661 wglDeleteContext( window->Window.Context );
664 DestroyWindow( window->Window.Handle );
669 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
672 * Creates a new top-level freeglut window
674 int FGAPIENTRY glutCreateWindow( const char* title )
676 return fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
677 fgState.Size.X, fgState.Size.Y, GL_FALSE,
682 * This function creates a sub window.
684 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
687 SFG_Window* window = NULL;
688 SFG_Window* parent = NULL;
690 freeglut_assert_ready;
691 parent = fgWindowByID( parentID );
692 freeglut_return_val_if_fail( parent != NULL, 0 );
693 window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE );
700 * Destroys a window and all of its subwindows
702 void FGAPIENTRY glutDestroyWindow( int windowID )
704 SFG_Window* window = fgWindowByID( windowID );
705 freeglut_return_if_fail( window != NULL );
707 fgExecutionState ExecState = fgState.ExecState;
708 fgAddToWindowDestroyList( window );
709 fgState.ExecState = ExecState;
714 * This function selects the current window
716 void FGAPIENTRY glutSetWindow( int ID )
718 SFG_Window* window = NULL;
720 freeglut_assert_ready;
721 if( fgStructure.Window != NULL )
722 if( fgStructure.Window->ID == ID )
725 window = fgWindowByID( ID );
728 fgWarning( "glutSetWindow(): window ID %i not found!", ID );
732 fgSetWindow( window );
736 * This function returns the ID number of the current window, 0 if none exists
738 int FGAPIENTRY glutGetWindow( void )
740 freeglut_assert_ready;
741 if( fgStructure.Window == NULL )
743 return fgStructure.Window->ID;
747 * This function makes the current window visible
749 void FGAPIENTRY glutShowWindow( void )
751 freeglut_assert_ready;
752 freeglut_assert_window;
754 #if TARGET_HOST_UNIX_X11
756 XMapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
757 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
759 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
761 ShowWindow( fgStructure.Window->Window.Handle, SW_SHOW );
765 fgStructure.Window->State.Redisplay = GL_TRUE;
769 * This function hides the current window
771 void FGAPIENTRY glutHideWindow( void )
773 freeglut_assert_ready;
774 freeglut_assert_window;
776 #if TARGET_HOST_UNIX_X11
778 if( fgStructure.Window->Parent == NULL )
779 XWithdrawWindow( fgDisplay.Display,
780 fgStructure.Window->Window.Handle,
783 XUnmapWindow( fgDisplay.Display,
784 fgStructure.Window->Window.Handle );
785 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
787 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
789 ShowWindow( fgStructure.Window->Window.Handle, SW_HIDE );
793 fgStructure.Window->State.Redisplay = GL_FALSE;
797 * Iconify the current window (top-level windows only)
799 void FGAPIENTRY glutIconifyWindow( void )
801 freeglut_assert_ready;
802 freeglut_assert_window;
804 fgStructure.Window->State.Visible = GL_FALSE;
805 #if TARGET_HOST_UNIX_X11
807 XIconifyWindow( fgDisplay.Display, fgStructure.Window->Window.Handle,
809 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
811 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
813 ShowWindow( fgStructure.Window->Window.Handle, SW_MINIMIZE );
817 fgStructure.Window->State.Redisplay = GL_FALSE;
821 * Set the current window's title
823 void FGAPIENTRY glutSetWindowTitle( const char* title )
825 freeglut_assert_ready;
826 freeglut_assert_window;
827 if( ! fgStructure.Window->Parent )
829 #if TARGET_HOST_UNIX_X11
833 text.value = (unsigned char *) title;
834 text.encoding = XA_STRING;
836 text.nitems = strlen( title );
840 fgStructure.Window->Window.Handle,
844 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
846 #elif TARGET_HOST_WIN32
848 SetWindowText( fgStructure.Window->Window.Handle, title );
850 #elif TARGET_HOST_WINCE
852 wchar_t* wstr = wstr_from_str(title);
854 SetWindowText( fgStructure.Window->Window.Handle, wstr );
863 * Set the current window's iconified title
865 void FGAPIENTRY glutSetIconTitle( const char* title )
867 freeglut_assert_ready;
868 freeglut_assert_window;
870 if( ! fgStructure.Window->Parent )
872 #if TARGET_HOST_UNIX_X11
876 text.value = (unsigned char *) title;
877 text.encoding = XA_STRING;
879 text.nitems = strlen( title );
883 fgStructure.Window->Window.Handle,
887 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
889 #elif TARGET_HOST_WIN32
891 SetWindowText( fgStructure.Window->Window.Handle, title );
893 #elif TARGET_HOST_WINCE
895 wchar_t* wstr = wstr_from_str(title);
897 SetWindowText( fgStructure.Window->Window.Handle, wstr );
906 * Change the current window's size
908 void FGAPIENTRY glutReshapeWindow( int width, int height )
910 freeglut_assert_ready;
911 freeglut_assert_window;
913 fgStructure.Window->State.NeedToResize = GL_TRUE;
914 fgStructure.Window->State.Width = width ;
915 fgStructure.Window->State.Height = height;
919 * Change the current window's position
921 void FGAPIENTRY glutPositionWindow( int x, int y )
923 freeglut_assert_ready;
924 freeglut_assert_window;
926 #if TARGET_HOST_UNIX_X11
928 XMoveWindow( fgDisplay.Display, fgStructure.Window->Window.Handle,
930 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
932 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
937 /* "GetWindowRect" returns the pixel coordinates of the outside of the window */
938 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
940 fgStructure.Window->Window.Handle,
943 winRect.right - winRect.left,
944 winRect.bottom - winRect.top,
953 * Lowers the current window (by Z order change)
955 void FGAPIENTRY glutPushWindow( void )
957 freeglut_assert_ready;
958 freeglut_assert_window;
960 #if TARGET_HOST_UNIX_X11
962 XLowerWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
964 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
967 fgStructure.Window->Window.Handle,
970 SWP_NOSIZE | SWP_NOMOVE
977 * Raises the current window (by Z order change)
979 void FGAPIENTRY glutPopWindow( void )
981 freeglut_assert_ready;
982 freeglut_assert_window;
984 #if TARGET_HOST_UNIX_X11
986 XRaiseWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
988 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
991 fgStructure.Window->Window.Handle,
994 SWP_NOSIZE | SWP_NOMOVE
1001 * Resize the current window so that it fits the whole screen
1003 void FGAPIENTRY glutFullScreen( void )
1005 freeglut_assert_ready;
1006 freeglut_assert_window;
1009 #if TARGET_HOST_UNIX_X11
1015 fgStructure.Window->Window.Handle,
1017 fgDisplay.ScreenWidth,
1018 fgDisplay.ScreenHeight
1021 XFlush( fgDisplay.Display ); /* This is needed */
1023 XTranslateCoordinates(
1025 fgStructure.Window->Window.Handle,
1026 fgDisplay.RootWindow,
1034 fgStructure.Window->Window.Handle,
1037 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
1039 #elif TARGET_HOST_WIN32
1042 /* For fullscreen mode, force the top-left corner to 0,0
1043 * and adjust the window rectangle so that the client area
1044 * covers the whole screen.
1049 rect.right = fgDisplay.ScreenWidth;
1050 rect.bottom = fgDisplay.ScreenHeight;
1052 AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
1053 WS_CLIPCHILDREN, FALSE );
1056 * SWP_NOACTIVATE Do not activate the window
1057 * SWP_NOOWNERZORDER Do not change position in z-order
1058 * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
1059 * SWP_NOZORDER Retains the current Z order (ignore 2nd param)
1062 SetWindowPos( fgStructure.Window->Window.Handle,
1066 rect.right - rect.left,
1067 rect.bottom - rect.top,
1068 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
1076 * A.Donev: Set and retrieve the window's user data
1078 void* FGAPIENTRY glutGetWindowData( void )
1080 return fgStructure.Window->UserData;
1083 void FGAPIENTRY glutSetWindowData(void* data)
1085 fgStructure.Window->UserData = data;
1088 /*** END OF FILE ***/