implemented GLUT_WINDOW_STENCIL_SIZE and GLUT_WINDOW_BUFFER_SIZE for glutGet
authorDiederick Niehorster <dcnieho@gmail.com>
Thu, 28 Feb 2013 08:53:31 +0000 (08:53 +0000)
committerDiederick Niehorster <dcnieho@gmail.com>
Thu, 28 Feb 2013 08:53:31 +0000 (08:53 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1529 7f0cb862-5218-0410-a997-914c9d46530a

progs/demos/One/one.c
src/mswin/fg_state_mswin.c

index 6509c3b..e8b08b3 100644 (file)
@@ -387,6 +387,12 @@ int main( int argc, char** argv )
     );
 
     /*
+     * Describe pixel format
+     */
+    printf("The current window has %i red bits, %i green bits, %i blue bits and %i alpha bits for a total buffer size of %i bits\n",glutGet(GLUT_WINDOW_RED_SIZE),glutGet(GLUT_WINDOW_GREEN_SIZE),glutGet(GLUT_WINDOW_BLUE_SIZE),glutGet(GLUT_WINDOW_ALPHA_SIZE),glutGet(GLUT_WINDOW_BUFFER_SIZE));
+    printf("It furthermore has %i depth bits and %i stencil bits\n",glutGet(GLUT_WINDOW_DEPTH_SIZE),glutGet(GLUT_WINDOW_STENCIL_SIZE));
+
+    /*
      * Enter the main FreeGLUT processing loop
      */
     glutMainLoop();
index c4598d4..27a9461 100644 (file)
@@ -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: