Splitting the X11-specific stuff out of "freeglut_internal.h" into its own file per...
[freeglut] / src / Common / freeglut_internal.h
index f0f9d57..4cca9e9 100644 (file)
@@ -33,8 +33,8 @@
 #endif\r
 \r
 /* XXX Update these for each release! */\r
-#define  VERSION_MAJOR 2\r
-#define  VERSION_MINOR 7\r
+#define  VERSION_MAJOR 3\r
+#define  VERSION_MINOR 0\r
 #define  VERSION_PATCH 0\r
 \r
 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */\r
 \r
 #define  FREEGLUT_MAX_MENUS         3\r
 \r
-/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */\r
-\r
-/* All Win32 headers depend on the huge windows.h recursive include.\r
- * Note: Lower-case header names are used, for best cross-platform\r
- * compatibility.\r
- */\r
-#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)\r
-#    include <windows.h>\r
-#    include <windowsx.h>\r
-#    include <mmsystem.h>\r
-/* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */\r
-#    ifndef __CYGWIN__\r
-#      include <tchar.h>\r
-#    else\r
-#      define _TEXT(x) TEXT(x)\r
-#      define _T(x)    TEXT(x)\r
-#    endif\r
-\r
-#elif TARGET_HOST_POSIX_X11\r
-#    include <GL/glx.h>\r
-#    include <X11/Xlib.h>\r
-#    include <X11/Xatom.h>\r
-#    include <X11/keysym.h>\r
-#    include <X11/extensions/XInput.h>\r
-#    ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H\r
-#        include <X11/extensions/xf86vmode.h>\r
-#    endif\r
-#    ifdef HAVE_X11_EXTENSIONS_XRANDR_H\r
-#        include <X11/extensions/Xrandr.h>\r
-#    endif\r
-/* If GLX is too old, we will fail during runtime when multisampling\r
-   is requested, but at least freeglut compiles. */\r
-#    ifndef GLX_SAMPLE_BUFFERS\r
-#        define GLX_SAMPLE_BUFFERS 0x80A8\r
-#    endif\r
-#    ifndef GLX_SAMPLES\r
-#        define GLX_SAMPLES 0x80A9\r
-#    endif\r
-\r
-#endif\r
-\r
 /* These files should be available on every platform. */\r
 #include <stdio.h>\r
 #include <string.h>\r
 #    endif\r
 #endif\r
 \r
-#if TARGET_HOST_MS_WINDOWS\r
-#    define  HAVE_VFPRINTF 1\r
-#endif\r
-\r
-/* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */\r
-#if TARGET_HOST_MS_WINDOWS && !defined(ChangeDisplaySettingsEx)\r
-LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);\r
-LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);\r
-#    ifdef UNICODE\r
-#        define ChangeDisplaySettingsEx ChangeDisplaySettingsExW\r
-#    else\r
-#        define ChangeDisplaySettingsEx ChangeDisplaySettingsExA\r
-#    endif\r
-#endif\r
-\r
 #if defined(_MSC_VER) || defined(__WATCOMC__)\r
 /* strdup() is non-standard, for all but POSIX-2001 */\r
 #define strdup   _strdup\r
@@ -210,6 +154,17 @@ LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
 \r
 #define INVALID_MODIFIERS 0xffffffff\r
 \r
+\r
+\r
+/* Platform-specific includes */\r
+#if TARGET_HOST_POSIX_X11\r
+#include "../x11/freeglut_internal_x11.h"\r
+#endif\r
+#if TARGET_HOST_MS_WINDOWS\r
+#include "../mswin/freeglut_internal_mswin.h"\r
+#endif\r
+\r
+\r
 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */\r
 \r
 /* Freeglut callbacks type definitions */\r
@@ -356,42 +311,7 @@ struct tagSFG_State
 typedef struct tagSFG_Display SFG_Display;\r
 struct tagSFG_Display\r
 {\r
-#if TARGET_HOST_POSIX_X11\r
-    Display*        Display;            /* The display we are being run in.  */\r
-    int             Screen;             /* The screen we are about to use.   */\r
-    Window          RootWindow;         /* The screen's root window.         */\r
-    int             Connection;         /* The display's connection number   */\r
-    Atom            DeleteWindow;       /* The window deletion atom          */\r
-    Atom            State;              /* The state atom                    */\r
-    Atom            StateFullScreen;    /* The full screen atom              */\r
-\r
-#ifdef HAVE_X11_EXTENSIONS_XRANDR_H\r
-    int prev_xsz, prev_ysz;\r
-    int prev_refresh;\r
-    int prev_size_valid;\r
-#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */\r
-\r
-#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H\r
-    /*\r
-     * XF86VidMode may be compilable even if it fails at runtime.  Therefore,\r
-     * the validity of the VidMode has to be tracked\r
-     */\r
-    int             DisplayModeValid;   /* Flag that indicates runtime status*/\r
-    XF86VidModeModeLine DisplayMode;    /* Current screen's display settings */\r
-    int             DisplayModeClock;   /* The display mode's refresh rate   */\r
-    int             DisplayViewPortX;   /* saved X location of the viewport  */\r
-    int             DisplayViewPortY;   /* saved Y location of the viewport  */\r
-#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */\r
-\r
-    int             DisplayPointerX;    /* saved X location of the pointer   */\r
-    int             DisplayPointerY;    /* saved Y location of the pointer   */\r
-\r
-#elif TARGET_HOST_MS_WINDOWS\r
-    HINSTANCE       Instance;           /* The application's instance        */\r
-    DEVMODE         DisplayMode;        /* Desktop's display settings        */\r
-    char           *DisplayName;        /* Display name for multi display support*/ \r
-\r
-#endif\r
+       SFG_PlatformDisplay pDisplay;\r
 \r
     int             ScreenWidth;        /* The screen's width in pixels      */\r
     int             ScreenHeight;       /* The screen's height in pixels     */\r
@@ -411,22 +331,6 @@ struct tagSFG_Timer
 };\r
 \r
 /*\r
- * Make "freeglut" window handle and context types so that we don't need so\r
- * much conditionally-compiled code later in the library.\r
- */\r
-#if TARGET_HOST_POSIX_X11\r
-\r
-typedef Window     SFG_WindowHandleType ;\r
-typedef GLXContext SFG_WindowContextType ;\r
-\r
-#elif TARGET_HOST_MS_WINDOWS\r
-\r
-typedef HWND    SFG_WindowHandleType ;\r
-typedef HGLRC   SFG_WindowContextType ;\r
-\r
-#endif\r
-\r
-/*\r
  * A window and its OpenGL context. The contents of this structure\r
  * are highly dependant on the target operating system we aim at...\r
  */\r
@@ -436,29 +340,20 @@ struct tagSFG_Context
     SFG_WindowHandleType  Handle;    /* The window's handle                 */\r
     SFG_WindowContextType Context;   /* The window's OpenGL/WGL context     */\r
 \r
-#if TARGET_HOST_POSIX_X11\r
-    GLXFBConfig*    FBConfig;        /* The window's FBConfig               */\r
-#elif TARGET_HOST_MS_WINDOWS\r
-    HDC             Device;          /* The window's device context         */\r
-#endif\r
+       SFG_PlatformContext pContext;    /* The window's FBConfig (X11) or device context (Windows) */\r
 \r
     int             DoubleBuffered;  /* Treat the window as double-buffered */\r
 };\r
 \r
-/* Window's state description. This structure should be kept portable. */\r
+\r
 typedef struct tagSFG_WindowState SFG_WindowState;\r
 struct tagSFG_WindowState\r
 {\r
     /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */\r
     int             Width;              /* Window's width in pixels          */\r
     int             Height;             /* The same about the height         */\r
-#if TARGET_HOST_POSIX_X11\r
-    int             OldWidth;           /* Window width from before a resize */\r
-    int             OldHeight;          /*   "    height  "    "    "   "    */\r
-#elif TARGET_HOST_MS_WINDOWS\r
-    RECT            OldRect;            /* window rect - stored before the window is made fullscreen */\r
-    DWORD           OldStyle;           /* window style - stored before the window is made fullscreen */\r
-#endif\r
+\r
+       SFG_PlatformWindowState pWState;    /* Window width/height (X11) or rectangle/style (Windows) from before a resize */\r
 \r
     GLboolean       Redisplay;          /* Do we have to redisplay?          */\r
     GLboolean       Visible;            /* Is the window visible now         */\r
@@ -775,6 +670,80 @@ struct tagSFG_StrokeFont
     const SFG_StrokeChar** Characters;          /* The characters mapping    */\r
 };\r
 \r
+\r
+/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */\r
+/*\r
+ * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"\r
+ * interspersed\r
+ */\r
+\r
+#if TARGET_HOST_MACINTOSH\r
+#    include <InputSprocket.h>\r
+#endif\r
+\r
+#if TARGET_HOST_MAC_OSX\r
+#    include <mach/mach.h>\r
+#    include <IOKit/IOkitLib.h>\r
+#    include <IOKit/hid/IOHIDLib.h>\r
+#endif\r
+\r
+/* XXX It might be better to poll the operating system for the numbers of buttons and\r
+ * XXX axes and then dynamically allocate the arrays.\r
+ */\r
+#define _JS_MAX_BUTTONS 32\r
+\r
+#if TARGET_HOST_MACINTOSH\r
+#    define _JS_MAX_AXES  9\r
+typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
+struct tagSFG_PlatformJoystick\r
+{\r
+#define  ISP_NUM_AXIS    9\r
+#define  ISP_NUM_NEEDS  41\r
+    ISpElementReference isp_elem  [ ISP_NUM_NEEDS ];\r
+    ISpNeed             isp_needs [ ISP_NUM_NEEDS ];\r
+};\r
+#endif\r
+\r
+#if TARGET_HOST_MAC_OSX\r
+#    define _JS_MAX_AXES 16\r
+typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
+struct tagSFG_PlatformJoystick\r
+{\r
+    IOHIDDeviceInterface ** hidDev;\r
+    IOHIDElementCookie buttonCookies[41];\r
+    IOHIDElementCookie axisCookies[_JS_MAX_AXES];\r
+/* The next two variables are not used anywhere */\r
+/*    long minReport[_JS_MAX_AXES],\r
+ *         maxReport[_JS_MAX_AXES];\r
+ */\r
+};\r
+#endif\r
+\r
+\r
+/*\r
+ * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.\r
+ * See "js.h" lines 80-178.\r
+ */\r
+typedef struct tagSFG_Joystick SFG_Joystick;\r
+struct tagSFG_Joystick\r
+{\r
+       SFG_PlatformJoystick pJoystick;\r
+\r
+    int          id;\r
+    GLboolean    error;\r
+    char         name [ 128 ];\r
+    int          num_axes;\r
+    int          num_buttons;\r
+\r
+    float dead_band[ _JS_MAX_AXES ];\r
+    float saturate [ _JS_MAX_AXES ];\r
+    float center   [ _JS_MAX_AXES ];\r
+    float max      [ _JS_MAX_AXES ];\r
+    float min      [ _JS_MAX_AXES ];\r
+};\r
+\r
+\r
+\r
 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */\r
 \r
 /* Freeglut display related stuff (initialized once per session) */\r
@@ -894,11 +863,6 @@ void        fgSpaceballSetWindow( SFG_Window *window );
 int         fgHasSpaceball( void );\r
 int         fgSpaceballNumButtons( void );\r
 \r
-#if TARGET_HOST_POSIX_X11\r
-int         fgIsSpaceballXEvent( const XEvent *ev );\r
-void        fgSpaceballHandleXEvent( const XEvent *ev );\r
-#endif\r
-\r
 /* Setting the cursor for a given window */\r
 void fgSetCursor ( SFG_Window *window, int cursorID );\r
 \r
@@ -971,25 +935,18 @@ void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);
 void fgError( const char *fmt, ... );\r
 void fgWarning( const char *fmt, ... );\r
 \r
-/*\r
- * Check if "hint" is present in "property" for "window".  See freeglut_init.c\r
- */\r
-#if TARGET_HOST_POSIX_X11\r
-int fgHintPresent(Window window, Atom property, Atom hint);\r
-\r
-/* Handler for X extension Events */\r
-#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H\r
-  void fgHandleExtensionEvents( XEvent * ev );\r
-  void fgRegisterDevices( Display* dpy, Window* win );\r
-#endif\r
-\r
-#endif\r
+SFG_Proc fgPlatformGetProcAddress( const char *procName );\r
 \r
-SFG_Proc fghGetProcAddress( const char *procName );\r
+/* Window functions needed for Platform implementations */\r
+/* pushing attribute/value pairs into an array */\r
+#define ATTRIB(a) attributes[where++]=(a)\r
+#define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}\r
 \r
-#if TARGET_HOST_MS_WINDOWS\r
-extern void (__cdecl *__glutExitFunc)( int return_value );\r
-#endif\r
+extern int fghIsLegacyContextVersionRequested( void );\r
+extern int fghMapBit( int mask, int from, int to );\r
+extern int fghIsLegacyContextRequested( void );\r
+extern void fghContextCreationError( void );\r
+extern int fghNumberOfAuxBuffersRequested( void );\r
 \r
 #endif /* FREEGLUT_INTERNAL_H */\r
 \r