diff -uNr gtkglext-1.2.0-orig/configure.in gtkglext-1.2.0-modif/configure.in
--- gtkglext-1.2.0-orig/configure.in	2006-02-05 05:17:19.000000000 +0200
+++ gtkglext-1.2.0-modif/configure.in	2008-05-20 17:18:53.000000000 +0300
@@ -59,10 +59,15 @@
 m4_define([pango_pkg], [pango])
 m4_define([pango_required_version], [1.0.0])
 
+
 # Pangox
 m4_define([pangox_pkg], [pangox])
 m4_define([pangox_required_version], [1.0.0])
 
+# Pangowin32
+m4_define([pangowin32_pkg], [pangowin32])
+m4_define([pangowin32_required_version], [1.0.0])
+
 # PangoFT2
 m4_define([pangoft2_pkg], [pangoft2])
 m4_define([pangoft2_required_version], [1.0.0])
@@ -345,13 +350,12 @@
 ## calls. Oh, also the later pkg-config calls don't include 
 ## the version requirements since those make the module lists 
 ## annoying to construct
-PKG_CHECK_MODULES([BASE_DEPENDENCIES], [\
-gtk_pkg >= gtk_required_version \
-gdk_pkg >= gdk_required_version \
-pango_pkg >= pango_required_version \
-pangox_pkg >= pangox_required_version \
-gmodule_pkg >= gmodule_required_version \
-])
+if test "x$platform_win32" = "xyes"; then
+  base_dep_args="gtk_pkg >= gtk_required_version gdk_pkg >= gdk_required_version pango_pkg >= pango_required_version pangowin32_pkg >= pangowin32_required_version gmodule_pkg >= gmodule_required_version"
+else
+  base_dep_args="gtk_pkg >= gtk_required_version gdk_pkg >= gdk_required_version pango_pkg >= pango_required_version pangox_pkg >= pangox_required_version gmodule_pkg >= gmodule_required_version"
+fi
+PKG_CHECK_MODULES([BASE_DEPENDENCIES], [ $base_dep_args ])
 
 # Check for GLib
 AM_PATH_GLIB_2_0([glib_required_version], ,
@@ -793,8 +797,11 @@
 ##################################################
 # CFLAGS and LIBS
 ##################################################
-
-GDKGLEXT_PACKAGES="gdk_pkg pango_pkg pangox_pkg gmodule_pkg"
+if test "x$platform_win32" = "xyes"; then
+  GDKGLEXT_PACKAGES="gdk_pkg pango_pkg pangowin32_pkg gmodule_pkg"
+else
+  GDKGLEXT_PACKAGES="gdk_pkg pango_pkg pangox_pkg gmodule_pkg"
+fi
 GDKGLEXT_EXTRA_CFLAGS="$GL_CFLAGS $GDKGLEXT_WIN_CFLAGS"
 GDKGLEXT_EXTRA_LIBS="$GL_LIBS $GDKGLEXT_WIN_LIBS"
 GDKGLEXT_DEP_CFLAGS="$GDKGLEXT_EXTRA_CFLAGS `$PKG_CONFIG --cflags $GDKGLEXT_PACKAGES`"
diff -uNr gtkglext-1.2.0-orig/examples/simple-multisample.c gtkglext-1.2.0-modif/examples/simple-multisample.c
--- gtkglext-1.2.0-orig/examples/simple-multisample.c	1970-01-01 02:00:00.000000000 +0200
+++ gtkglext-1.2.0-modif/examples/simple-multisample.c	2008-05-20 14:50:51.000000000 +0300
@@ -0,0 +1,336 @@
+/*
+ * simple-multisample.c:
+ * Simple GtkGLExt example.
+ *
+ * written by Naofumi Yasufuku  <naofumi@users.sourceforge.net>
+ */
+
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include <gtk/gtkgl.h>
+
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glext.h> /* GL_MULTISAMPLE_ARB */
+
+static void
+realize (GtkWidget *widget,
+         gpointer   data)
+{
+  GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
+  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
+
+  GLUquadricObj *qobj;
+  static GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0};
+  static GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};
+
+  /*** OpenGL BEGIN ***/
+  if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
+    return;
+
+  qobj = gluNewQuadric ();
+  gluQuadricDrawStyle (qobj, GLU_FILL);
+  glNewList (1, GL_COMPILE);
+  gluSphere (qobj, 1.0, 20, 20);
+  glEndList ();
+
+  glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+  glLightfv (GL_LIGHT0, GL_POSITION, light_position);
+  glEnable (GL_LIGHTING);
+  glEnable (GL_LIGHT0);
+  glEnable (GL_DEPTH_TEST);
+
+  glClearColor (1.0, 1.0, 1.0, 1.0);
+  glClearDepth (1.0);
+
+  glViewport (0, 0,
+              widget->allocation.width, widget->allocation.height);
+
+  glMatrixMode (GL_PROJECTION);
+  glLoadIdentity ();
+  gluPerspective (40.0, 1.0, 1.0, 10.0);
+
+  glMatrixMode (GL_MODELVIEW);
+  glLoadIdentity ();
+  gluLookAt (0.0, 0.0, 3.0,
+             0.0, 0.0, 0.0,
+             0.0, 1.0, 0.0);
+  glTranslatef (0.0, 0.0, -3.0);
+
+  gdk_gl_drawable_gl_end (gldrawable);
+  /*** OpenGL END ***/
+}
+
+static gboolean
+configure_event (GtkWidget         *widget,
+                 GdkEventConfigure *event,
+                 gpointer           data)
+{
+  GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
+  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
+
+  /*** OpenGL BEGIN ***/
+  if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
+    return FALSE;
+
+  glViewport (0, 0,
+              widget->allocation.width, widget->allocation.height);
+
+  gdk_gl_drawable_gl_end (gldrawable);
+  /*** OpenGL END ***/
+
+  return TRUE;
+}
+
+static gboolean
+expose_event (GtkWidget      *widget,
+              GdkEventExpose *event,
+              gpointer        data)
+{
+  GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
+  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
+
+  /*** OpenGL BEGIN ***/
+  if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
+    return FALSE;
+
+  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+  if(gdk_gl_config_has_multisample_buffer (gtk_widget_get_gl_config(widget)))
+    {
+      glEnable(GL_MULTISAMPLE_ARB);
+      g_print("GL_MULTISAMPLE_ARB enabled\n");
+    }
+
+  glCallList (1);
+
+  if (gdk_gl_drawable_is_double_buffered (gldrawable))
+    gdk_gl_drawable_swap_buffers (gldrawable);
+  else
+    glFlush ();
+
+  gdk_gl_drawable_gl_end (gldrawable);
+  /*** OpenGL END ***/
+
+  return TRUE;
+}
+
+static void
+print_gl_config_attrib (GdkGLConfig *glconfig,
+                        const gchar *attrib_str,
+                        int          attrib,
+                        gboolean     is_boolean)
+{
+  int value;
+
+  g_print ("%s = ", attrib_str);
+  if (gdk_gl_config_get_attrib (glconfig, attrib, &value))
+    {
+      if (is_boolean)
+        g_print ("%s\n", value == TRUE ? "TRUE" : "FALSE");
+      else
+        g_print ("%d\n", value);
+    }
+  else
+    g_print ("*** Cannot get %s attribute value\n", attrib_str);
+}
+
+static void
+examine_gl_config_attrib (GdkGLConfig *glconfig)
+{
+  g_print ("\nOpenGL visual configurations :\n\n");
+
+  g_print ("gdk_gl_config_is_rgba (glconfig) = %s\n",
+           gdk_gl_config_is_rgba (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_is_double_buffered (glconfig) = %s\n",
+           gdk_gl_config_is_double_buffered (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_is_stereo (glconfig) = %s\n",
+           gdk_gl_config_is_stereo (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_has_alpha (glconfig) = %s\n",
+           gdk_gl_config_has_alpha (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_has_depth_buffer (glconfig) = %s\n",
+           gdk_gl_config_has_depth_buffer (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n",
+           gdk_gl_config_has_stencil_buffer (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_has_accum_buffer (glconfig) = %s\n",
+           gdk_gl_config_has_accum_buffer (glconfig) ? "TRUE" : "FALSE");
+  g_print ("gdk_gl_config_has_multisample_buffer (glconfig) = %s\n",
+           gdk_gl_config_has_multisample_buffer (glconfig) ? "TRUE" : "FALSE");
+
+  g_print ("\n");
+
+  print_gl_config_attrib (glconfig, "GDK_GL_USE_GL",           GDK_GL_USE_GL,           TRUE);
+  print_gl_config_attrib (glconfig, "GDK_GL_BUFFER_SIZE",      GDK_GL_BUFFER_SIZE,      FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_LEVEL",            GDK_GL_LEVEL,            FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_RGBA",             GDK_GL_RGBA,             TRUE);
+  print_gl_config_attrib (glconfig, "GDK_GL_DOUBLEBUFFER",     GDK_GL_DOUBLEBUFFER,     TRUE);
+  print_gl_config_attrib (glconfig, "GDK_GL_STEREO",           GDK_GL_STEREO,           TRUE);
+  print_gl_config_attrib (glconfig, "GDK_GL_AUX_BUFFERS",      GDK_GL_AUX_BUFFERS,      FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_RED_SIZE",         GDK_GL_RED_SIZE,         FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_GREEN_SIZE",       GDK_GL_GREEN_SIZE,       FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_BLUE_SIZE",        GDK_GL_BLUE_SIZE,        FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_ALPHA_SIZE",       GDK_GL_ALPHA_SIZE,       FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_DEPTH_SIZE",       GDK_GL_DEPTH_SIZE,       FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_STENCIL_SIZE",     GDK_GL_STENCIL_SIZE,     FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_RED_SIZE",   GDK_GL_ACCUM_RED_SIZE,   FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_GREEN_SIZE", GDK_GL_ACCUM_GREEN_SIZE, FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_BLUE_SIZE",  GDK_GL_ACCUM_BLUE_SIZE,  FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_ALPHA_SIZE", GDK_GL_ACCUM_ALPHA_SIZE, FALSE);
+  print_gl_config_attrib (glconfig, "GDK_GL_SAMPLE_BUFFERS",   GDK_GL_SAMPLE_BUFFERS,   TRUE);
+  print_gl_config_attrib (glconfig, "GDK_GK_SAMPLES",          GDK_GL_SAMPLES,          FALSE);
+
+  g_print ("\n");
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+  GdkGLConfig *glconfig;
+  gint major, minor;
+
+  GtkWidget *window;
+  GtkWidget *vbox;
+  GtkWidget *drawing_area;
+  GtkWidget *button;
+
+  /*
+   * Init GTK.
+   */
+
+  gtk_init (&argc, &argv);
+
+  /*
+   * Init GtkGLExt.
+   */
+
+  gtk_gl_init (&argc, &argv);
+
+  /*
+   * Query OpenGL extension version.
+   */
+
+  gdk_gl_query_version (&major, &minor);
+  g_print ("\nOpenGL extension version - %d.%d\n",
+           major, minor);
+
+  /*
+   * Configure OpenGL-capable visual.
+   */
+
+  /* Try multisampling */
+  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
+                                        GDK_GL_MODE_DOUBLE |
+                                        GDK_GL_MODE_DEPTH  |
+                                        GDK_GL_MODE_MULTISAMPLE |
+                                        /* 4x FSAA */
+                                        (4 << GDK_GL_MODE_SAMPLES_SHIFT));
+
+  if (glconfig == NULL)
+    {
+      g_print ("*** Cannot find the multisample-buffered visual.\n");
+      g_print ("*** Trying double-buffered visual.\n");
+      /* Try double-buffered visual */
+
+      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
+                                            GDK_GL_MODE_DEPTH  |
+                                            GDK_GL_MODE_DOUBLE);
+    }
+
+  if (glconfig == NULL)
+    {
+      g_print ("*** Cannot find the double-buffered visual.\n");
+      g_print ("*** Trying single-buffered visual.\n");
+
+      /* Try single-buffered visual */
+      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
+                                            GDK_GL_MODE_DEPTH);
+      if (glconfig == NULL)
+        {
+          g_print ("*** No appropriate OpenGL-capable visual found.\n");
+          exit (1);
+        }
+    }
+
+  examine_gl_config_attrib (glconfig);
+
+  /*
+   * Top-level window.
+   */
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title (GTK_WINDOW (window), "simple");
+
+  /* Get automatically redrawn if any of their children changed allocation. */
+  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);
+
+  g_signal_connect (G_OBJECT (window), "delete_event",
+                    G_CALLBACK (gtk_main_quit), NULL);
+
+  /*
+   * VBox.
+   */
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (window), vbox);
+  gtk_widget_show (vbox);
+
+  /*
+   * Drawing area for drawing OpenGL scene.
+   */
+
+  drawing_area = gtk_drawing_area_new ();
+  gtk_widget_set_size_request (drawing_area, 200, 200);
+
+  /* Set OpenGL-capability to the widget. */
+  gtk_widget_set_gl_capability (drawing_area,
+                                glconfig,
+                                NULL,
+                                TRUE,
+                                GDK_GL_RGBA_TYPE);
+
+  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
+                          G_CALLBACK (realize), NULL);
+  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
+		    G_CALLBACK (configure_event), NULL);
+  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
+		    G_CALLBACK (expose_event), NULL);
+
+  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
+
+  gtk_widget_show (drawing_area);
+
+  /*
+   * Simple quit button.
+   */
+
+  button = gtk_button_new_with_label ("Quit");
+
+  g_signal_connect (G_OBJECT (button), "clicked",
+                    G_CALLBACK (gtk_main_quit), NULL);
+
+  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+  gtk_widget_show (button);
+
+  /*
+   * Show window.
+   */
+
+  gtk_widget_show (window);
+
+  /*
+   * Main loop.
+   */
+
+  gtk_main ();
+
+  return 0;
+}
diff -uNr gtkglext-1.2.0-orig/gdk/gdkglconfig.c gtkglext-1.2.0-modif/gdk/gdkglconfig.c
--- gtkglext-1.2.0-orig/gdk/gdkglconfig.c	2004-02-20 11:38:10.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/gdkglconfig.c	2008-05-20 13:18:25.000000000 +0300
@@ -136,6 +136,8 @@
   return NULL;
 }
 
+#define GDK_GL_MODE_SAMPLES_MASK 0xff000000
+
 static GdkGLConfig *
 gdk_gl_config_new_rgb (GdkScreen       *screen,
                        GdkGLConfigMode  mode)
@@ -187,6 +189,21 @@
           list[n++] = 1;
         }
     }
+  if (mode & GDK_GL_MODE_MULTISAMPLE)
+    {
+      list[n++] = GDK_GL_SAMPLE_BUFFERS;
+      list[n++] = 1;
+        if (mode & GDK_GL_MODE_SAMPLES_MASK)
+          {
+            list[n++] = GDK_GL_SAMPLES;
+            list[n++] = (mode & GDK_GL_MODE_SAMPLES_MASK) >> GDK_GL_MODE_SAMPLES_SHIFT;
+          }
+        else /* Default to 2xFSAA */
+          {
+            list[n++] = GDK_GL_SAMPLES;
+            list[n++] = 2;
+          }
+    }
   list[n] = GDK_GL_ATTRIB_LIST_NONE;
 
 #ifdef GDKGLEXT_MULTIHEAD_SUPPORT
@@ -440,3 +457,20 @@
 
   return glconfig->has_accum_buffer;
 }
+
+/**
+ * gdk_gl_config_has_multisample_buffer:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configured frame buffer has multisampling.
+ *
+ * Return value: TRUE if the frame buffer has multisampling, FALSE
+ *               otherwise.
+ **/
+gboolean
+gdk_gl_config_has_multisample_buffer (GdkGLConfig *glconfig)
+{
+  g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+  return glconfig->has_multisample_buffer;
+}
diff -uNr gtkglext-1.2.0-orig/gdk/gdkglconfig.h gtkglext-1.2.0-modif/gdk/gdkglconfig.h
--- gtkglext-1.2.0-orig/gdk/gdkglconfig.h	2004-02-20 11:38:10.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/gdkglconfig.h	2008-05-16 10:39:45.000000000 +0300
@@ -41,7 +41,8 @@
   GDK_GL_MODE_DEPTH       = 1 << 4,
   GDK_GL_MODE_STENCIL     = 1 << 5,
   GDK_GL_MODE_ACCUM       = 1 << 6,
-  GDK_GL_MODE_MULTISAMPLE = 1 << 7   /* not supported yet */
+  GDK_GL_MODE_MULTISAMPLE = 1 << 7,
+  GDK_GL_MODE_SAMPLES_SHIFT = 24 /* Upper 8 bits reserved to select FSAA level */
 } GdkGLConfigMode;
 
 typedef struct _GdkGLConfigClass GdkGLConfigClass;
@@ -63,14 +64,15 @@
 
   gint n_sample_buffers;
 
-  guint is_rgba            : 1;
-  guint is_double_buffered : 1;
-  guint as_single_mode     : 1;
-  guint is_stereo          : 1;
-  guint has_alpha          : 1;
-  guint has_depth_buffer   : 1;
-  guint has_stencil_buffer : 1;
-  guint has_accum_buffer   : 1;
+  guint is_rgba                : 1;
+  guint is_double_buffered     : 1;
+  guint as_single_mode         : 1;
+  guint is_stereo              : 1;
+  guint has_alpha              : 1;
+  guint has_depth_buffer       : 1;
+  guint has_stencil_buffer     : 1;
+  guint has_accum_buffer       : 1;
+  guint has_multisample_buffer : 1;
 };
 
 struct _GdkGLConfigClass
@@ -130,6 +132,8 @@
 
 gboolean     gdk_gl_config_has_accum_buffer       (GdkGLConfig     *glconfig);
 
+gboolean     gdk_gl_config_has_multisample_buffer (GdkGLConfig     *glconfig);
+
 G_END_DECLS
 
 #endif /* __GDK_GL_CONFIG_H__ */
diff -uNr gtkglext-1.2.0-orig/gdk/gdkglenumtypes.c gtkglext-1.2.0-modif/gdk/gdkglenumtypes.c
--- gtkglext-1.2.0-orig/gdk/gdkglenumtypes.c	2006-02-05 05:18:39.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/gdkglenumtypes.c	2008-05-20 17:19:52.000000000 +0300
@@ -277,6 +277,7 @@
       { GDK_GL_MODE_STENCIL, "GDK_GL_MODE_STENCIL", "stencil" },
       { GDK_GL_MODE_ACCUM, "GDK_GL_MODE_ACCUM", "accum" },
       { GDK_GL_MODE_MULTISAMPLE, "GDK_GL_MODE_MULTISAMPLE", "multisample" },
+      { GDK_GL_MODE_SAMPLES_SHIFT, "GDK_GL_MODE_SAMPLES_SHIFT", "samples-shift" },
       { 0, NULL, NULL }
     };
     etype = g_flags_register_static ("GdkGLConfigMode", values);
diff -uNr gtkglext-1.2.0-orig/gdk/gdkglext.def gtkglext-1.2.0-modif/gdk/gdkglext.def
--- gtkglext-1.2.0-orig/gdk/gdkglext.def	2003-07-14 13:35:37.000000000 +0300
+++ gtkglext-1.2.0-modif/gdk/gdkglext.def	2008-05-20 12:01:46.000000000 +0300
@@ -16,6 +16,7 @@
 	gdk_gl_config_has_alpha
 	gdk_gl_config_has_depth_buffer
 	gdk_gl_config_has_stencil_buffer
+	gdk_gl_config_has_multisample_buffer
 	gdk_gl_config_is_double_buffered
 	gdk_gl_config_is_rgba
 	gdk_gl_config_is_stereo
@@ -1345,9 +1346,11 @@
 	gdk_win32_gl_drawable_hdc_get
 	gdk_win32_gl_drawable_hdc_release
 	gdk_win32_gl_pixmap_get_pfd
+	gdk_win32_gl_config_get_iattributes
 	gdk_win32_gl_pixmap_get_pixel_format
 	gdk_win32_gl_query_wgl_extension
 	gdk_win32_gl_window_get_pfd
+	gdk_win32_gl_window_get_iattributes
 	gdk_win32_gl_window_get_pixel_format
 	gdk_window_get_gl_window
 	gdk_window_is_gl_capable
diff -uNr gtkglext-1.2.0-orig/gdk/gdkglext-gtk20.def gtkglext-1.2.0-modif/gdk/gdkglext-gtk20.def
--- gtkglext-1.2.0-orig/gdk/gdkglext-gtk20.def	2003-07-14 13:35:37.000000000 +0300
+++ gtkglext-1.2.0-modif/gdk/gdkglext-gtk20.def	2008-05-20 17:34:34.000000000 +0300
@@ -16,6 +16,7 @@
 	gdk_gl_config_has_alpha
 	gdk_gl_config_has_depth_buffer
 	gdk_gl_config_has_stencil_buffer
+	gdk_gl_config_has_multisample_buffer
 	gdk_gl_config_is_double_buffered
 	gdk_gl_config_is_rgba
 	gdk_gl_config_is_stereo
@@ -1340,9 +1341,11 @@
 	gdk_win32_gl_drawable_hdc_get
 	gdk_win32_gl_drawable_hdc_release
 	gdk_win32_gl_pixmap_get_pfd
+	gdk_win32_gl_config_get_iattributes
 	gdk_win32_gl_pixmap_get_pixel_format
 	gdk_win32_gl_query_wgl_extension
 	gdk_win32_gl_window_get_pfd
+	gdk_win32_gl_window_get_iattributes
 	gdk_win32_gl_window_get_pixel_format
 	gdk_window_get_gl_window
 	gdk_window_is_gl_capable
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkglconfig-win32.c gtkglext-1.2.0-modif/gdk/win32/gdkglconfig-win32.c
--- gtkglext-1.2.0-orig/gdk/win32/gdkglconfig-win32.c	2004-02-20 11:38:13.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkglconfig-win32.c	2008-05-20 17:46:01.000000000 +0300
@@ -19,6 +19,7 @@
 #include "gdkglwin32.h"
 #include "gdkglprivate-win32.h"
 #include "gdkglconfig-win32.h"
+#include "gdkgldummywindow-win32.h"
 
 #ifdef GDKGLEXT_MULTIHEAD_SUPPORT
 #include <gdk/gdkscreen.h>
@@ -77,6 +78,9 @@
 
   g_object_unref (G_OBJECT (impl->colormap));
 
+  if (impl->iAttributes)
+    free(impl->iAttributes);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -238,6 +242,208 @@
                     pfd->cAccumAlphaBits;
 }
 
+static void
+gdk_gl_config_parse_ARB_attrib_list (const int *attrib_list, int *iAttr)
+{
+  int *p;
+  int layer_plane, buffer_size=0;
+  int cRedBits=0, cGreenBits=0, cBlueBits=0;
+  int cAccum=0,cAccumRedBits=0,cAccumGreenBits=0,cAccumBlueBits=0,cAccumAlphaBits=0;
+  gboolean buffer_size_is_specified = FALSE;
+  gboolean pixel_type_is_specified  = FALSE;
+  gboolean buffer_is_double = FALSE;
+
+  /* Defaults. */
+
+  /* A set of attribs flags that specify properties of the pixel buffer.
+     WGL_DRAW_TO_WINDOW_ARB or WGL_DRAW_TO_BITMAP_ARB are not specified at this stage.
+     The attribs are set by gdk_gl_(window|pixmap)_new(). */
+  *iAttr++ = WGL_SUPPORT_OPENGL_ARB;
+  *iAttr++ = GL_TRUE;
+  *iAttr++ = WGL_ACCELERATION_ARB;
+  *iAttr++ = WGL_FULL_ACCELERATION_ARB;
+
+  p = (int *) attrib_list;
+  while (*p != GDK_GL_ATTRIB_LIST_NONE)
+    {
+      switch (*p)
+        {
+        case GDK_GL_USE_GL:
+	  /* The buffer supports OpenGL drawing. */
+          *iAttr++ = WGL_SUPPORT_OPENGL_ARB;
+          *iAttr++ = GL_TRUE;
+          break;
+        case GDK_GL_BUFFER_SIZE:
+	  /* Specifies the number of color bitplanes in each color buffer. */
+          *iAttr++ = WGL_COLOR_BITS_ARB;
+          *iAttr++ = *(++p);
+          buffer_size_is_specified = TRUE;
+          break;
+        case GDK_GL_LEVEL:
+          layer_plane = *(++p);
+	  /* Ignored. Earlier implementations of OpenGL used this member,
+	     but it is no longer used. */
+	  if (layer_plane > 0)
+            {
+              *iAttr++ = WGL_NUMBER_OVERLAYS_ARB;
+              *iAttr++ = layer_plane;
+	    }
+          else if (layer_plane < 0)
+            {
+              *iAttr++ = WGL_NUMBER_UNDERLAYS_ARB;
+              *iAttr++ = (-1) * layer_plane;
+            }
+          break;
+        case GDK_GL_RGBA:
+	  /* RGBA pixels. */
+          *iAttr++ = WGL_PIXEL_TYPE_ARB;
+          *iAttr++ = WGL_TYPE_RGBA_ARB ;
+          pixel_type_is_specified = TRUE;
+          break;
+        case GDK_GL_DOUBLEBUFFER:
+	  /* The buffer is double-buffered. */
+          *iAttr++ = WGL_DOUBLE_BUFFER_ARB;
+          *iAttr++ = GL_TRUE;
+          buffer_is_double = TRUE;
+          break;
+        case GDK_GL_STEREO:
+	  /* The buffer is stereoscopic.
+	     This flag is not supported in the current generic implementation. */
+          *iAttr++ = WGL_STEREO_ARB;
+          *iAttr++ = GL_TRUE;
+          break;
+        case GDK_GL_AUX_BUFFERS:
+	  /* Specifies the number of auxiliary buffers.
+	     Auxiliary buffers are not supported. */
+          *iAttr++ = WGL_AUX_BUFFERS_ARB;
+          *iAttr++ = *(++p);
+          break;
+        case GDK_GL_RED_SIZE:
+	  /* Specifies the number of red bitplanes in each RGBA color buffer.
+	     Not used by ChoosePixelFormat. */
+          *iAttr++ = WGL_RED_BITS_ARB;
+          cRedBits = *(++p);
+          *iAttr++ = cRedBits;
+          break;
+        case GDK_GL_GREEN_SIZE:
+	  /* Specifies the number of green bitplanes in each RGBA color buffer.
+	     Not used by ChoosePixelFormat. */
+          *iAttr++ = WGL_GREEN_BITS_ARB;
+          cGreenBits = *(++p);
+          *iAttr++ = cGreenBits;
+          break;
+        case GDK_GL_BLUE_SIZE:
+	  /* Specifies the number of blue bitplanes in each RGBA color buffer.
+	     Not used by ChoosePixelFormat. */
+          *iAttr++ = WGL_BLUE_BITS_ARB;
+          cBlueBits = *(++p);
+          *iAttr++ = cBlueBits;
+          break;
+        case GDK_GL_ALPHA_SIZE:
+	  /* Specifies the number of alpha bitplanes in each RGBA color buffer.
+	     Alpha bitplanes are not supported.  */
+          *iAttr++ = WGL_ALPHA_BITS_ARB;
+          *iAttr++ = *(++p);
+          break;
+        case GDK_GL_DEPTH_SIZE:
+	  /* Specifies the depth of the depth (z-axis) buffer. */
+          *iAttr++ = WGL_DEPTH_BITS_ARB;
+          *iAttr++ = *(++p);
+          break;
+        case GDK_GL_STENCIL_SIZE:
+	  /* Specifies the depth of the stencil buffer. */
+          *iAttr++ = WGL_STENCIL_BITS_ARB;
+          *iAttr++ = *(++p);
+          break;
+        case GDK_GL_ACCUM_RED_SIZE:
+	  /* Specifies the number of red bitplanes in the accumulation buffer.
+	     Not used by ChoosePixelFormat. */
+          *iAttr++ = WGL_ACCUM_RED_BITS_ARB;
+          cAccumRedBits = *(++p);
+          *iAttr++ = cAccumRedBits;
+	  break;
+        case GDK_GL_ACCUM_GREEN_SIZE:
+	  /* Specifies the number of green bitplanes in the accumulation buffer.
+	     Not used by ChoosePixelFormat. */
+          *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB;
+          cAccumGreenBits =  *(++p);
+          *iAttr++ = cAccumGreenBits;
+	  break;
+        case GDK_GL_ACCUM_BLUE_SIZE:
+	  /* Specifies the number of blue bitplanes in the accumulation buffer.
+	     Not used by ChoosePixelFormat. */
+          *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB;
+          cAccumBlueBits = *(++p);
+          *iAttr++ = cAccumBlueBits;
+	  break;
+        case GDK_GL_ACCUM_ALPHA_SIZE:
+	  /* Specifies the number of alpha bitplanes in the accumulation buffer.
+	     Not used by ChoosePixelFormat.*/
+          *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB;
+          cAccumAlphaBits = *(++p);
+          *iAttr++ = cAccumAlphaBits;
+          break;
+        case GDK_GL_SAMPLE_BUFFERS:
+        /* Specifies whether multisample rasterization shall be used. */
+          *iAttr++ = WGL_SAMPLE_BUFFERS_ARB;
+          *iAttr++ = *(++p);
+          break;
+        case GDK_GL_SAMPLES:
+        /* Specifies the number of samples when multisampling is enabled.
+           Each pixel in the framebuffer has WGL_SAMPLES_ARB locations
+           associated with it */
+          *iAttr++ = WGL_SAMPLES_ARB;
+          *iAttr++ = *(++p);
+          break;
+        }
+      ++p;
+    }
+
+  /* If GDK_GL_BUFFER_SIZE is not specified. */
+  if (!buffer_size_is_specified)
+    {
+      buffer_size = cRedBits + cGreenBits + cBlueBits;
+      if (buffer_size != 0)
+        {
+          *iAttr++ = WGL_COLOR_BITS_ARB;
+          *iAttr++ = buffer_size;
+        }
+      else
+        {
+          *iAttr++ = WGL_COLOR_BITS_ARB;
+          *iAttr++ = 32;
+        }
+    }
+
+  /* WGL_DOUBLE_BUFFER_ARB is not used */
+  if (!buffer_is_double)
+    {
+     *iAttr++ = WGL_SUPPORT_GDI_ARB;
+     *iAttr++ = GL_TRUE;
+    }
+
+  /* Specifies the type of pixel data. */
+  if (!pixel_type_is_specified)
+    {
+     *iAttr++ = WGL_PIXEL_TYPE_ARB;
+     *iAttr++ = WGL_TYPE_COLORINDEX_ARB;
+    }
+
+  /* Specifies the total number of bitplanes in the accumulation buffer. */
+     cAccum = cAccumRedBits +
+              cAccumGreenBits +
+              cAccumBlueBits +
+              cAccumAlphaBits;
+     if (cAccum != 0)
+       {
+         *iAttr++ = WGL_ACCUM_BITS_ARB;
+         *iAttr++ = cAccum;
+       }
+
+  *iAttr++ = 0;
+  *iAttr++ = 0;
+}
+
 /*
  * Find an appropriate pixel format.
  * Basic idea of this code is ripped from FLTK.
@@ -383,6 +589,208 @@
   return TRUE;
 }
 
+
+int
+gdk_win32_gl_nattributes (int *iAttributes)
+{
+  int n = 0;
+
+  if (!iAttributes)
+    return 0;
+
+  while (iAttributes[2*n] != 0)
+    ++n;
+
+  return n;
+}
+
+static gboolean
+_gdk_win32_gl_setup_ARB_pixel_format (int *req_iAttr,
+                                      int *res_iAttr,
+                                      int *have_ARB_pixel_format,
+                                      int *have_ARB_Multisample)
+{
+  int niAttr = gdk_win32_gl_nattributes(req_iAttr);   /* number of attributes we will query */
+  int tmp_niAttr = niAttr + 1;                        /* let room to add WGL_DRAW_TO_WINDOW_ARB */
+  int npf = 0;                                        /* number of pixel formats for the device context */
+  int i,j,best;
+  int iAttributes[tmp_niAttr];                        /* attributes to query */
+  int iValues[tmp_niAttr];                            /* the returned values by wglGetPixelFormatAttribivARB */
+  int chosen_iValues[tmp_niAttr];
+  HWND hWnd;
+  HDC hdc;
+  HGLRC hrc;
+  int pixel_format;
+  PIXELFORMATDESCRIPTOR pfd;
+  GdkGLProc proc = NULL;
+
+  memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
+
+  /* Create the dummy window */
+  hWnd = gdk_win32_gl_create_dummy_window();
+  if (hWnd == 0)
+    {
+      g_warning ("cannot create dummy window");
+      return FALSE;
+    }
+
+  /* Get the device context for the dummy window */
+  hdc = GetDC (hWnd);
+  if (hdc == NULL)
+    {
+      ShowWindow(hWnd, SW_HIDE);
+      DestroyWindow(hWnd);
+      hWnd = 0;
+      g_warning ("cannot get DC for dummy window");
+      return FALSE;
+    }
+
+  /* Let's put some OpenGL pixel format for this device context */
+  pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
+  pfd.nVersion = 1;
+  pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+  pfd.iPixelType = PFD_TYPE_RGBA;
+  pfd.cColorBits = 32;
+  pfd.iLayerType = PFD_MAIN_PLANE;
+  pfd.cDepthBits = 16;
+  pixel_format = ChoosePixelFormat(hdc, &pfd);
+  if ((pixel_format == 0) || (!SetPixelFormat(hdc, pixel_format, &pfd)))
+    {
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot choose pixel format for dummy window");
+      return FALSE;
+    }
+
+  /* Create an OpenGL rendering context for the device context */
+  hrc = wglCreateContext(hdc);
+  if (!hrc)
+    {
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot create a rendering context for dummy window");
+      return FALSE;
+    }
+
+  /* Make the rendering context current */
+  if (wglMakeCurrent (hdc, hrc) == FALSE)
+    {
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot make current the rendering context for dummy window");
+      return FALSE;
+    }
+
+  /* To get a multisamples buffer, we need WGL_ARB_pixel_format
+     and WGL_ARB_multisample supports. */
+  if (gdk_win32_gl_query_wgl_extension(NULL,"WGL_ARB_pixel_format") == FALSE)
+    {
+      wglMakeCurrent(hdc, NULL);
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      return FALSE;
+    }
+  *have_ARB_pixel_format = TRUE;
+  if (gdk_win32_gl_query_wgl_extension(NULL,"WGL_ARB_multisample") == FALSE)
+    {
+      wglMakeCurrent(hdc, NULL);
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      return FALSE;
+    }
+  *have_ARB_Multisample = TRUE;
+
+  /* Query the number of pixel formats for this device context */
+  iAttributes[0] = WGL_NUMBER_PIXEL_FORMATS_ARB;
+
+  proc = gdk_gl_get_wglGetPixelFormatAttribivARB ();
+  if (proc == NULL)
+    {
+      proc = gdk_gl_get_proc_address ("wglGetPixelFormatAttribivARB");
+      if (proc == NULL) /* even if we should not so far */
+	{
+          wglDeleteContext (hrc);
+          hrc = 0;
+          gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+          hdc = 0;
+          hWnd = 0;
+          g_warning ("cannot get support for wglGetPixelFormatAttribivARB for dummy window.");
+          return FALSE;
+	}
+    }
+  if (!gdk_gl_wglGetPixelFormatAttribivARB(proc,hdc,0,0,1,iAttributes,iValues))
+    {
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot get the number of pixel formats for dummy window.");
+      return FALSE;
+    }
+
+  npf = iValues[0];
+
+  for (i = 0; i < niAttr; i++)
+    {
+      iAttributes[i] = req_iAttr[2*i];      /* we select the attributes only */
+      chosen_iValues[i] = req_iAttr[2*i+1]; /* we select the values only */
+    }
+  iAttributes[niAttr] = WGL_DRAW_TO_WINDOW_ARB;
+  chosen_iValues[niAttr] = GL_TRUE;
+
+  for (i = 0; i < npf; i++)
+    {
+      /* Query pixel format */
+      if (gdk_gl_wglGetPixelFormatAttribivARB(proc,hdc, i+1, 0, tmp_niAttr, iAttributes, iValues))
+        {
+          best = 1;
+          for (j = 0; j < tmp_niAttr; j++)
+            {
+              best = (chosen_iValues[j] <= iValues[j]) && best;
+            }
+          if (best)
+            {
+              memcpy (chosen_iValues, iValues, tmp_niAttr*sizeof(int));
+              break;
+            }
+        }
+    }
+
+  for (i = 0; i < niAttr; i++) /* discard WGL_DRAW_TO_WINDOW_ARB attribute */
+  {
+    res_iAttr[2*i] = iAttributes[i];
+    res_iAttr[2*i+1] = chosen_iValues[i];
+  }
+  /* make sure {0,0} is set at the 
+     end of res_iAttr */
+  res_iAttr[2*niAttr] = 0;
+  res_iAttr[2*niAttr+1] = 0;
+
+  /* Release all the temporary stuff. */
+  wglMakeCurrent(hdc, NULL);
+  wglDeleteContext (hrc);
+  hrc = 0;
+  gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+  hdc = 0;
+  hWnd = 0;
+
+  return TRUE;
+}
+
+
+
 /* 
  * Setup colormap.
  */
@@ -512,8 +920,24 @@
   /* Has accumulation buffer? */
   glconfig->has_accum_buffer = pfd->cAccumBits ? TRUE : FALSE;
 
-  /* Number of multisample buffers (not supported yet) */
+  /* Has multisample buffer? */
+  glconfig->has_multisample_buffer = FALSE;
+
+  /* Number of multisample buffers */
   glconfig->n_sample_buffers = 0;
+
+  int *wgl_attr = GDK_GL_CONFIG_ATTRIBS (glconfig);
+  int i, nattr = gdk_win32_gl_nattributes (wgl_attr);
+  for (i = 0; i < nattr ; i++)
+    {
+      if (wgl_attr[2*i] == WGL_SAMPLES_ARB)
+        {
+          int samples = wgl_attr[2*i+1];
+          glconfig->n_sample_buffers = samples;
+          glconfig->has_multisample_buffer = samples ? TRUE : FALSE;
+        }
+    }
+
 }
 
 static GdkGLConfig *
@@ -523,6 +947,8 @@
   GdkGLConfig *glconfig;
   GdkGLConfigImplWin32 *impl;
   PIXELFORMATDESCRIPTOR pfd;
+  int iAttribs[2*MAX_ATTRIBS];
+  int have_ARB_pixel_format=0, have_ARB_Multisample=0;
 
   GDK_GL_NOTE_FUNC_PRIVATE ();
 
@@ -534,6 +960,23 @@
 
   GDK_GL_NOTE (MISC, _gdk_win32_gl_print_pfd (&pfd));
 
+
+  /*
+   * Parse WGL_ARB_pixel_format style attrib_list.
+   */
+
+  gdk_gl_config_parse_ARB_attrib_list (attrib_list, &iAttribs[0]);
+
+
+  /*
+   * Setup iAttribs.
+   */
+
+  if (!_gdk_win32_gl_setup_ARB_pixel_format (&iAttribs[0], &iAttribs[0],
+                                             &have_ARB_pixel_format,
+                                             &have_ARB_Multisample))
+    g_warning ("failed in _gdk_win32_gl_ARB_pixel_format. Fall back to pfd.");
+
   /*
    * Setup PFD.
    */
@@ -551,7 +994,18 @@
   glconfig = g_object_new (GDK_TYPE_GL_CONFIG_IMPL_WIN32, NULL);
   impl = GDK_GL_CONFIG_IMPL_WIN32 (glconfig);
 
+
   impl->pfd = pfd;
+  impl->iAttributes = NULL;
+  if (have_ARB_pixel_format && have_ARB_Multisample)
+    {
+      int *iAttributes;
+      int niAttributes;
+      niAttributes = gdk_win32_gl_nattributes(&iAttribs[0]);
+      iAttributes = calloc(2*(niAttributes+1), sizeof(iAttributes));
+      memcpy(iAttributes, &iAttribs[0], 2*(niAttributes+1)*sizeof(iAttributes));
+      impl->iAttributes = iAttributes;
+    }
 
   impl->screen = screen;
 
@@ -612,6 +1066,231 @@
 
 #endif /* GDKGLEXT_MULTIHEAD_SUPPORT */
 
+gboolean
+_gdk_win32_gl_config_new_from_ARB_pixel_format (GdkGLConfigImplWin32 *impl, int pixel_format)
+{
+  int tmp_pixel_format;
+  int *iAttributeList;
+  HWND hWnd;
+  HDC hdc;
+  HGLRC hrc;
+  PIXELFORMATDESCRIPTOR pfd;
+  GdkGLProc proc = NULL;
+
+  memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
+
+  /* Create the dummy window */
+  hWnd = gdk_win32_gl_create_dummy_window();
+  if (hWnd == 0)
+    {
+      g_warning ("cannot create dummy window");
+      return FALSE;
+    }
+
+  /* Get the device context for the dummy window */
+  hdc = GetDC (hWnd);
+  if (hdc == NULL)
+    {
+      ShowWindow(hWnd, SW_HIDE);
+      DestroyWindow(hWnd);
+      hWnd = 0;
+      g_warning ("cannot get DC for dummy window");
+      return FALSE;
+    }
+
+  /* Let's put some OpenGL pixel format for this device context */
+  pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
+  pfd.nVersion = 1;
+  pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+  pfd.iPixelType = PFD_TYPE_RGBA;
+  pfd.cColorBits = 32;
+  pfd.iLayerType = PFD_MAIN_PLANE;
+  pfd.cDepthBits = 16;
+  tmp_pixel_format = ChoosePixelFormat(hdc, &pfd);
+  if ((tmp_pixel_format == 0) || (!SetPixelFormat(hdc, tmp_pixel_format, &pfd)))
+    {
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot choose pixel format for dummy window");
+      return FALSE;
+    }
+
+  /* Create an OpenGL rendering context for the device context */
+  hrc = wglCreateContext(hdc);
+  if (!hrc)
+    {
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot create a rendering context for dummy window");
+      return FALSE;
+    }
+
+  /* Make the rendering context current */
+  if (wglMakeCurrent (hdc, hrc) == FALSE)
+    {
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot make current the rendering context for dummy window");
+      return FALSE;
+    }
+
+  /* To get a multisamples buffer, we need WGL_ARB_pixel_format
+     and WGL_ARB_multisample supports. */
+  if (gdk_win32_gl_query_wgl_extension(NULL,"WGL_ARB_pixel_format") == FALSE)
+    {
+      wglMakeCurrent(hdc, NULL);
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot query WGL_ARB_pixel_format");
+      return FALSE;
+    }
+  if (gdk_win32_gl_query_wgl_extension(NULL,"WGL_ARB_multisample") == FALSE)
+    {
+      wglMakeCurrent(hdc, NULL);
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot query WGL_ARB_multisample");
+      return FALSE;
+    }
+
+  /* Query the number of pixel formats for this device context */
+  int tmp_iAttributes[] = {WGL_NUMBER_PIXEL_FORMATS_ARB};
+  int tmp_iValues[] = {0};
+
+  proc = gdk_gl_get_wglGetPixelFormatAttribivARB ();
+  if (proc == NULL)
+    {
+      proc = gdk_gl_get_proc_address ("wglGetPixelFormatAttribivARB");
+      if (proc == NULL) /* even if we should not so far */
+	{
+          wglDeleteContext (hrc);
+          hrc = 0;
+          gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+          hdc = 0;
+          hWnd = 0;
+          g_warning ("cannot get support for wglGetPixelFormatAttribivARB for dummy window.");
+          return FALSE;
+	}
+    }
+  if (!gdk_gl_wglGetPixelFormatAttribivARB(proc,hdc,0,0,1,tmp_iAttributes,tmp_iValues))
+    {
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot get the number of pixel formats for dummy window.");
+      return FALSE;
+    }
+
+  if (pixel_format >  tmp_iValues[0])
+    {
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("pixel_format out of bound");
+      return FALSE;
+    }
+
+  int i;
+  int niAttributes = 45;
+  int iValues[niAttributes];
+  int iAttributes[] = {
+    WGL_DRAW_TO_WINDOW_ARB,
+    WGL_DRAW_TO_BITMAP_ARB,
+    WGL_ACCELERATION_ARB,
+    WGL_NEED_PALETTE_ARB,
+    WGL_NEED_SYSTEM_PALETTE_ARB,
+    WGL_SWAP_LAYER_BUFFERS_ARB,
+    WGL_SWAP_METHOD_ARB,
+    WGL_NUMBER_OVERLAYS_ARB,
+    WGL_NUMBER_UNDERLAYS_ARB,
+    WGL_TRANSPARENT_ARB,
+    WGL_TRANSPARENT_RED_VALUE_ARB,
+    WGL_TRANSPARENT_GREEN_VALUE_ARB,
+    WGL_TRANSPARENT_BLUE_VALUE_ARB,
+    WGL_TRANSPARENT_ALPHA_VALUE_ARB,
+    WGL_TRANSPARENT_INDEX_VALUE_ARB,
+    WGL_SHARE_DEPTH_ARB,
+    WGL_SHARE_STENCIL_ARB,
+    WGL_SHARE_ACCUM_ARB,
+    WGL_SUPPORT_GDI_ARB,
+    WGL_SUPPORT_OPENGL_ARB,
+    WGL_DOUBLE_BUFFER_ARB,
+    WGL_STEREO_ARB,
+    WGL_PIXEL_TYPE_ARB,
+    WGL_COLOR_BITS_ARB,
+    WGL_RED_BITS_ARB,
+    WGL_RED_SHIFT_ARB,
+    WGL_GREEN_BITS_ARB,
+    WGL_GREEN_SHIFT_ARB,
+    WGL_BLUE_BITS_ARB,
+    WGL_BLUE_SHIFT_ARB,
+    WGL_ALPHA_BITS_ARB,
+    WGL_ALPHA_SHIFT_ARB,
+    WGL_ACCUM_BITS_ARB,
+    WGL_ACCUM_RED_BITS_ARB,
+    WGL_ACCUM_GREEN_BITS_ARB,
+    WGL_ACCUM_BLUE_BITS_ARB,
+    WGL_ACCUM_ALPHA_BITS_ARB,
+    WGL_DEPTH_BITS_ARB,
+    WGL_STENCIL_BITS_ARB,
+    WGL_AUX_BUFFERS_ARB,
+    WGL_DRAW_TO_PBUFFER_ARB,
+    WGL_BIND_TO_TEXTURE_RGBA_ARB,
+    WGL_BIND_TO_TEXTURE_RGB_ARB,
+    WGL_SAMPLE_BUFFERS_ARB,
+    WGL_SAMPLES_ARB,
+  };
+
+  memset (iValues, 0, sizeof (iValues));
+
+  /* Query the requested pixel format */
+  if (!gdk_gl_wglGetPixelFormatAttribivARB(proc,hdc, pixel_format, 0, niAttributes, iAttributes, iValues))
+    {
+      wglDeleteContext (hrc);
+      hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+      hdc = 0;
+      hWnd = 0;
+      g_warning ("cannot get valid iAttributes for the given pixel format");
+      return FALSE;
+    }
+
+  iAttributeList = calloc(2*(niAttributes+1),sizeof(iAttributeList));
+  for (i = 0; i < niAttributes; i++)
+  {
+    iAttributeList[2*i] = iAttributes[i];
+    iAttributeList[2*i+1] = iValues[i];
+  }
+
+  /* Release all the temporary stuff. */
+  wglMakeCurrent(hdc, NULL);
+  wglDeleteContext (hrc);
+  hrc = 0;
+  gdk_win32_gl_destroy_dummy_window(hWnd,hdc);
+  hdc = 0;
+  hWnd = 0;
+
+  /* update glconfig */
+  impl->iAttributes = iAttributeList;
+
+  return TRUE;
+}
+
 GdkGLConfig *
 gdk_win32_gl_config_new_from_pixel_format (int pixel_format)
 {
@@ -642,7 +1321,10 @@
   ReleaseDC (NULL, hdc);
 
   if (result == 0)
-    return NULL;
+    {
+      g_warning ("DescribePixelForma failed");
+      return NULL;
+    }
 
   GDK_GL_NOTE (MISC, g_message (" -- pixel_format = 0x%x", pixel_format));
 
@@ -656,6 +1338,7 @@
   impl = GDK_GL_CONFIG_IMPL_WIN32 (glconfig);
 
   impl->pfd = pfd;
+  impl->iAttributes = NULL;
 
 #ifdef GDKGLEXT_MULTIHEAD_SUPPORT
   impl->screen = gdk_screen_get_default ();
@@ -678,6 +1361,14 @@
   impl->depth = pfd.cRedBits + pfd.cGreenBits + pfd.cBlueBits;
 
   /*
+   * See if we can get a better config with a WGL_ARB_pixel_format
+   */
+
+  if(!_gdk_win32_gl_config_new_from_ARB_pixel_format (impl, pixel_format))
+    g_warning ("cannot get extended configuration");
+  
+
+  /*
    * Init configuration attributes.
    */
 
@@ -686,6 +1377,7 @@
   return glconfig;
 }
 
+
 GdkScreen *
 gdk_gl_config_get_screen (GdkGLConfig *glconfig)
 {
@@ -793,6 +1485,12 @@
     case GDK_GL_ACCUM_ALPHA_SIZE:
       *value = impl->pfd.cAccumAlphaBits;
       break;
+    case GDK_GL_SAMPLE_BUFFERS:
+      *value = glconfig->has_multisample_buffer;
+      break;
+    case GDK_GL_SAMPLES:
+      *value = glconfig->n_sample_buffers;
+      break;
     default:
       return FALSE;
     }
@@ -832,6 +1530,14 @@
   return &(GDK_GL_CONFIG_IMPL_WIN32 (glconfig)->pfd);
 }
 
+int *
+gdk_win32_gl_config_get_iattributes (GdkGLConfig *glconfig)
+{
+  g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_WIN32 (glconfig), NULL);
+
+  return GDK_GL_CONFIG_IMPL_WIN32 (glconfig)->iAttributes;
+}
+
 /*< private >*/
 void
 _gdk_win32_gl_print_pfd (PIXELFORMATDESCRIPTOR *pfd)
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkglconfig-win32.h gtkglext-1.2.0-modif/gdk/win32/gdkglconfig-win32.h
--- gtkglext-1.2.0-orig/gdk/win32/gdkglconfig-win32.h	2004-02-20 11:38:13.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkglconfig-win32.h	2008-05-20 17:46:22.000000000 +0300
@@ -45,6 +45,14 @@
   GdkColormap *colormap;
 
   gint depth;
+
+  int *iAttributes;      /* pixel format attributes. Attributes are
+                            specified by name. This interface allows pixel 
+                            formats to be supported which have attributes
+                            that cannot be represented using the standard
+                            pixel format functions, i.e. DescribePixelFormat,
+                            DescribeLayerPlane, ChoosePixelFormat, SetPixelFormat,
+                            and GetPixelFormat. */
 };
 
 struct _GdkGLConfigImplWin32Class
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkgldummywindow-win32.c gtkglext-1.2.0-modif/gdk/win32/gdkgldummywindow-win32.c
--- gtkglext-1.2.0-orig/gdk/win32/gdkgldummywindow-win32.c	1970-01-01 02:00:00.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkgldummywindow-win32.c	2008-05-20 17:47:07.000000000 +0300
@@ -0,0 +1,79 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2002-2004  Naofumi Yasufuku
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
+ */
+
+#include "gdkglwin32.h"
+#include "gdkglprivate-win32.h"
+#include "gdkglconfig-win32.h"
+
+
+# define DUMMYWINDOWNAME "__GtkGlExtDummyWindow"
+
+
+static int wc_registered = 0;
+
+LRESULT CALLBACK DummyWndProc 
+  (HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    return DefWindowProc(hWnd,uMsg,wParam,lParam);
+}
+
+HWND gdk_win32_gl_create_dummy_window(void) {
+  HINSTANCE hInstance;
+  DWORD     dwExStyle;
+  DWORD     dwStyle;
+  HWND      hWnd;
+
+  hInstance = GetModuleHandle(NULL);
+  if (!wc_registered)
+    {
+      WNDCLASS  wc;
+      ZeroMemory(&wc, sizeof(wc));
+      wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+      wc.lpfnWndProc = (WNDPROC) DummyWndProc;
+      wc.cbClsExtra = 0;
+      wc.cbWndExtra = 0;
+      wc.hInstance = hInstance;
+      wc.hIcon = NULL;
+      wc.hCursor = NULL;
+      wc.hbrBackground = NULL;
+      wc.lpszMenuName = NULL;
+      wc.lpszClassName = DUMMYWINDOWNAME;
+      if (!(wc_registered = RegisterClass(&wc)))
+        {
+          g_warning ("could not register class for dummy window");
+          return(0);
+        }
+    }
+
+  dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
+  dwStyle = WS_OVERLAPPEDWINDOW;
+  hWnd=CreateWindowEx(dwExStyle, DUMMYWINDOWNAME, DUMMYWINDOWNAME,
+                      dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+                      0, 0, 1, 1,
+                      NULL, NULL, hInstance, NULL);
+  if(!hWnd)
+      return(0);
+
+  return(hWnd);
+}
+
+void gdk_win32_gl_destroy_dummy_window(HWND hWnd, HDC hdc) {
+  ReleaseDC (hWnd, hdc);
+  ShowWindow(hWnd, SW_HIDE);
+  DestroyWindow(hWnd);
+}
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkgldummywindow-win32.h gtkglext-1.2.0-modif/gdk/win32/gdkgldummywindow-win32.h
--- gtkglext-1.2.0-orig/gdk/win32/gdkgldummywindow-win32.h	1970-01-01 02:00:00.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkgldummywindow-win32.h	2008-05-20 17:47:18.000000000 +0300
@@ -0,0 +1,29 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2002-2004  Naofumi Yasufuku
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
+ */
+
+#ifndef __GDK_GL_DUMMY_WINDOW_WIN32_H__
+#define __GDK_GL_DUMMY_WINDOW_WIN32_H__
+
+G_BEGIN_DECLS
+
+HWND gdk_win32_gl_create_dummy_window(void);
+void gdk_win32_gl_destroy_dummy_window(HWND hWnd, HDC hdc);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_DUMMY_WINDOW_WIN32_H__ */
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkglquery-win32.c gtkglext-1.2.0-modif/gdk/win32/gdkglquery-win32.c
--- gtkglext-1.2.0-orig/gdk/win32/gdkglquery-win32.c	2004-02-20 11:38:13.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkglquery-win32.c	2008-05-20 17:47:32.000000000 +0300
@@ -136,6 +136,7 @@
 
   if (extensions == NULL)
     {
+      char *s = NULL;
       /* Try wglGetExtensionsStringARB. */
 
       wgl_get_extensions_string_arb =
@@ -150,12 +151,12 @@
             }
           else
             {
-              extensions = wgl_get_extensions_string_arb (hdc);
+              s = wgl_get_extensions_string_arb (hdc);
               ReleaseDC (NULL, hdc);
             }
         }
 
-      if (extensions == NULL)
+      if (s == NULL)
         {
           /* Try wglGetExtensionsStringEXT. */
 
@@ -163,11 +164,14 @@
             (__wglGetExtensionsStringEXTProc) gdk_gl_get_proc_address ("wglGetExtensionsStringEXT");
 
           if (wgl_get_extensions_string_ext)
-            extensions = wgl_get_extensions_string_ext ();
+            s = wgl_get_extensions_string_ext ();
         }
 
-      if (extensions == NULL)
+      if (s == NULL)
         return FALSE;
+
+      extensions = calloc(strlen(s)+1,sizeof(char));
+      strncpy(extensions,s,strlen(s));
     }
 
   /* It takes a bit of care to be fool-proof about parsing
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkglwin32.h gtkglext-1.2.0-modif/gdk/win32/gdkglwin32.h
--- gtkglext-1.2.0-orig/gdk/win32/gdkglwin32.h	2004-02-20 11:38:13.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkglwin32.h	2008-05-20 12:24:42.000000000 +0300
@@ -45,6 +45,10 @@
 
 PIXELFORMATDESCRIPTOR *gdk_win32_gl_config_get_pfd          (GdkGLConfig   *glconfig);
 
+int                   *gdk_win32_gl_config_get_iattributes  (GdkGLConfig   *glconfig);
+
+int                    gdk_win32_gl_nattributes             (int *iAttributes);
+
 GdkGLContext          *gdk_win32_gl_context_foreign_new     (GdkGLConfig   *glconfig,
                                                              GdkGLContext  *share_list,
                                                              HGLRC          hglrc);
@@ -58,11 +62,15 @@
 int                    gdk_win32_gl_pixmap_get_pixel_format (GdkGLPixmap   *glpixmap);
 
 PIXELFORMATDESCRIPTOR *gdk_win32_gl_window_get_pfd          (GdkGLWindow   *glwindow);
+int                   *gdk_win32_gl_window_get_iattributes  (GdkGLWindow   *glwindow);
 int                    gdk_win32_gl_window_get_pixel_format (GdkGLWindow   *glwindow);
 
+#define MAX_ATTRIBS 256
+
 #ifdef INSIDE_GDK_GL_WIN32
 
 #define GDK_GL_CONFIG_PFD(glconfig)          (&(GDK_GL_CONFIG_IMPL_WIN32 (glconfig)->pfd))
+#define GDK_GL_CONFIG_ATTRIBS(glconfig)      (GDK_GL_CONFIG_IMPL_WIN32 (glconfig)->iAttributes)
 #define GDK_GL_CONTEXT_HGLRC(glcontext)      (GDK_GL_CONTEXT_IMPL_WIN32 (glcontext)->hglrc)
 #define GDK_GL_PIXMAP_PFD(glpixmap)          (&(GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap)->pfd))
 #define GDK_GL_PIXMAP_PIXEL_FORMAT(glpixmap) (GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap)->pixel_format)
@@ -72,6 +80,7 @@
 #else
 
 #define GDK_GL_CONFIG_PFD(glconfig)          (gdk_win32_gl_config_get_pfd (glconfig))
+#define GDK_GL_CONFIG_ATTRIBS(glconfig)      (gdk_win32_gl_config_get_iattributes (glconfig)
 #define GDK_GL_CONTEXT_HGLRC(glcontext)      (gdk_win32_gl_context_get_hglrc (glcontext))
 #define GDK_GL_PIXMAP_PFD(glpixmap)          (gdk_win32_gl_pixmap_get_pfd (glpixmap))
 #define GDK_GL_PIXMAP_PIXEL_FORMAT(glpixmap) (gdk_win32_gl_pixmap_get_pixel_format (glpixmap))
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkglwindow-win32.c gtkglext-1.2.0-modif/gdk/win32/gdkglwindow-win32.c
--- gtkglext-1.2.0-orig/gdk/win32/gdkglwindow-win32.c	2004-02-20 11:38:13.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkglwindow-win32.c	2008-05-20 15:05:57.000000000 +0300
@@ -21,6 +21,7 @@
 #include "gdkglconfig-win32.h"
 #include "gdkglcontext-win32.h"
 #include "gdkglwindow-win32.h"
+#include "gdkgldummywindow-win32.h"
 
 static gboolean     gdk_gl_window_impl_win32_make_context_current (GdkGLDrawable *draw,
                                                                    GdkGLDrawable *read,
@@ -135,6 +136,9 @@
 
   _gdk_gl_window_destroy (GDK_GL_WINDOW (object));
 
+  if (impl->iAttributes)
+    free(impl->iAttributes);
+
   g_object_unref (G_OBJECT (impl->glconfig));
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -157,6 +161,183 @@
   iface->get_size             = _gdk_gl_window_get_size;
 }
 
+static gboolean
+gdk_gl_window_new_with_ARB_pixel_format (HDC hdc,
+                                         int *iAttributes,
+                                         int niAttribs,
+                                         int *res_iAttributes,
+                                         int *pixel_format)
+{
+  int i, numFormats;
+  float fAttribs[] = {0,0};
+  GdkGLProc proc = NULL;
+  PIXELFORMATDESCRIPTOR pfd;
+  HWND tmp_hWnd;
+  HDC tmp_hdc;
+  HGLRC tmp_hrc;
+
+  memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
+
+  /* Create the dummy window */
+  tmp_hWnd = gdk_win32_gl_create_dummy_window();
+  if (tmp_hWnd == 0)
+    {
+      g_warning ("cannot create dummy window");
+      return FALSE;
+    }
+
+  /* Get the device context for the dummy window */
+  tmp_hdc = GetDC (tmp_hWnd);
+  if (tmp_hdc == NULL)
+    {
+      ShowWindow(tmp_hWnd, SW_HIDE);
+      DestroyWindow(tmp_hWnd);
+      tmp_hWnd = 0;
+      g_warning ("cannot get DC for dummy window");
+      return FALSE;
+    }
+
+  /* Let's put some OpenGL pixel format for this device context */
+  pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
+  pfd.nVersion = 1;
+  pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+  pfd.iPixelType = PFD_TYPE_RGBA;
+  pfd.cColorBits = 32;
+  pfd.iLayerType = PFD_MAIN_PLANE;
+  pfd.cDepthBits = 16;
+
+  *pixel_format = ChoosePixelFormat(tmp_hdc, &pfd);
+  if ((*pixel_format == 0) || (!SetPixelFormat(tmp_hdc, *pixel_format, &pfd)))
+    {
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      g_warning ("cannot choose pixel format for dummy window");
+      return FALSE;
+    }
+  *pixel_format = 0;
+
+  /* Create an OpenGL rendering context for the device context */
+  tmp_hrc = wglCreateContext(tmp_hdc);
+  if (!tmp_hrc)
+    {
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      g_warning ("cannot create a rendering context for dummy window");
+      return FALSE;
+    }
+
+  /* Make the rendering context current */
+  if (wglMakeCurrent (tmp_hdc, tmp_hrc) == FALSE)
+    {
+      wglDeleteContext (tmp_hrc);
+      tmp_hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      g_warning ("cannot make current the rendering context for dummy window");
+      return FALSE;
+    }
+
+  /* To get a multisamples buffer, we need WGL_ARB_pixel_format
+     and WGL_ARB_multisample supports. */
+  if (gdk_win32_gl_query_wgl_extension(NULL,"WGL_ARB_pixel_format") == FALSE)
+    {
+      wglMakeCurrent(tmp_hdc, NULL);
+      wglDeleteContext (tmp_hrc);
+      tmp_hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      return FALSE;
+    }
+
+  if (gdk_win32_gl_query_wgl_extension(NULL,"WGL_ARB_multisample") == FALSE)
+    {
+      wglMakeCurrent(tmp_hdc, NULL);
+      wglDeleteContext (tmp_hrc);
+      tmp_hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      return FALSE;
+    }
+
+  proc = gdk_gl_get_wglChoosePixelFormatARB ();
+  if (proc == NULL)
+    {
+      proc = gdk_gl_get_proc_address ("wglChoosePixelFormatARB");
+      if (proc == NULL)
+        {
+          wglMakeCurrent(tmp_hdc, NULL);
+          wglDeleteContext(tmp_hrc);
+          tmp_hrc = 0;
+          gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+          tmp_hdc = 0;
+          tmp_hWnd = 0;
+          g_warning ("cannot get wglChoosePixelFormatARB");
+          return FALSE;
+        }
+    }
+
+
+  for (i = 0; i < (2*niAttribs); i++)
+    {
+      res_iAttributes[i] = iAttributes[i];
+    }
+  res_iAttributes[2*niAttribs] = WGL_DRAW_TO_WINDOW_ARB;
+  res_iAttributes[2*niAttribs+1] = TRUE;
+  res_iAttributes[2*niAttribs+2] = 0;
+  res_iAttributes[2*niAttribs+3] = 0;
+
+  GDK_GL_NOTE_FUNC_IMPL ("wglChoosePixelFormatARB");
+
+  if (!gdk_gl_wglChoosePixelFormatARB(proc,tmp_hdc,&res_iAttributes[0],
+                                      fAttribs,1,pixel_format,
+				      &numFormats))
+    {
+      wglMakeCurrent(tmp_hdc, NULL);
+      wglDeleteContext(tmp_hrc);
+      tmp_hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      g_warning ("wglChoosePixelFormatARB invalid");
+      return FALSE;
+    }
+
+  if (!numFormats)
+    {
+      wglMakeCurrent(tmp_hdc, NULL);
+      wglDeleteContext(tmp_hrc);
+      tmp_hrc = 0;
+      gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+      tmp_hdc = 0;
+      tmp_hWnd = 0;
+      g_warning ("numFormats < 1");
+      return FALSE;
+    }
+
+  /* Release all the temporary stuff. */
+  wglMakeCurrent(tmp_hdc, NULL);
+  wglDeleteContext (tmp_hrc);
+  tmp_hrc = 0;
+  gdk_win32_gl_destroy_dummy_window(tmp_hWnd,tmp_hdc);
+  tmp_hdc = 0;
+  tmp_hWnd = 0;
+
+  GDK_GL_NOTE_FUNC_IMPL ("SetPixelFormat");
+ 
+  if (!SetPixelFormat (hdc, *pixel_format, NULL))
+    {
+      g_warning ("could not SetPixelFormat for pixel_format = %d", *pixel_format);
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
 /*
  * attrib_list is currently unused. This must be set to NULL or empty
  * (first attribute of None). See GLX 1.3 spec.
@@ -174,7 +355,9 @@
   gboolean need_release_dc;
   HDC hdc = NULL;
   PIXELFORMATDESCRIPTOR pfd;
+  int *iAttribs;
   int pixel_format;
+  int *res_iAttribs=NULL;
 
   GDK_GL_NOTE_FUNC ();
 
@@ -204,11 +387,8 @@
       goto FAIL;
     }
 
-  /*
-   * Choose pixel format.
-   */
-
   pfd = *(GDK_GL_CONFIG_PFD (glconfig));
+
   /* Draw to window */
   pfd.dwFlags &= ~PFD_DRAW_TO_BITMAP;
   pfd.dwFlags |= PFD_DRAW_TO_WINDOW;
@@ -216,6 +396,31 @@
   /* Request pfd.cColorBits should exclude alpha bitplanes. */
   pfd.cColorBits = pfd.cRedBits + pfd.cGreenBits + pfd.cBlueBits;
 
+  /* bypass the PFD method if we have 
+     WGL_ARB_pixel_format support */
+  iAttribs = GDK_GL_CONFIG_ATTRIBS (glconfig);
+  if (iAttribs)
+    {
+      int niAttribs = gdk_win32_gl_nattributes (iAttribs);
+      /* let room for {WGL_DRAW_TO_WINDOW_ARB,TRUE} and {0,0} */
+      res_iAttribs = calloc(2*(niAttribs+2),sizeof(res_iAttribs));
+      if (gdk_gl_window_new_with_ARB_pixel_format (hdc, iAttribs, niAttribs,
+                                                   res_iAttribs, &pixel_format))
+        {
+          goto SUCCESS;
+        }
+      else
+        {
+          free(res_iAttribs);
+          res_iAttribs = NULL;
+          g_warning ("could not use iAttribs!");
+        }
+    }
+
+  /*
+   * Choose pixel format.
+   */
+
   GDK_GL_NOTE_FUNC_IMPL ("ChoosePixelFormat");
 
   pixel_format = ChoosePixelFormat (hdc, &pfd);
@@ -242,6 +447,7 @@
   GDK_GL_NOTE (MISC, g_message (" -- impl->pixel_format = 0x%x", pixel_format));
   GDK_GL_NOTE (MISC, _gdk_win32_gl_print_pfd (&pfd));
 
+ SUCCESS:
   if (need_release_dc)
     {
       /* Release DC. */
@@ -263,6 +469,7 @@
   impl->hwnd = hwnd;
 
   impl->pfd = pfd;
+  impl->iAttributes = res_iAttribs;
   impl->pixel_format = pixel_format;
 
   impl->glconfig = glconfig;
@@ -433,6 +640,14 @@
   return &(GDK_GL_WINDOW_IMPL_WIN32 (glwindow)->pfd);
 }
 
+int *
+gdk_win32_gl_window_get_iattributes (GdkGLWindow *glwindow)
+{
+  g_return_val_if_fail (GDK_IS_GL_WINDOW_IMPL_WIN32 (glwindow), NULL);
+
+  return GDK_GL_WINDOW_IMPL_WIN32 (glwindow)->iAttributes;
+}
+
 int
 gdk_win32_gl_window_get_pixel_format (GdkGLWindow *glwindow)
 {
diff -uNr gtkglext-1.2.0-orig/gdk/win32/gdkglwindow-win32.h gtkglext-1.2.0-modif/gdk/win32/gdkglwindow-win32.h
--- gtkglext-1.2.0-orig/gdk/win32/gdkglwindow-win32.h	2004-02-20 11:38:13.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/gdkglwindow-win32.h	2008-05-19 14:04:57.000000000 +0300
@@ -41,6 +41,7 @@
   HWND hwnd;
 
   PIXELFORMATDESCRIPTOR pfd;
+  int *iAttributes;
   int pixel_format;
 
   GdkGLConfig *glconfig;
diff -uNr gtkglext-1.2.0-orig/gdk/win32/Makefile.in gtkglext-1.2.0-modif/gdk/win32/Makefile.in
--- gtkglext-1.2.0-orig/gdk/win32/Makefile.in	2006-02-05 05:17:41.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/win32/Makefile.in	2008-05-20 17:51:07.000000000 +0300
@@ -241,6 +241,7 @@
 
 
 gdkglext_win32_private_h_sources = \
+	gdkgldummywindow-win32.h \
 	gdkglconfig-win32.h	\
 	gdkglcontext-win32.h	\
 	gdkglpixmap-win32.h	\
@@ -250,6 +251,7 @@
 
 gdkglext_win32_c_sources = \
 	gdkglquery-win32.c	\
+	gdkgldummywindow-win32.c \
 	gdkglconfig-win32.c	\
 	gdkglcontext-win32.c	\
 	gdkgldrawable-win32.c	\
@@ -284,7 +286,7 @@
 libgdkglext_win32_la_LDFLAGS =
 libgdkglext_win32_la_LIBADD =
 am__objects_1 =
-am__objects_2 = gdkglquery-win32.lo gdkglconfig-win32.lo \
+am__objects_2 = gdkglquery-win32.lo gdkgldummywindow-win32.lo gdkglconfig-win32.lo \
 	gdkglcontext-win32.lo gdkgldrawable-win32.lo \
 	gdkglpixmap-win32.lo gdkglwindow-win32.lo gdkglfont-win32.lo \
 	gdkglwglext.lo
@@ -296,6 +298,7 @@
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/gdkglconfig-win32.Plo \
+@AMDEP_TRUE@	./$(DEPDIR)/gdkgldummywindow-win32.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/gdkglcontext-win32.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/gdkgldrawable-win32.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/gdkglfont-win32.Plo \
@@ -345,6 +348,7 @@
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdkglconfig-win32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdkgldummywindow-win32.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdkglcontext-win32.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdkgldrawable-win32.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdkglfont-win32.Plo@am__quote@
diff -uNr gtkglext-1.2.0-orig/gdk/x11/gdkglconfig-x11.c gtkglext-1.2.0-modif/gdk/x11/gdkglconfig-x11.c
--- gtkglext-1.2.0-orig/gdk/x11/gdkglconfig-x11.c	2004-02-20 11:38:14.000000000 +0200
+++ gtkglext-1.2.0-modif/gdk/x11/gdkglconfig-x11.c	2008-05-20 16:59:31.000000000 +0300
@@ -480,8 +480,10 @@
   _GET_CONFIG (GLX_ACCUM_RED_SIZE);
   glconfig->has_accum_buffer = value ? TRUE : FALSE;
 
-  /* Number of multisample buffers (not supported yet) */
-  glconfig->n_sample_buffers = 0;
+  /* Number of multisample buffers */
+  _GET_CONFIG(GLX_SAMPLE_BUFFERS_ARB);
+  glconfig->n_sample_buffers = value;
+  glconfig->has_multisample_buffer = value ? TRUE : FALSE;
 
 #undef _GET_CONFIG
 }
@@ -583,7 +585,8 @@
  * GDK_GL_DOUBLEBUFFER, GDK_GL_STEREO, GDK_GL_AUX_BUFFERS,
  * GDK_GL_RED_SIZE, GDK_GL_GREEN_SIZE, GDK_GL_BLUE_SIZE, GDK_GL_ALPHA_SIZE,
  * GDK_GL_DEPTH_SIZE, GDK_GL_STENCIL_SIZE, GDK_GL_ACCUM_RED_SIZE,
- * GDK_GL_ACCUM_GREEN_SIZE, GDK_GL_ACCUM_BLUE_SIZE, GDK_GL_ACCUM_ALPHA_SIZE.
+ * GDK_GL_ACCUM_GREEN_SIZE, GDK_GL_ACCUM_BLUE_SIZE, GDK_GL_ACCUM_ALPHA_SIZE,
+ * GDK_GL_SAMPLE_BUFFERS, GDK_GL_SAMPLES.
  *
  * Return value: the new #GdkGLConfig.
  **/

 	  	 
