Adding support for the multisampling query per bug report 1274193
authorJohn F. Fay <johnffay@nettally.com>
Thu, 21 Sep 2006 22:39:12 +0000 (22:39 +0000)
committerJohn F. Fay <johnffay@nettally.com>
Thu, 21 Sep 2006 22:39:12 +0000 (22:39 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@704 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_state.c
src/freeglut_window.c

index 4da1b5e..5a2f081 100644 (file)
@@ -119,6 +119,16 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
     }
 }
 
+#if TARGET_HOST_MS_WINDOWS
+/* WRONG-- FIXME */
+/* The following include file is available from SGI but is not standard:
+ *   #include <GL/wglext.h>
+ * So we copy the necessary parts out of it to support the multisampling query
+ */
+#define WGL_SAMPLES_ARB                0x2042
+#endif
+
+
 /*
  * General settings query method
  */
@@ -129,6 +139,8 @@ int FGAPIENTRY glutGet( GLenum eWhat )
     GLboolean boolValue ;
 #endif
 
+    int nsamples = 0;
+
     switch (eWhat)
     {
     case GLUT_INIT_STATE:
@@ -154,15 +166,17 @@ int FGAPIENTRY glutGet( GLenum eWhat )
     case GLUT_INIT_WINDOW_HEIGHT:   return fgState.Size.Y          ;
     case GLUT_INIT_DISPLAY_MODE:    return fgState.DisplayMode     ;
 
+#if TARGET_HOST_POSIX_X11
     /*
      * The window/context specific queries are handled mostly by
      * fghGetConfig().
      */
     case GLUT_WINDOW_NUM_SAMPLES:
-        /* XXX Multisampling. Return what I know about multisampling. */
-        return 0;
+#ifdef GLX_VERSION_1_3
+        glGetIntegerv(GL_SAMPLES, &nsamples);
+#endif
+        return nsamples;
 
-#if TARGET_HOST_POSIX_X11
     /*
      * The rest of GLX queries under X are general enough to use a macro to
      * check them
@@ -279,6 +293,10 @@ int FGAPIENTRY glutGet( GLenum eWhat )
 
 #elif TARGET_HOST_MS_WINDOWS
 
+    case GLUT_WINDOW_NUM_SAMPLES:
+      glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
+      return nsamples;
+
     /* Handle the OpenGL inquiries */
     case GLUT_WINDOW_RGBA:
       glGetBooleanv ( GL_RGBA_MODE, &boolValue );
index 58e95f4..c60aee0 100644 (file)
@@ -433,10 +433,12 @@ void fgOpenWindow( SFG_Window* window, const char* title,
             fgState.DisplayMode &= ~GLUT_DOUBLE;
         }
 
-        /*
-         * GLUT also checks for multi-sampling, but I don't see that
-         * anywhere else in FREEGLUT so I won't bother with it for the moment.
-         */
+        if( fgState.DisplayMode & GLUT_MULTISAMPLE )
+        {
+            fgState.DisplayMode &= ~GLUT_MULTISAMPLE ;
+            window->Window.VisualInfo = fgChooseVisual( );
+            fgState.DisplayMode &= GLUT_MULTISAMPLE;
+        }
     }
 
     FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.VisualInfo != NULL,