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: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@362
7f0cb862-5218-0410-a997-
914c9d46530a
};
/*
+ * 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...
*/
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 */
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 */
};
/*
* 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
* 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;
* 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 );
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;
* Otherwise, check this window's children
*/
fgEnumSubWindows( window, fghcbWindowByHandle, enumerator );
-
-#undef WBHANDLE
}
/*
* 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;