Moving the platform-specific FBConfig and device context variables into platform...
authorJohn F. Fay <johnffay@nettally.com>
Sun, 29 Jan 2012 03:15:41 +0000 (03:15 +0000)
committerJohn F. Fay <johnffay@nettally.com>
Sun, 29 Jan 2012 03:15:41 +0000 (03:15 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1014 7f0cb862-5218-0410-a997-914c9d46530a

src/Common/freeglut_internal.h
src/Common/freeglut_state.c
src/Common/freeglut_structure.c
src/Common/freeglut_window.c
src/mswin/freeglut_display_mswin.c
src/mswin/freeglut_internal_mswin.h
src/mswin/freeglut_main_mswin.c
src/mswin/freeglut_state_mswin.c
src/mswin/freeglut_window_mswin.c

index 815d13e..f4fc756 100644 (file)
@@ -255,6 +255,12 @@ struct tagSFG_PlatformDisplay
  */\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
@@ -438,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
index 434b41f..6630b6d 100644 (file)
@@ -66,7 +66,7 @@ static int fghGetConfig( int attribute )
 \r
   if( fgStructure.CurrentWindow )\r
       result = glXGetFBConfigAttrib( fgDisplay.Display,\r
-                                     *(fgStructure.CurrentWindow->Window.FBConfig),\r
+                                     *(fgStructure.CurrentWindow->Window.pContext.FBConfig),\r
                                      attribute,\r
                                      &returnValue );\r
 \r
@@ -125,7 +125,7 @@ int fgPlatformGlutGet ( GLenum eWhat )
         else\r
         {\r
           const GLXFBConfig * fbconfig =\r
-                fgStructure.CurrentWindow->Window.FBConfig;\r
+                fgStructure.CurrentWindow->Window.pContext.FBConfig;\r
 \r
           XVisualInfo * visualInfo =\r
                 glXGetVisualFromFBConfig( fgDisplay.Display, *fbconfig );\r
index f8d748f..56798f1 100644 (file)
@@ -63,7 +63,7 @@ static void fghClearCallBacks( SFG_Window *window )
 #if TARGET_HOST_POSIX_X11\r
 void fgPlatformCreateWindow ( SFG_Window *window )\r
 {\r
-    window->Window.FBConfig = NULL;\r
+    window->Window.pContext.FBConfig = NULL;\r
 \r
     window->State.OldHeight = window->State.OldWidth = -1;\r
 }\r
index 8a44d1a..1468627 100644 (file)
@@ -398,7 +398,7 @@ static GLXContext fghCreateNewContext( SFG_Window* window )
 \r
   /* "classic" context creation */\r
   Display *dpy = fgDisplay.Display;\r
-  GLXFBConfig config = *(window->Window.FBConfig);\r
+  GLXFBConfig config = *(window->Window.pContext.FBConfig);\r
   int render_type = ( !menu && index_mode ) ? GLX_COLOR_INDEX_TYPE : GLX_RGBA_TYPE;\r
   GLXContext share_list = NULL;\r
   Bool direct = ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT );\r
@@ -548,12 +548,12 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
     if( window->IsMenu && ( ! fgStructure.MenuContext ) )\r
         fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB ;\r
 \r
-    window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );\r
+    window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs );\r
 \r
     if( window->IsMenu && ( ! fgStructure.MenuContext ) )\r
         fgState.DisplayMode = current_DisplayMode ;\r
 \r
-    if( ! window->Window.FBConfig )\r
+    if( ! window->Window.pContext.FBConfig )\r
     {\r
         /*\r
          * The "fgChooseFBConfig" returned a null meaning that the visual\r
@@ -563,25 +563,25 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
         if( !( fgState.DisplayMode & GLUT_DOUBLE ) )\r
         {\r
             fgState.DisplayMode |= GLUT_DOUBLE ;\r
-            window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );\r
+            window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs );\r
             fgState.DisplayMode &= ~GLUT_DOUBLE;\r
         }\r
 \r
         if( fgState.DisplayMode & GLUT_MULTISAMPLE )\r
         {\r
             fgState.DisplayMode &= ~GLUT_MULTISAMPLE ;\r
-            window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );\r
+            window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs );\r
             fgState.DisplayMode |= GLUT_MULTISAMPLE;\r
         }\r
     }\r
 \r
-    FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.FBConfig != NULL,\r
+    FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.pContext.FBConfig != NULL,\r
                                   "FBConfig with necessary capabilities not found", "fgOpenWindow" );\r
 \r
     /*  Get the X visual.  */\r
     for (i = 0; i < num_FBConfigs; i++) {\r
            visualInfo = glXGetVisualFromFBConfig( fgDisplay.Display,\r
-                                                  window->Window.FBConfig[i] );\r
+                                                  window->Window.pContext.FBConfig[i] );\r
            if (visualInfo)\r
                break;\r
     }\r
@@ -750,7 +750,7 @@ void fgPlatformCloseWindow( SFG_Window* window )
 {\r
     if( window->Window.Context )\r
         glXDestroyContext( fgDisplay.Display, window->Window.Context );\r
-    XFree( window->Window.FBConfig );\r
+    XFree( window->Window.pContext.FBConfig );\r
 \r
     if( window->Window.Handle ) {\r
         XDestroyWindow( fgDisplay.Display, window->Window.Handle );\r
index 9437382..d93675c 100644 (file)
@@ -33,5 +33,5 @@
 \r
 void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )\r
 {\r
-    SwapBuffers( CurrentWindow->Window.Device );\r
+    SwapBuffers( CurrentWindow->Window.pContext.Device );\r
 }\r
index bd392f0..628c06d 100644 (file)
@@ -42,6 +42,12 @@ struct tagSFG_PlatformDisplay
  */\r
 typedef HWND    SFG_WindowHandleType ;\r
 typedef HGLRC   SFG_WindowContextType ;\r
+typedef struct tagSFG_PlatformContext SFG_PlatformContext;\r
+struct tagSFG_PlatformContext\r
+{\r
+    HDC             Device;          /* The window's device context         */\r
+};\r
+\r
 \r
 \r
 \r
index b4d1bc9..b04e9e0 100644 (file)
@@ -329,7 +329,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
                                        "fgPlatformWindowProc" );\r
 \r
         window->Window.Handle = hWnd;\r
-        window->Window.Device = GetDC( hWnd );\r
+        window->Window.pContext.Device = GetDC( hWnd );\r
         if( window->IsMenu )\r
         {\r
             unsigned int current_DisplayMode = fgState.DisplayMode;\r
@@ -340,7 +340,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
             fgState.DisplayMode = current_DisplayMode;\r
 \r
             if( fgStructure.MenuContext )\r
-                wglMakeCurrent( window->Window.Device,\r
+                wglMakeCurrent( window->Window.pContext.Device,\r
                                 fgStructure.MenuContext->MContext\r
                 );\r
             else\r
@@ -348,11 +348,11 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
                 fgStructure.MenuContext =\r
                     (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );\r
                 fgStructure.MenuContext->MContext =\r
-                    wglCreateContext( window->Window.Device );\r
+                    wglCreateContext( window->Window.pContext.Device );\r
             }\r
 \r
             /* window->Window.Context = wglGetCurrentContext ();   */\r
-            window->Window.Context = wglCreateContext( window->Window.Device );\r
+            window->Window.Context = wglCreateContext( window->Window.pContext.Device );\r
         }\r
         else\r
         {\r
@@ -362,13 +362,13 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
 \r
             if( ! fgState.UseCurrentContext )\r
                 window->Window.Context =\r
-                    wglCreateContext( window->Window.Device );\r
+                    wglCreateContext( window->Window.pContext.Device );\r
             else\r
             {\r
                 window->Window.Context = wglGetCurrentContext( );\r
                 if( ! window->Window.Context )\r
                     window->Window.Context =\r
-                        wglCreateContext( window->Window.Device );\r
+                        wglCreateContext( window->Window.pContext.Device );\r
             }\r
 \r
 #if !defined(_WIN32_WCE)\r
@@ -391,7 +391,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
             fgSetWindow( current_window );\r
         }\r
 \r
-        ReleaseDC( window->Window.Handle, window->Window.Device );\r
+        ReleaseDC( window->Window.Handle, window->Window.pContext.Device );\r
 \r
 #if defined(_WIN32_WCE)\r
         /* Take over button handling */\r
index ed1f57e..1f9966b 100644 (file)
@@ -229,7 +229,7 @@ int fgPlatformGlutGet ( GLenum eWhat )
     case GLUT_WINDOW_FORMAT_ID:\r
 #if !defined(_WIN32_WCE)\r
         if( fgStructure.CurrentWindow != NULL )\r
-            return GetPixelFormat( fgStructure.CurrentWindow->Window.Device );\r
+            return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device );\r
 #endif /* defined(_WIN32_WCE) */\r
         return 0;\r
 \r
index bf4ef04..583d5f7 100644 (file)
@@ -169,9 +169,9 @@ void fgNewWGLCreateContext( SFG_Window* window )
         return;\r
     }\r
 \r
-    wglMakeCurrent( window->Window.Device, window->Window.Context );\r
+    wglMakeCurrent( window->Window.pContext.Device, window->Window.Context );\r
 \r
-    if ( !fghIsExtensionSupported( window->Window.Device, "WGL_ARB_create_context" ) )\r
+    if ( !fghIsExtensionSupported( window->Window.pContext.Device, "WGL_ARB_create_context" ) )\r
     {\r
         return;\r
     }\r
@@ -185,7 +185,7 @@ void fgNewWGLCreateContext( SFG_Window* window )
         fgError( "wglCreateContextAttribsARB not found" );\r
     }\r
 \r
-    context = wglCreateContextAttribsARB( window->Window.Device, 0, attributes );\r
+    context = wglCreateContextAttribsARB( window->Window.pContext.Device, 0, attributes );\r
     if ( context == NULL )\r
     {\r
         fghContextCreationError();\r
@@ -296,7 +296,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
     if (checkOnly)\r
       current_hDC = CreateDC(TEXT("DISPLAY"), NULL ,NULL ,NULL);\r
     else\r
-      current_hDC = window->Window.Device;\r
+      current_hDC = window->Window.pContext.Device;\r
 \r
     fghFillPFD( ppfd, current_hDC, layer_type );\r
     pixelformat = ChoosePixelFormat( current_hDC, ppfd );\r
@@ -370,13 +370,13 @@ void fgPlatformSetWindow ( SFG_Window *window )
     {\r
         if( fgStructure.CurrentWindow )\r
             ReleaseDC( fgStructure.CurrentWindow->Window.Handle,\r
-                       fgStructure.CurrentWindow->Window.Device );\r
+                       fgStructure.CurrentWindow->Window.pContext.Device );\r
 \r
         if ( window )\r
         {\r
-            window->Window.Device = GetDC( window->Window.Handle );\r
+            window->Window.pContext.Device = GetDC( window->Window.Handle );\r
             wglMakeCurrent(\r
-                window->Window.Device,\r
+                window->Window.pContext.Device,\r
                 window->Window.Context\r
             );\r
         }\r