Change from John (I removed a couple of spaces from a couple of lines in

his freeglut_internal.h file where they were wrapping in EMACS; otherwise,
the files are exactly as he sent them to me).

The change unifies the WIN32 and UNIX_X11 code by defining our own
window-handle-type in freeglut_internal.h.  This let John rip out some
#if garbage in several places.  The result is clearer code.

Thanks, John!


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@362 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-11-25 04:21:48 +00:00
parent 354569a7c4
commit db9108dfeb
3 changed files with 26 additions and 47 deletions

View File

@ -309,6 +309,22 @@ struct tagSFG_Timer
long TriggerTime; /* The timer trigger time */
};
/*
* Make "freeglut" window handle and context types so that we don't need so
* much conditionally-compiled code later in the library.
*/
#if TARGET_HOST_UNIX_X11
typedef Window SFG_WindowHandleType ;
typedef GLXContext SFG_WindowContextType ;
#elif TARGET_HOST_WIN32
typedef HWND SFG_WindowHandleType ;
typedef HGLRC SFG_WindowContextType ;
#endif
/*
* A window and its OpenGL context. The contents of this structure
* are highly dependant on the target operating system we aim at...
@ -316,16 +332,13 @@ struct tagSFG_Timer
typedef struct tagSFG_Context SFG_Context;
struct tagSFG_Context
{
SFG_WindowHandleType Handle; /* The window's handle */
SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
#if TARGET_HOST_UNIX_X11
Window Handle; /* The window's handle */
GLXContext Context; /* The OpenGL context */
XVisualInfo* VisualInfo; /* The window's visual information */
#elif TARGET_HOST_WIN32
HWND Handle; /* The window's handle */
HDC Device; /* The window's device context */
HGLRC Context; /* The window's WGL context */
#endif
int DoubleBuffered; /* Treat the window as double-buffered */
@ -456,12 +469,10 @@ typedef struct tagSFG_MenuContext SFG_MenuContext;
struct tagSFG_MenuContext
{
#if TARGET_HOST_UNIX_X11
GLXContext Context; /* The menu OpenGL context */
XVisualInfo* VisualInfo; /* The window's visual information */
#elif TARGET_HOST_WIN32
HGLRC Context; /* The menu window's WGL context */
#endif
SFG_WindowContextType Context; /* The menu window's WGL context */
};
/*
@ -750,11 +761,7 @@ void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,
* first window in the queue matching the specified window handle.
* The function is defined in freeglut_structure.c file.
*/
#if TARGET_HOST_UNIX_X11
SFG_Window* fgWindowByHandle( Window hWindow );
#elif TARGET_HOST_WIN32
SFG_Window* fgWindowByHandle( HWND hWindow );
#endif
SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );
/*
* This function is similiar to the previous one, except it is

View File

@ -68,19 +68,9 @@
* Handle a window configuration change. When no reshape
* callback is hooked, the viewport size is updated to
* match the new window size.
*
* XXX We can/should make a "unified" window handle type so that
* XXX the function headers don't need this silly #ifdef junk.
* XXX Make the type, say, {fgWindow}. On UNIX_X11, this is
* XXX {Window}. On WIN32, it is {HWND}. Then do the #ifdef
* XXX junk *once* in "freeglut_internal.h".
*/
static void fghReshapeWindowByHandle
#if TARGET_HOST_UNIX_X11
( Window handle, int width, int height )
#elif TARGET_HOST_WIN32
( HWND handle, int width, int height )
#endif
static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
int width, int height )
{
SFG_Window *current_window = fgStructure.Window;
@ -175,12 +165,7 @@ static void fghReshapeWindowByHandle
* Calls a window's redraw method. This is used when
* a redraw is forced by the incoming window messages.
*/
static void fghRedrawWindowByHandle
#if TARGET_HOST_UNIX_X11
( Window handle )
#elif TARGET_HOST_WIN32
( HWND handle )
#endif
static void fghRedrawWindowByHandle ( SFG_WindowHandleType handle )
{
SFG_Window* window = fgWindowByHandle( handle );
freeglut_return_if_fail( window != NULL );

View File

@ -518,16 +518,10 @@ static void fghcbWindowByHandle( SFG_Window *window,
if ( enumerator->found )
return;
#if TARGET_HOST_UNIX_X11
#define WBHANDLE (Window)
#elif TARGET_HOST_WIN32
#define WBHANDLE (HWND)
#endif
/*
* Check the window's handle. Hope this works. Looks ugly. That's for sure.
*/
if( window->Window.Handle == WBHANDLE (enumerator->data) )
if( window->Window.Handle == (SFG_WindowHandleType) (enumerator->data) )
{
enumerator->found = GL_TRUE;
enumerator->data = window;
@ -539,8 +533,6 @@ static void fghcbWindowByHandle( SFG_Window *window,
* Otherwise, check this window's children
*/
fgEnumSubWindows( window, fghcbWindowByHandle, enumerator );
#undef WBHANDLE
}
/*
@ -548,12 +540,7 @@ static void fghcbWindowByHandle( SFG_Window *window,
* first window in the queue matching the specified window handle.
* The function is defined in freeglut_structure.c file.
*/
SFG_Window* fgWindowByHandle
#if TARGET_HOST_UNIX_X11
( Window hWindow )
#elif TARGET_HOST_WIN32
( HWND hWindow )
#endif
SFG_Window* fgWindowByHandle ( SFG_WindowHandleType hWindow )
{
SFG_Enumerator enumerator;