X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_internal.h;h=4cca9e9ebbdf76b93d3607b8ff78b9b90e0f2513;hb=2537114893dba103beba5fd88b21e832098f1175;hp=cb527ff0695cfbab86a9ce2691326f1265f962b4;hpb=b7ffd3e60d961de87355b3027e589eb150337e60;p=freeglut diff --git a/src/Common/freeglut_internal.h b/src/Common/freeglut_internal.h index cb527ff..4cca9e9 100644 --- a/src/Common/freeglut_internal.h +++ b/src/Common/freeglut_internal.h @@ -33,8 +33,8 @@ #endif /* XXX Update these for each release! */ -#define VERSION_MAJOR 2 -#define VERSION_MINOR 7 +#define VERSION_MAJOR 3 +#define VERSION_MINOR 0 #define VERSION_PATCH 0 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */ @@ -86,47 +86,6 @@ #define FREEGLUT_MAX_MENUS 3 -/* -- 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 -# include -# include -# include -# include -# include -# ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H -# include -# endif -# ifdef HAVE_X11_EXTENSIONS_XRANDR_H -# include -# endif -/* If GLX is too old, we will fail during runtime when multisampling - is requested, but at least freeglut compiles. */ -# ifndef GLX_SAMPLE_BUFFERS -# define GLX_SAMPLE_BUFFERS 0x80A8 -# endif -# ifndef GLX_SAMPLES -# define GLX_SAMPLES 0x80A9 -# endif - -#endif - /* These files should be available on every platform. */ #include #include @@ -164,21 +123,6 @@ # endif #endif -#if TARGET_HOST_MS_WINDOWS -# define HAVE_VFPRINTF 1 -#endif - -/* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */ -#if TARGET_HOST_MS_WINDOWS && !defined(ChangeDisplaySettingsEx) -LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID); -LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID); -# ifdef UNICODE -# define ChangeDisplaySettingsEx ChangeDisplaySettingsExW -# else -# define ChangeDisplaySettingsEx ChangeDisplaySettingsExA -# endif -#endif - #if defined(_MSC_VER) || defined(__WATCOMC__) /* strdup() is non-standard, for all but POSIX-2001 */ #define strdup _strdup @@ -210,6 +154,17 @@ LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID); #define INVALID_MODIFIERS 0xffffffff + + +/* Platform-specific includes */ +#if TARGET_HOST_POSIX_X11 +#include "../x11/freeglut_internal_x11.h" +#endif +#if TARGET_HOST_MS_WINDOWS +#include "../mswin/freeglut_internal_mswin.h" +#endif + + /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */ /* Freeglut callbacks type definitions */ @@ -356,42 +311,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 +331,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,29 +340,20 @@ 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 */ }; -/* Window's state description. This structure should be kept portable. */ + typedef struct tagSFG_WindowState SFG_WindowState; struct tagSFG_WindowState { /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */ int Width; /* Window's width in pixels */ int Height; /* The same about the height */ -#if TARGET_HOST_POSIX_X11 - int OldWidth; /* Window width from before a resize */ - int OldHeight; /* " height " " " " */ -#elif TARGET_HOST_MS_WINDOWS - RECT OldRect; /* window rect - stored before the window is made fullscreen */ - DWORD OldStyle; /* window style - stored before the window is made fullscreen */ -#endif + + SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize */ GLboolean Redisplay; /* Do we have to redisplay? */ GLboolean Visible; /* Is the window visible now */ @@ -775,6 +670,80 @@ struct tagSFG_StrokeFont const SFG_StrokeChar** Characters; /* The characters mapping */ }; + +/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */ +/* + * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c" + * interspersed + */ + +#if TARGET_HOST_MACINTOSH +# include +#endif + +#if TARGET_HOST_MAC_OSX +# include +# include +# include +#endif + +/* 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 + + +/* + * 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) */ @@ -894,11 +863,6 @@ void fgSpaceballSetWindow( SFG_Window *window ); int fgHasSpaceball( void ); int fgSpaceballNumButtons( void ); -#if TARGET_HOST_POSIX_X11 -int fgIsSpaceballXEvent( const XEvent *ev ); -void fgSpaceballHandleXEvent( const XEvent *ev ); -#endif - /* Setting the cursor for a given window */ void fgSetCursor ( SFG_Window *window, int cursorID ); @@ -918,19 +882,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. @@ -984,25 +935,18 @@ void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node); void fgError( const char *fmt, ... ); void fgWarning( const char *fmt, ... ); -/* - * Check if "hint" is present in "property" for "window". See freeglut_init.c - */ -#if TARGET_HOST_POSIX_X11 -int fgHintPresent(Window window, Atom property, Atom hint); - -/* Handler for X extension Events */ -#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H - void fgHandleExtensionEvents( XEvent * ev ); - void fgRegisterDevices( Display* dpy, Window* win ); -#endif - -#endif +SFG_Proc fgPlatformGetProcAddress( const char *procName ); -SFG_Proc fghGetProcAddress( const char *procName ); +/* Window functions needed for Platform implementations */ +/* pushing attribute/value pairs into an array */ +#define ATTRIB(a) attributes[where++]=(a) +#define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);} -#if TARGET_HOST_MS_WINDOWS -extern void (__cdecl *__glutExitFunc)( int return_value ); -#endif +extern int fghIsLegacyContextVersionRequested( void ); +extern int fghMapBit( int mask, int from, int to ); +extern int fghIsLegacyContextRequested( void ); +extern void fghContextCreationError( void ); +extern int fghNumberOfAuxBuffersRequested( void ); #endif /* FREEGLUT_INTERNAL_H */