src/freeglut_window.c Windowing fixes from John F.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@145 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
sandalle 2003-07-23 21:44:06 +00:00
parent 3af1444ebd
commit 4c8460be81
2 changed files with 57 additions and 16 deletions

View File

@ -245,3 +245,5 @@ October 24, 2002:
******************************************************************************************* *******************************************************************************************
(93) doc/Makefile.am:4 Removed trailing backslash and added an empty last line (93) doc/Makefile.am:4 Removed trailing backslash and added an empty last line
(94) src/freeglut_window.c Windowing fixes from John F.

View File

@ -428,11 +428,23 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
/* /*
* The GLX context creation, possibly trying the direct context rendering * The GLX context creation, possibly trying the direct context rendering
* or else use the current context if the user has so specified
*/ */
window->Window.Context = glXCreateContext( if ( fgState.UseCurrentContext == TRUE )
fgDisplay.Display, window->Window.VisualInfo, {
NULL, fgState.ForceDirectContext | fgState.TryDirectContext window->Window.Context = glXGetCurrentContext();
);
if ( ! window->Window.Context )
window->Window.Context = glXCreateContext(
fgDisplay.Display, window->Window.VisualInfo,
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
);
}
else
window->Window.Context = glXCreateContext(
fgDisplay.Display, window->Window.VisualInfo,
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
);
/* /*
* Make sure the context is direct when the user wants it forced * Make sure the context is direct when the user wants it forced
@ -536,7 +548,8 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
# endif # endif
} }
#elif TARGET_HOST_WIN32 #elif TAR
GET_HOST_WIN32
WNDCLASS wc; WNDCLASS wc;
int flags; int flags;
@ -563,13 +576,16 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION ); h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION );
} }
/* /*
* Check if the user wants us to use the default position/size * Check if the user wants us to use the default position/size
*/ */
if( fgState.Position.Use == FALSE ) { x = CW_USEDEFAULT; y = CW_USEDEFAULT; } if( fgState.Position.Use == FALSE ) { x = CW_USEDEFAULT; y = CW_USEDEFAULT; }
if( fgState.Size .Use == FALSE ) { w = CW_USEDEFAULT; h = CW_USEDEFAULT; }
if( fgState.Size .Use == FALSE ) { w = CW_USEDEFAULT; h = CW_USEDEFAULT; }
/*
/*
* There's a small difference between creating the top, child and game mode windows * There's a small difference between creating the top, child and game mode windows
*/ */
flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE; flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
@ -579,6 +595,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
else else
flags |= WS_CHILD; flags |= WS_CHILD;
} }
else else
{ {
/* /*
@ -592,6 +609,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE; flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
} }
/* /*
* Create the window now, passing the freeglut window structure as the parameter * Create the window now, passing the freeglut window structure as the parameter
*/ */
@ -634,12 +652,14 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
glReadBuffer ( GL_FRONT ) ; glReadBuffer ( GL_FRONT ) ;
} }
/* /*
* Set the newly created window as the current one * Set the newly created window as the current one
*/ */
fgSetWindow( window ); fgSetWindow( window );
} }
/* /*
* Closes a window, destroying the frame and OpenGL context * Closes a window, destroying the frame and OpenGL context
*/ */
@ -678,6 +698,7 @@ void fgCloseWindow( SFG_Window* window )
} }
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
@ -692,6 +713,7 @@ int FGAPIENTRY glutCreateWindow( const char* title )
fgState.Size.X, fgState.Size.Y, FALSE )->ID ); fgState.Size.X, fgState.Size.Y, FALSE )->ID );
} }
/* /*
* This function creates a sub window. * This function creates a sub window.
*/ */
@ -723,6 +745,7 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
return( window->ID ); return( window->ID );
} }
/* /*
* Destroys a window and all of its subwindows * Destroys a window and all of its subwindows
*/ */
@ -749,6 +772,7 @@ void FGAPIENTRY glutDestroyWindow( int windowID )
fgState.ExecState = ExecState ; fgState.ExecState = ExecState ;
} }
/* /*
* This function selects the current window * This function selects the current window
*/ */
@ -785,9 +809,11 @@ void FGAPIENTRY glutSetWindow( int ID )
return; return;
} }
fgSetWindow ( window ) ; fgSetWindow ( window ) ;
} }
/* /*
* This function returns the ID number of the current window, 0 if none exists * This function returns the ID number of the current window, 0 if none exists
*/ */
@ -806,12 +832,14 @@ int FGAPIENTRY glutGetWindow( void )
return( 0 ); return( 0 );
} }
/* /*
* Otherwise, return the ID of the current window * Otherwise, return the ID of the current window
*/ */
return( fgStructure.Window->ID ); return( fgStructure.Window->ID );
} }
/* /*
* This function makes the current window visible * This function makes the current window visible
*/ */
@ -835,6 +863,7 @@ void FGAPIENTRY glutShowWindow( void )
#endif #endif
} }
/* /*
* This function hides the current window * This function hides the current window
*/ */
@ -854,6 +883,7 @@ void FGAPIENTRY glutHideWindow( void )
*/ */
XWithdrawWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen ); XWithdrawWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
} }
else else
{ {
/* /*
@ -862,6 +892,7 @@ void FGAPIENTRY glutHideWindow( void )
XUnmapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle ); XUnmapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
} }
/* /*
* Flush the X state now * Flush the X state now
*/ */
@ -876,6 +907,7 @@ void FGAPIENTRY glutHideWindow( void )
#endif #endif
} }
/* /*
* Iconify the current window (top-level windows only) * Iconify the current window (top-level windows only)
*/ */
@ -899,6 +931,7 @@ void FGAPIENTRY glutIconifyWindow( void )
#endif #endif
} }
/* /*
* Set the current window's title * Set the current window's title
*/ */
@ -939,6 +972,7 @@ void FGAPIENTRY glutSetWindowTitle( const char* title )
XFlush( fgDisplay.Display ); XFlush( fgDisplay.Display );
} }
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
/* /*
* This seems to be a bit easier under Win32 * This seems to be a bit easier under Win32
@ -948,6 +982,7 @@ void FGAPIENTRY glutSetWindowTitle( const char* title )
#endif #endif
} }
/* /*
* Set the current window's iconified title * Set the current window's iconified title
*/ */
@ -988,6 +1023,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title )
XFlush( fgDisplay.Display ); XFlush( fgDisplay.Display );
} }
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
/* /*
* This seems to be a bit easier under Win32 * This seems to be a bit easier under Win32
@ -997,6 +1033,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title )
#endif #endif
} }
/* /*
* Change the current window's size * Change the current window's size
*/ */
@ -1031,6 +1068,7 @@ void FGAPIENTRY glutReshapeWindow( int width, int height )
width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2; width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION ); height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION );
} }
else /* This is a subwindow, get the parent window's position and subtract it off */ else /* This is a subwindow, get the parent window's position and subtract it off */
{ {
GetWindowRect ( fgStructure.Window->Parent->Window.Handle, &winRect ) ; GetWindowRect ( fgStructure.Window->Parent->Window.Handle, &winRect ) ;
@ -1038,6 +1076,7 @@ void FGAPIENTRY glutReshapeWindow( int width, int height )
y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) ; y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) ;
} }
/* /*
* Resize the window, forcing a redraw to happen * Resize the window, forcing a redraw to happen
*/ */
@ -1050,9 +1089,11 @@ void FGAPIENTRY glutReshapeWindow( int width, int height )
TRUE TRUE
); );
} }
#endif #endif
} }
/* /*
* Change the current window's position * Change the current window's position
*/ */
@ -1089,9 +1130,11 @@ void FGAPIENTRY glutPositionWindow( int x, int y )
); );
} }
#endif #endif
} }
/* /*
* Lowers the current window (by Z order change) * Lowers the current window (by Z order change)
*/ */
@ -1119,6 +1162,7 @@ void FGAPIENTRY glutPushWindow( void )
#endif #endif
} }
/* /*
* Raises the current window (by Z order change) * Raises the current window (by Z order change)
*/ */
@ -1146,6 +1190,7 @@ void FGAPIENTRY glutPopWindow( void )
#endif #endif
} }
/* /*
* Resize the current window so that it fits the whole screen * Resize the current window so that it fits the whole screen
*/ */
@ -1164,6 +1209,7 @@ void FGAPIENTRY glutFullScreen( void )
); );
} }
/* /*
* A.Donev: Set and retrieve the window's user data * A.Donev: Set and retrieve the window's user data
*/ */
@ -1172,18 +1218,11 @@ void* FGAPIENTRY glutGetWindowData( void )
return(fgStructure.Window->UserData); return(fgStructure.Window->UserData);
} }
void FGAPIENTRY glutSetWindowData(void* data) void FGAPIENTRY glutSetWindowData(void* data)
{ {
fgStructure.Window->UserData=data; fgStructure.Window->UserData=data;
} }
/*** END OF FILE ***/ /*** END OF FILE ***/