simplified some window rect calculations
[freeglut] / src / mswin / fg_state_mswin.c
index c4598d4..a217747 100644 (file)
@@ -37,7 +37,7 @@ extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
  * 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).
  */
-extern void fghGetClientArea( RECT *clientRect, const SFG_Window *window, BOOL wantPosOutside );
+extern void fghGetClientArea( RECT *clientRect, const SFG_Window *window );
 extern void fghGetStyleFromWindow( const SFG_Window *window, DWORD *windowStyle, DWORD *windowExStyle );
 extern void fghComputeWindowRectFromClientArea_UseStyle( RECT *clientRect, const DWORD windowStyle, const DWORD windowExStyle, BOOL posIsOutside );
 
@@ -141,10 +141,20 @@ int fgPlatformGlutGet ( GLenum eWhat )
       return returnValue;
 
     case GLUT_WINDOW_BUFFER_SIZE:
-      returnValue = 1 ;                                      /* TODO????? */
-      return returnValue;
+    {
+        PIXELFORMATDESCRIPTOR  pfd;
+        HDC hdc = fgStructure.CurrentWindow->Window.pContext.Device;
+        int iPixelFormat = GetPixelFormat( hdc );
+        DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+        
+        returnValue = pfd.cColorBits;
+        if (pfd.iPixelType==PFD_TYPE_RGBA)
+            returnValue += pfd.cAlphaBits;
+
+        return returnValue;
+    }
     case GLUT_WINDOW_STENCIL_SIZE:
-      returnValue = 0 ;                                      /* TODO????? */
+      glGetIntegerv ( GL_STENCIL_BITS, &returnValue );
       return returnValue;
 
     case GLUT_WINDOW_X:
@@ -226,15 +236,19 @@ int fgPlatformGlutGet ( GLenum eWhat )
 
             /* Get style of window, or default style */
             fghGetStyleFromWindow( fgStructure.CurrentWindow, &windowStyle, &windowExStyle );
-            /* Get client area if any window */
+            /* Get client area if we have a current window, else use dummy rect */
+            /* Also get window rect (including non-client area) */
             if (fgStructure.CurrentWindow && fgStructure.CurrentWindow->Window.Handle)
-                fghGetClientArea(&clientRect,fgStructure.CurrentWindow,FALSE);
+            {
+                fghGetClientArea(&clientRect,fgStructure.CurrentWindow);
+                GetWindowRect(fgStructure.CurrentWindow->Window.Handle,&winRect);
+            }
             else
+            {
                 SetRect(&clientRect,0,0,200,200);
-
-            /* Compute window rect (including non-client area) */
-            CopyRect(&winRect,&clientRect);
-            fghComputeWindowRectFromClientArea_UseStyle(&winRect,windowStyle,windowExStyle,FALSE);
+                CopyRect(&winRect,&clientRect);
+                fghComputeWindowRectFromClientArea_UseStyle(&winRect,windowStyle,windowExStyle,FALSE);
+            }
 
             /* Calculate border width by taking width of whole window minus width of client area and divide by two
              * NB: we assume horizontal and vertical borders have the same size, which should always be the case