Moving the platform-specific FBConfig and device context variables into platform...
[freeglut] / src / Common / freeglut_internal.h
index cb527ff..f4fc756 100644 (file)
@@ -210,6 +210,65 @@ 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
+\r
+typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;\r
+struct tagSFG_PlatformDisplay\r
+{\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
+\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
+typedef Window     SFG_WindowHandleType ;\r
+typedef GLXContext SFG_WindowContextType ;\r
+typedef struct tagSFG_PlatformContext SFG_PlatformContext;\r
+struct tagSFG_PlatformContext\r
+{\r
+    GLXFBConfig*    FBConfig;        /* The window's FBConfig               */\r
+};\r
+\r
+\r
+\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 +415,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 +435,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,11 +444,7 @@ 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
@@ -918,19 +922,6 @@ void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
 void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,\r
                        SFG_Enumerator* enumerator );\r
 \r
-#if TARGET_HOST_MS_WINDOWS\r
-/* \r
- * Helper functions for getting client area from the window rect\r
- * and the window rect from the client area given the style of the window\r
- * (or a valid window pointer from which the style can be queried).\r
- */\r
-void fghComputeWindowRectFromClientArea_UseStyle   ( const DWORD windowStyle , RECT *clientRect, BOOL posIsOutside );\r
-void fghComputeWindowRectFromClientArea_QueryWindow( const SFG_Window *window, RECT *clientRect, BOOL posIsOutside );\r
-void fghComputeClientAreaFromWindowRect            ( const SFG_Window *window, RECT *windowRect, BOOL wantPosOutside );\r
-RECT fghGetClientArea                              ( const SFG_Window *window,                   BOOL wantPosOutside );\r
-void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth);\r
-#endif\r
-\r
 /*\r
  * fgWindowByHandle returns a (SFG_Window *) value pointing to the\r
  * first window in the queue matching the specified window handle.\r