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 static wchar_t* fghWstrFromStr(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;
90 /* First we have to process the display mode settings... */
92 * XXX Why is there a semi-colon in this #define? The code
93 * XXX that uses the macro seems to always add more semicolons...
95 #define ATTRIB(a) attributes[where++]=a;
96 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
98 if( fgState.DisplayMode & GLUT_INDEX )
100 ATTRIB_VAL( GLX_BUFFER_SIZE, 8 );
101 wantIndexedMode = GL_TRUE;
106 ATTRIB_VAL( GLX_RED_SIZE, 1 );
107 ATTRIB_VAL( GLX_GREEN_SIZE, 1 );
108 ATTRIB_VAL( GLX_BLUE_SIZE, 1 );
109 if( fgState.DisplayMode & GLUT_ALPHA )
110 ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
113 if( fgState.DisplayMode & GLUT_DOUBLE )
114 ATTRIB( GLX_DOUBLEBUFFER );
116 if( fgState.DisplayMode & GLUT_STEREO )
117 ATTRIB( GLX_STEREO );
119 if( fgState.DisplayMode & GLUT_DEPTH )
120 ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
122 if( fgState.DisplayMode & GLUT_STENCIL )
123 ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
125 if( fgState.DisplayMode & GLUT_ACCUM )
127 ATTRIB_VAL( GLX_ACCUM_RED_SIZE, 1 );
128 ATTRIB_VAL( GLX_ACCUM_GREEN_SIZE, 1 );
129 ATTRIB_VAL( GLX_ACCUM_BLUE_SIZE, 1 );
130 if( fgState.DisplayMode & GLUT_ALPHA )
131 ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
134 /* Push a null at the end of the list */
137 if( ! wantIndexedMode )
138 return glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
142 XVisualInfo* visualInfo;
146 * In indexed mode, we need to check how many bits of depth can we
147 * achieve. We do this by trying each possibility from the list
148 * given in the {bufferSize} array. If we match, we return to caller.
150 for( i=0; i<BUFFER_SIZES; i++ )
152 attributes[ 1 ] = bufferSize[ i ];
153 visualInfo = glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
155 if( visualInfo != NULL )
164 * Setup the pixel format for a Win32 window
166 #if TARGET_HOST_WIN32
167 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
168 unsigned char layer_type )
170 #if TARGET_HOST_WINCE
173 PIXELFORMATDESCRIPTOR* ppfd, pfd;
174 int flags, pixelformat;
176 freeglut_return_val_if_fail( window != NULL, 0 );
177 flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
178 if( fgState.DisplayMode & GLUT_DOUBLE )
179 flags |= PFD_DOUBLEBUFFER;
181 #if defined(_MSC_VER)
182 #pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
185 /* Specify which pixel format do we opt for... */
186 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
189 pfd.iPixelType = PFD_TYPE_RGBA;
200 pfd.cAccumRedBits = 0;
201 pfd.cAccumGreenBits = 0;
202 pfd.cAccumBlueBits = 0;
203 pfd.cAccumAlphaBits = 0;
206 pfd.cStencilBits = 0;
209 pfd.cStencilBits = 8;
212 pfd.iLayerType = layer_type;
215 pfd.dwVisibleMask = 0;
216 pfd.dwDamageMask = 0;
218 pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL );
221 pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
222 if( pixelformat == 0 )
227 return SetPixelFormat( window->Window.Device, pixelformat, ppfd );
228 #endif /* TARGET_HOST_WINCE */
233 * Sets the OpenGL context and the fgStructure "Current Window" pointer to
234 * the window structure passed in.
236 void fgSetWindow ( SFG_Window *window )
238 #if TARGET_HOST_UNIX_X11
242 window->Window.Handle,
243 window->Window.Context
245 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
246 if( fgStructure.Window )
247 ReleaseDC( fgStructure.Window->Window.Handle,
248 fgStructure.Window->Window.Device );
252 window->Window.Device = GetDC( window->Window.Handle );
254 window->Window.Device,
255 window->Window.Context
259 fgStructure.Window = window;
264 * Opens a window. Requires a SFG_Window object created and attached
265 * to the freeglut structure. OpenGL context is created here.
267 void fgOpenWindow( SFG_Window* window, const char* title,
268 int x, int y, int w, int h,
269 GLboolean gameMode, GLboolean isSubWindow )
271 #if TARGET_HOST_UNIX_X11
272 XSetWindowAttributes winAttr;
273 XTextProperty textProperty;
274 XSizeHints sizeHints;
278 freeglut_assert_ready;
281 * XXX fgChooseVisual() is a common part of all three.
282 * XXX With a little thought, we should be able to greatly
285 if( !window->IsMenu )
286 window->Window.VisualInfo = fgChooseVisual( );
287 else if( fgStructure.MenuContext )
288 window->Window.VisualInfo = fgChooseVisual( );
291 /* XXX Why are menus double- and depth-buffered? */
292 unsigned int current_DisplayMode = fgState.DisplayMode ;
293 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
294 window->Window.VisualInfo = fgChooseVisual( );
295 fgState.DisplayMode = current_DisplayMode ;
298 if( ! window->Window.VisualInfo )
301 * The "fgChooseVisual" returned a null meaning that the visual
302 * context is not available.
303 * Try a couple of variations to see if they will work.
305 if( !( fgState.DisplayMode & GLUT_DOUBLE ) )
307 fgState.DisplayMode |= GLUT_DOUBLE ;
308 window->Window.VisualInfo = fgChooseVisual( );
309 fgState.DisplayMode &= ~GLUT_DOUBLE;
313 * GLUT also checks for multi-sampling, but I don't see that
314 * anywhere else in FREEGLUT so I won't bother with it for the moment.
319 * XXX This seems to be abusing an assert() for error-checking.
320 * XXX It is possible that the visual simply can't be found,
321 * XXX in which case we should print an error and return a 0
322 * XXX for the window id, I think.
324 assert( window->Window.VisualInfo != NULL );
328 * XXX HINT: the masks should be updated when adding/removing callbacks.
329 * XXX This might speed up message processing. Is that true?
331 * XXX A: Not appreciably, but it WILL make it easier to debug.
332 * XXX Try tracing old GLUT and try tracing freeglut. Old GLUT
333 * XXX turns off events that it doesn't need and is a whole lot
334 * XXX more pleasant to trace. (Think mouse-motion! Tons of
335 * XXX ``bonus'' GUI events stream in.)
338 StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
339 ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
340 VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
341 PointerMotionMask | ButtonMotionMask;
342 winAttr.background_pixmap = None;
343 winAttr.background_pixel = 0;
344 winAttr.border_pixel = 0;
346 winAttr.colormap = XCreateColormap(
347 fgDisplay.Display, fgDisplay.RootWindow,
348 window->Window.VisualInfo->visual, AllocNone
351 mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
355 winAttr.override_redirect = True;
356 mask |= CWOverrideRedirect;
359 window->Window.Handle = XCreateWindow(
361 window->Parent == NULL ? fgDisplay.RootWindow :
362 window->Parent->Window.Handle,
364 window->Window.VisualInfo->depth, InputOutput,
365 window->Window.VisualInfo->visual, mask,
370 * The GLX context creation, possibly trying the direct context rendering
371 * or else use the current context if the user has so specified
376 * If there isn't already an OpenGL rendering context for menu
379 if( !fgStructure.MenuContext )
381 fgStructure.MenuContext =
382 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
383 fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
384 fgStructure.MenuContext->Context = glXCreateContext(
385 fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
386 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
390 /* window->Window.Context = fgStructure.MenuContext->Context; */
391 window->Window.Context = glXCreateContext(
392 fgDisplay.Display, window->Window.VisualInfo,
393 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
396 else if( fgState.UseCurrentContext )
398 window->Window.Context = glXGetCurrentContext( );
400 if( ! window->Window.Context )
401 window->Window.Context = glXCreateContext(
402 fgDisplay.Display, window->Window.VisualInfo,
403 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
407 window->Window.Context = glXCreateContext(
408 fgDisplay.Display, window->Window.VisualInfo,
409 NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
412 #if !defined( __FreeBSD__ ) && !defined( __NetBSD__ )
413 if( !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
415 if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
416 fgError( "Unable to force direct context rendering for window '%s'",
418 else if( fgState.DirectContext == GLUT_TRY_DIRECT_CONTEXT )
419 fgWarning( "Unable to create direct context rendering for window '%s'\nThis may hurt performance.",
426 window->Window.Handle,
427 window->Window.Context
431 * XXX Assume the new window is visible by default
432 * XXX Is this a safe assumption?
434 window->State.Visible = GL_TRUE;
437 if ( fgState.Position.Use )
438 sizeHints.flags |= USPosition;
439 if ( fgState.Size.Use )
440 sizeHints.flags |= USSize;
443 * Fill in the size hints values now (the x, y, width and height
444 * settings are obsolete, are there any more WMs that support them?)
445 * Unless the X servers actually stop supporting these, we should
446 * continue to fill them in. It is *not* our place to tell the user
447 * that they should replace a window manager that they like, and which
448 * works, just because *we* think that it's not "modern" enough.
450 #if TARGET_HOST_WINCE /* Since this is in the X11 branch, it's pretty dumb */
453 sizeHints.width = 320;
454 sizeHints.height = 240;
459 sizeHints.height = h;
460 #endif /* TARGET_HOST_WINCE */
462 wmHints.flags = StateHint;
463 wmHints.initial_state = fgState.ForceIconic ? IconicState : NormalState;
464 /* Prepare the window and iconified window names... */
465 XStringListToTextProperty( (char **) &title, 1, &textProperty );
469 window->Window.Handle,
479 XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
480 &fgDisplay.DeleteWindow, 1 );
482 XMapWindow( fgDisplay.Display, window->Window.Handle );
484 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
491 freeglut_assert_ready;
493 /* Grab the window class we have registered on glutInit(): */
494 atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );
499 assert( window->Parent == NULL );
502 * Set the window creation flags appropriately to make the window
505 flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
509 #if !TARGET_HOST_WINCE
510 if ( ( ! isSubWindow ) && ( ! window->IsMenu ) )
513 * Update the window dimensions, taking account of window
514 * decorations. "freeglut" is to create the window with the
515 * outside of its border at (x,y) and with dimensions (w,h).
517 w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
518 h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 +
519 GetSystemMetrics( SM_CYCAPTION );
521 #endif /* TARGET_HOST_WINCE */
523 if( ! fgState.Position.Use )
528 if( ! fgState.Size.Use )
535 * There's a small difference between creating the top, child and
538 flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
540 if ( window->IsMenu )
543 exFlags |= WS_EX_TOOLWINDOW;
545 #if !TARGET_HOST_WINCE
546 else if( window->Parent == NULL )
547 flags |= WS_OVERLAPPEDWINDOW;
553 #if TARGET_HOST_WINCE
555 wchar_t* wstr = fghWstrFromStr(title);
557 window->Window.Handle = CreateWindow(
560 WS_VISIBLE | WS_POPUP,
570 SHFullScreen(window->Window.Handle, SHFS_HIDESTARTICON);
571 SHFullScreen(window->Window.Handle, SHFS_HIDESIPBUTTON);
572 SHFullScreen(window->Window.Handle, SHFS_HIDETASKBAR);
573 MoveWindow(window->Window.Handle, 0, 0, 240, 320, TRUE);
574 ShowWindow(window->Window.Handle, SW_SHOW);
575 UpdateWindow(window->Window.Handle);
578 window->Window.Handle = CreateWindowEx(
584 (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
589 #endif /* TARGET_HOST_WINCE */
591 if( !( window->Window.Handle ) )
592 fgError( "Failed to create a window (%s)!", title );
594 #if TARGET_HOST_WINCE
595 ShowWindow( window->Window.Handle, SW_SHOW );
597 ShowWindow( window->Window.Handle,
598 fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
599 #endif /* TARGET_HOST_WINCE */
601 UpdateWindow( window->Window.Handle );
602 ShowCursor( TRUE ); /* XXX Old comments say "hide cusror"! */
606 fgSetWindow( window );
608 window->Window.DoubleBuffered =
609 ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0;
611 if ( ! window->Window.DoubleBuffered )
613 glDrawBuffer ( GL_FRONT );
614 glReadBuffer ( GL_FRONT );
619 * Closes a window, destroying the frame and OpenGL context
621 void fgCloseWindow( SFG_Window* window )
623 freeglut_assert_ready;
625 #if TARGET_HOST_UNIX_X11
627 glXDestroyContext( fgDisplay.Display, window->Window.Context );
628 XDestroyWindow( fgDisplay.Display, window->Window.Handle );
629 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
631 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
633 /* Make sure we don't close a window with current context active */
634 if( fgStructure.Window == window )
635 wglMakeCurrent( NULL, NULL );
638 * Step through the list of windows. If the rendering context
639 * is not being used by another window, then we delete it.
645 for( iter = (SFG_Window *)fgStructure.Windows.First;
647 iter = (SFG_Window *)iter->Node.Next )
649 if( ( iter->Window.Context == window->Window.Context ) &&
655 wglDeleteContext( window->Window.Context );
658 DestroyWindow( window->Window.Handle );
663 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
666 * Creates a new top-level freeglut window
668 int FGAPIENTRY glutCreateWindow( const char* title )
670 return fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
671 fgState.Size.X, fgState.Size.Y, GL_FALSE,
676 * This function creates a sub window.
678 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
681 SFG_Window* window = NULL;
682 SFG_Window* parent = NULL;
684 freeglut_assert_ready;
685 parent = fgWindowByID( parentID );
686 freeglut_return_val_if_fail( parent != NULL, 0 );
687 window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE );
694 * Destroys a window and all of its subwindows
696 void FGAPIENTRY glutDestroyWindow( int windowID )
698 SFG_Window* window = fgWindowByID( windowID );
699 freeglut_return_if_fail( window != NULL );
701 fgExecutionState ExecState = fgState.ExecState;
702 fgAddToWindowDestroyList( window );
703 fgState.ExecState = ExecState;
708 * This function selects the current window
710 void FGAPIENTRY glutSetWindow( int ID )
712 SFG_Window* window = NULL;
714 freeglut_assert_ready;
715 if( fgStructure.Window != NULL )
716 if( fgStructure.Window->ID == ID )
719 window = fgWindowByID( ID );
722 fgWarning( "glutSetWindow(): window ID %d not found!", ID );
726 fgSetWindow( window );
730 * This function returns the ID number of the current window, 0 if none exists
732 int FGAPIENTRY glutGetWindow( void )
734 freeglut_assert_ready;
735 if( fgStructure.Window == NULL )
737 return fgStructure.Window->ID;
741 * This function makes the current window visible
743 void FGAPIENTRY glutShowWindow( void )
745 freeglut_assert_ready;
746 freeglut_assert_window;
748 #if TARGET_HOST_UNIX_X11
750 XMapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
751 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
753 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
755 ShowWindow( fgStructure.Window->Window.Handle, SW_SHOW );
759 fgStructure.Window->State.Redisplay = GL_TRUE;
763 * This function hides the current window
765 void FGAPIENTRY glutHideWindow( void )
767 freeglut_assert_ready;
768 freeglut_assert_window;
770 #if TARGET_HOST_UNIX_X11
772 if( fgStructure.Window->Parent == NULL )
773 XWithdrawWindow( fgDisplay.Display,
774 fgStructure.Window->Window.Handle,
777 XUnmapWindow( fgDisplay.Display,
778 fgStructure.Window->Window.Handle );
779 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
781 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
783 ShowWindow( fgStructure.Window->Window.Handle, SW_HIDE );
787 fgStructure.Window->State.Redisplay = GL_FALSE;
791 * Iconify the current window (top-level windows only)
793 void FGAPIENTRY glutIconifyWindow( void )
795 freeglut_assert_ready;
796 freeglut_assert_window;
798 fgStructure.Window->State.Visible = GL_FALSE;
799 #if TARGET_HOST_UNIX_X11
801 XIconifyWindow( fgDisplay.Display, fgStructure.Window->Window.Handle,
803 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
805 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
807 ShowWindow( fgStructure.Window->Window.Handle, SW_MINIMIZE );
811 fgStructure.Window->State.Redisplay = GL_FALSE;
815 * Set the current window's title
817 void FGAPIENTRY glutSetWindowTitle( const char* title )
819 freeglut_assert_ready;
820 freeglut_assert_window;
821 if( ! fgStructure.Window->Parent )
823 #if TARGET_HOST_UNIX_X11
827 text.value = (unsigned char *) title;
828 text.encoding = XA_STRING;
830 text.nitems = strlen( title );
834 fgStructure.Window->Window.Handle,
838 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
840 #elif TARGET_HOST_WIN32
842 SetWindowText( fgStructure.Window->Window.Handle, title );
844 #elif TARGET_HOST_WINCE
846 wchar_t* wstr = fghWstrFromStr(title);
848 SetWindowText( fgStructure.Window->Window.Handle, wstr );
857 * Set the current window's iconified title
859 void FGAPIENTRY glutSetIconTitle( const char* title )
861 freeglut_assert_ready;
862 freeglut_assert_window;
864 if( ! fgStructure.Window->Parent )
866 #if TARGET_HOST_UNIX_X11
870 text.value = (unsigned char *) title;
871 text.encoding = XA_STRING;
873 text.nitems = strlen( title );
877 fgStructure.Window->Window.Handle,
881 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
883 #elif TARGET_HOST_WIN32
885 SetWindowText( fgStructure.Window->Window.Handle, title );
887 #elif TARGET_HOST_WINCE
889 wchar_t* wstr = fghWstrFromStr(title);
891 SetWindowText( fgStructure.Window->Window.Handle, wstr );
900 * Change the current window's size
902 void FGAPIENTRY glutReshapeWindow( int width, int height )
904 freeglut_assert_ready;
905 freeglut_assert_window;
907 fgStructure.Window->State.NeedToResize = GL_TRUE;
908 fgStructure.Window->State.Width = width ;
909 fgStructure.Window->State.Height = height;
913 * Change the current window's position
915 void FGAPIENTRY glutPositionWindow( int x, int y )
917 freeglut_assert_ready;
918 freeglut_assert_window;
920 #if TARGET_HOST_UNIX_X11
922 XMoveWindow( fgDisplay.Display, fgStructure.Window->Window.Handle,
924 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
926 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
931 /* "GetWindowRect" returns the pixel coordinates of the outside of the window */
932 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
934 fgStructure.Window->Window.Handle,
937 winRect.right - winRect.left,
938 winRect.bottom - winRect.top,
947 * Lowers the current window (by Z order change)
949 void FGAPIENTRY glutPushWindow( void )
951 freeglut_assert_ready;
952 freeglut_assert_window;
954 #if TARGET_HOST_UNIX_X11
956 XLowerWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
958 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
961 fgStructure.Window->Window.Handle,
964 SWP_NOSIZE | SWP_NOMOVE
971 * Raises the current window (by Z order change)
973 void FGAPIENTRY glutPopWindow( void )
975 freeglut_assert_ready;
976 freeglut_assert_window;
978 #if TARGET_HOST_UNIX_X11
980 XRaiseWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
982 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
985 fgStructure.Window->Window.Handle,
988 SWP_NOSIZE | SWP_NOMOVE
995 * Resize the current window so that it fits the whole screen
997 void FGAPIENTRY glutFullScreen( void )
999 freeglut_assert_ready;
1000 freeglut_assert_window;
1003 #if TARGET_HOST_UNIX_X11
1009 fgStructure.Window->Window.Handle,
1011 fgDisplay.ScreenWidth,
1012 fgDisplay.ScreenHeight
1015 XFlush( fgDisplay.Display ); /* This is needed */
1017 XTranslateCoordinates(
1019 fgStructure.Window->Window.Handle,
1020 fgDisplay.RootWindow,
1028 fgStructure.Window->Window.Handle,
1031 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
1033 #elif TARGET_HOST_WIN32
1036 /* For fullscreen mode, force the top-left corner to 0,0
1037 * and adjust the window rectangle so that the client area
1038 * covers the whole screen.
1043 rect.right = fgDisplay.ScreenWidth;
1044 rect.bottom = fgDisplay.ScreenHeight;
1046 AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
1047 WS_CLIPCHILDREN, FALSE );
1050 * SWP_NOACTIVATE Do not activate the window
1051 * SWP_NOOWNERZORDER Do not change position in z-order
1052 * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
1053 * SWP_NOZORDER Retains the current Z order (ignore 2nd param)
1056 SetWindowPos( fgStructure.Window->Window.Handle,
1060 rect.right - rect.left,
1061 rect.bottom - rect.top,
1062 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
1070 * A.Donev: Set and retrieve the window's user data
1072 void* FGAPIENTRY glutGetWindowData( void )
1074 return fgStructure.Window->UserData;
1077 void FGAPIENTRY glutSetWindowData(void* data)
1079 fgStructure.Window->UserData = data;
1082 /*** END OF FILE ***/