Demos (master): glxgears: Add support for multisample visuals

Chad Versace chadversary at kemper.freedesktop.org
Sun Jul 22 00:38:49 UTC 2012


Module: Demos
Branch: master
Commit: 0ff766c656a7ab81a8a559e785b7fdad5038b214
URL:    http://cgit.freedesktop.org/mesa/demos/commit/?id=0ff766c656a7ab81a8a559e785b7fdad5038b214

Author: Chad Versace <chad.versace at linux.intel.com>
Date:   Fri Jul 20 09:41:43 2012 -0700

glxgears: Add support for multisample visuals

Add a command line parameter, `-sample N`, which selects a visual with at
least N samples.

Reviewed-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>

---

 src/xdemos/glxgears.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/xdemos/glxgears.c b/src/xdemos/glxgears.c
index 74b0bfd..79b7226 100644
--- a/src/xdemos/glxgears.c
+++ b/src/xdemos/glxgears.c
@@ -102,6 +102,7 @@ static GLfloat angle = 0.0;
 
 static GLboolean fullscreen = GL_FALSE;	/* Create a single fullscreen window */
 static GLboolean stereo = GL_FALSE;	/* Enable stereo.  */
+static GLint samples = 0;               /* Choose visual with at least N samples. */
 static GLboolean animate = GL_TRUE;	/* Animation */
 static GLfloat eyesep = 5.0;		/* Eye separation. */
 static GLfloat fix_point = 40.0;	/* Fixation point distance.  */
@@ -504,6 +505,12 @@ make_window( Display *dpy, const char *name,
    attribs[i++] = 1;
    attribs[i++] = GLX_DEPTH_SIZE;
    attribs[i++] = 1;
+   if (samples > 0) {
+      attribs[i++] = GLX_SAMPLE_BUFFERS;
+      attribs[i++] = 1;
+      attribs[i++] = GLX_SAMPLES;
+      attribs[i++] = samples;
+   }
 
    attribs[i++] = None;
 
@@ -521,6 +528,8 @@ make_window( Display *dpy, const char *name,
       printf("Error: couldn't get an RGB, Double-buffered");
       if (stereo)
          printf(", Stereo");
+      if (samples > 0)
+         printf(", Multisample");
       printf(" visual\n");
       exit(1);
    }
@@ -707,6 +716,7 @@ usage(void)
    printf("Usage:\n");
    printf("  -display <displayname>  set the display to run on\n");
    printf("  -stereo                 run in stereo mode\n");
+   printf("  -samples N              run in multisample mode with at least N samples\n");
    printf("  -fullscreen             run in fullscreen mode\n");
    printf("  -info                   display OpenGL renderer info\n");
    printf("  -geometry WxH+X+Y       window geometry\n");
@@ -736,6 +746,10 @@ main(int argc, char *argv[])
       else if (strcmp(argv[i], "-stereo") == 0) {
          stereo = GL_TRUE;
       }
+      else if (i < argc-1 && strcmp(argv[i], "-samples") == 0) {
+         samples = strtod(argv[i+1], NULL );
+         ++i;
+      }
       else if (strcmp(argv[i], "-fullscreen") == 0) {
          fullscreen = GL_TRUE;
       }




More information about the mesa-commit mailing list