X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_internal.h;h=d6d1743dc5ba58a093a1c2ad6b038bd4f4e72501;hb=0533f65a199109084a2cfc04ccb1e1fbae700729;hp=38c465bd32e5eacfb0478c8eaa79262777cf76ae;hpb=d2f7ea29ea6d946f455f4363c3f058ff2bdfba35;p=freeglut diff --git a/src/Common/freeglut_internal.h b/src/Common/freeglut_internal.h index 38c465b..d6d1743 100644 --- a/src/Common/freeglut_internal.h +++ b/src/Common/freeglut_internal.h @@ -88,23 +88,7 @@ /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */ -/* All Win32 headers depend on the huge windows.h recursive include. - * Note: Lower-case header names are used, for best cross-platform - * compatibility. - */ -#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) -# include -# include -# include -/* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */ -# ifndef __CYGWIN__ -# include -# else -# define _TEXT(x) TEXT(x) -# define _T(x) TEXT(x) -# endif - -#elif TARGET_HOST_POSIX_X11 +#if TARGET_HOST_POSIX_X11 # include # include # include @@ -210,6 +194,65 @@ LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID); #define INVALID_MODIFIERS 0xffffffff + + +/* Platform-specific includes */ +#if TARGET_HOST_POSIX_X11 + +typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay; +struct tagSFG_PlatformDisplay +{ + Display* Display; /* The display we are being run in. */ + int Screen; /* The screen we are about to use. */ + Window RootWindow; /* The screen's root window. */ + int Connection; /* The display's connection number */ + Atom DeleteWindow; /* The window deletion atom */ + Atom State; /* The state atom */ + Atom StateFullScreen; /* The full screen atom */ + +#ifdef HAVE_X11_EXTENSIONS_XRANDR_H + int prev_xsz, prev_ysz; + int prev_refresh; + int prev_size_valid; +#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */ + +#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H + /* + * XF86VidMode may be compilable even if it fails at runtime. Therefore, + * the validity of the VidMode has to be tracked + */ + int DisplayModeValid; /* Flag that indicates runtime status*/ + XF86VidModeModeLine DisplayMode; /* Current screen's display settings */ + int DisplayModeClock; /* The display mode's refresh rate */ + int DisplayViewPortX; /* saved X location of the viewport */ + int DisplayViewPortY; /* saved Y location of the viewport */ +#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */ + + int DisplayPointerX; /* saved X location of the pointer */ + int DisplayPointerY; /* saved Y location of the pointer */ +}; + + +/* + * Make "freeglut" window handle and context types so that we don't need so + * much conditionally-compiled code later in the library. + */ +typedef Window SFG_WindowHandleType ; +typedef GLXContext SFG_WindowContextType ; +typedef struct tagSFG_PlatformContext SFG_PlatformContext; +struct tagSFG_PlatformContext +{ + GLXFBConfig* FBConfig; /* The window's FBConfig */ +}; + + + +#endif +#if TARGET_HOST_MS_WINDOWS +#include "../mswin/freeglut_internal_mswin.h" +#endif + + /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */ /* Freeglut callbacks type definitions */ @@ -356,42 +399,7 @@ struct tagSFG_State typedef struct tagSFG_Display SFG_Display; struct tagSFG_Display { -#if TARGET_HOST_POSIX_X11 - Display* Display; /* The display we are being run in. */ - int Screen; /* The screen we are about to use. */ - Window RootWindow; /* The screen's root window. */ - int Connection; /* The display's connection number */ - Atom DeleteWindow; /* The window deletion atom */ - Atom State; /* The state atom */ - Atom StateFullScreen; /* The full screen atom */ - -#ifdef HAVE_X11_EXTENSIONS_XRANDR_H - int prev_xsz, prev_ysz; - int prev_refresh; - int prev_size_valid; -#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */ - -#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H - /* - * XF86VidMode may be compilable even if it fails at runtime. Therefore, - * the validity of the VidMode has to be tracked - */ - int DisplayModeValid; /* Flag that indicates runtime status*/ - XF86VidModeModeLine DisplayMode; /* Current screen's display settings */ - int DisplayModeClock; /* The display mode's refresh rate */ - int DisplayViewPortX; /* saved X location of the viewport */ - int DisplayViewPortY; /* saved Y location of the viewport */ -#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */ - - int DisplayPointerX; /* saved X location of the pointer */ - int DisplayPointerY; /* saved Y location of the pointer */ - -#elif TARGET_HOST_MS_WINDOWS - HINSTANCE Instance; /* The application's instance */ - DEVMODE DisplayMode; /* Desktop's display settings */ - char *DisplayName; /* Display name for multi display support*/ - -#endif + SFG_PlatformDisplay pDisplay; int ScreenWidth; /* The screen's width in pixels */ int ScreenHeight; /* The screen's height in pixels */ @@ -411,22 +419,6 @@ struct tagSFG_Timer }; /* - * 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_POSIX_X11 - -typedef Window SFG_WindowHandleType ; -typedef GLXContext SFG_WindowContextType ; - -#elif TARGET_HOST_MS_WINDOWS - -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... */ @@ -436,11 +428,7 @@ struct tagSFG_Context SFG_WindowHandleType Handle; /* The window's handle */ SFG_WindowContextType Context; /* The window's OpenGL/WGL context */ -#if TARGET_HOST_POSIX_X11 - GLXFBConfig* FBConfig; /* The window's FBConfig */ -#elif TARGET_HOST_MS_WINDOWS - HDC Device; /* The window's device context */ -#endif + SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */ int DoubleBuffered; /* Treat the window as double-buffered */ }; @@ -775,6 +763,86 @@ struct tagSFG_StrokeFont const SFG_StrokeChar** Characters; /* The characters mapping */ }; + +/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */ +/* XXX It might be better to poll the operating system for the numbers of buttons and + * XXX axes and then dynamically allocate the arrays. + */ +#define _JS_MAX_BUTTONS 32 + +#if TARGET_HOST_MACINTOSH +# define _JS_MAX_AXES 9 +typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick; +struct tagSFG_PlatformJoystick +{ +#define ISP_NUM_AXIS 9 +#define ISP_NUM_NEEDS 41 + ISpElementReference isp_elem [ ISP_NUM_NEEDS ]; + ISpNeed isp_needs [ ISP_NUM_NEEDS ]; +}; +#endif + +#if TARGET_HOST_MAC_OSX +# define _JS_MAX_AXES 16 +typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick; +struct tagSFG_PlatformJoystick +{ + IOHIDDeviceInterface ** hidDev; + IOHIDElementCookie buttonCookies[41]; + IOHIDElementCookie axisCookies[_JS_MAX_AXES]; +/* The next two variables are not used anywhere */ +/* long minReport[_JS_MAX_AXES], + * maxReport[_JS_MAX_AXES]; + */ +}; +#endif + +#if TARGET_HOST_POSIX_X11 +# define _JS_MAX_AXES 16 +typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick; +struct tagSFG_PlatformJoystick +{ +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) + struct os_specific_s *os; +# endif + +# ifdef JS_NEW + struct js_event js; + int tmp_buttons; + float tmp_axes [ _JS_MAX_AXES ]; +# else + struct JS_DATA_TYPE js; +# endif + + char fname [ 128 ]; + int fd; +}; +#endif + +/* + * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class. + * See "js.h" lines 80-178. + */ +typedef struct tagSFG_Joystick SFG_Joystick; +struct tagSFG_Joystick +{ + SFG_PlatformJoystick pJoystick; + + int id; + GLboolean error; + char name [ 128 ]; + int num_axes; + int num_buttons; + + float dead_band[ _JS_MAX_AXES ]; + float saturate [ _JS_MAX_AXES ]; + float center [ _JS_MAX_AXES ]; + float max [ _JS_MAX_AXES ]; + float min [ _JS_MAX_AXES ]; +}; + + + /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */ /* Freeglut display related stuff (initialized once per session) */ @@ -852,20 +920,6 @@ void fgDeinitialize( void ); void fgCreateStructure( void ); void fgDestroyStructure( void ); -/* A helper function to check if a display mode is possible to use */ -#if TARGET_HOST_POSIX_X11 -GLXFBConfig* fgChooseFBConfig( int* numcfgs ); -#endif - -/* The window procedure for Win32 events handling */ -#if TARGET_HOST_MS_WINDOWS -LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, - WPARAM wParam, LPARAM lParam ); -void fgNewWGLCreateContext( SFG_Window* window ); -GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, - unsigned char layer_type ); -#endif - /* * Window creation, opening, closing and destruction. * Also CallBack clearing/initialization. @@ -932,19 +986,6 @@ void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator ); void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback, SFG_Enumerator* enumerator ); -#if TARGET_HOST_MS_WINDOWS -/* - * Helper functions for getting client area from the window rect - * and the window rect from the client area given the style of the window - * (or a valid window pointer from which the style can be queried). - */ -void fghComputeWindowRectFromClientArea_UseStyle ( const DWORD windowStyle , RECT *clientRect, BOOL posIsOutside ); -void fghComputeWindowRectFromClientArea_QueryWindow( const SFG_Window *window, RECT *clientRect, BOOL posIsOutside ); -void fghComputeClientAreaFromWindowRect ( const SFG_Window *window, RECT *windowRect, BOOL wantPosOutside ); -RECT fghGetClientArea ( const SFG_Window *window, BOOL wantPosOutside ); -void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth); -#endif - /* * fgWindowByHandle returns a (SFG_Window *) value pointing to the * first window in the queue matching the specified window handle. @@ -1014,10 +1055,6 @@ int fgHintPresent(Window window, Atom property, Atom hint); SFG_Proc fghGetProcAddress( const char *procName ); -#if TARGET_HOST_MS_WINDOWS -extern void (__cdecl *__glutExitFunc)( int return_value ); -#endif - #endif /* FREEGLUT_INTERNAL_H */ /*** END OF FILE ***/