[GtkGLExt] Multisample (aka FSAA) patch
- From: Jonathan Brandmeyer <jbrandmeyer earthlink net>
- To: "gtkglext-list gnome org" <gtkglext-list gnome org>
- Subject: [GtkGLExt] Multisample (aka FSAA) patch
- Date: Wed, 17 May 2006 23:30:04 -0400
I have attached a patch to support multisampling on the X11 target using
the GdkGLConfigMode method. I'll write a corresponding patch for the
-mm binding as well.
There is also a pair of marked TODO's that should be implemented when
the lib is ready to break ABI.
If someone out there has more clue than I about wGL, then maybe they
could write the patch to win32/gdkglconfig-win32.c.
-Jonathan
Index: examples/simple.c
===================================================================
RCS file: /cvsroot/gtkglext/gtkglext/examples/simple.c,v
retrieving revision 1.27
diff -u -r1.27 simple.c
--- examples/simple.c 6 Nov 2003 18:04:46 -0000 1.27
+++ examples/simple.c 18 May 2006 03:28:47 -0000
@@ -174,6 +174,8 @@
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, FALSE);
+ pring_gl_config_attrib (glconfig, "GDK_GK_SAMPLES", GDK_GL_SAMPLES, FALSE);
g_print ("\n");
}
@@ -217,7 +219,22 @@
/* Try double-buffered visual */
glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
GDK_GL_MODE_DEPTH |
- GDK_GL_MODE_DOUBLE);
+ GDK_GL_MODE_DOUBLE |
+ GDK_GL_MODE_MULTISAMPLE |
+ /* 2x FSAA */
+ (2 << GDK_GL_MODE_SAMPLE_SHIFT));
+
+ if (glconfig == NULL)
+ {
+ g_print ("*** Cannot find a multisampled visual.\n");
+ g_print ("*** Trying without FSAA.\n");
+
+ /* Try single-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");
Index: gdk/gdkglconfig.c
===================================================================
RCS file: /cvsroot/gtkglext/gtkglext/gdk/gdkglconfig.c,v
retrieving revision 1.36
diff -u -r1.36 gdkglconfig.c
--- gdk/gdkglconfig.c 20 Feb 2004 09:38:10 -0000 1.36
+++ gdk/gdkglconfig.c 18 May 2006 03:28:47 -0000
@@ -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
Index: gdk/gdkglconfig.h
===================================================================
RCS file: /cvsroot/gtkglext/gtkglext/gdk/gdkglconfig.h,v
retrieving revision 1.24
diff -u -r1.24 gdkglconfig.h
--- gdk/gdkglconfig.h 20 Feb 2004 09:38:10 -0000 1.24
+++ gdk/gdkglconfig.h 18 May 2006 03:28:47 -0000
@@ -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;
@@ -71,6 +72,12 @@
guint has_depth_buffer : 1;
guint has_stencil_buffer : 1;
guint has_accum_buffer : 1;
+ /* TODO: When ready to break ABI, enable the following, and remove n_sample_buffers
+ * According to the spec, GLX_SAMPLE_BUFFERS_ARB has no meaning for values > 1
+ * See also gdkglconfig-x11.c
+ guint n_sample_buffers : 1;
+ guint n_samples;
+ */
};
struct _GdkGLConfigClass
Index: gdk/x11/gdkglconfig-x11.c
===================================================================
RCS file: /cvsroot/gtkglext/gtkglext/gdk/x11/gdkglconfig-x11.c,v
retrieving revision 1.60
diff -u -r1.60 gdkglconfig-x11.c
--- gdk/x11/gdkglconfig-x11.c 20 Feb 2004 09:38:14 -0000 1.60
+++ gdk/x11/gdkglconfig-x11.c 18 May 2006 03:28:48 -0000
@@ -480,8 +480,18 @@
_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;
+
+ /* TODO: When ready to break ABI, enable the following:
+ See also gdkglconfig.h
+ _GET_CONFIG( GLX_SAMPLE_BUFFERS_ARB);
+ glconfig->n_sample_buffers = value ? TRUE : FALSE;
+
+ _GET_CONFIG( GLX_SAMPLES_ARB);
+ glconfig->n_samples = value;
+ */
#undef _GET_CONFIG
}
Index: .cdtproject
===================================================================
RCS file: .cdtproject
diff -N .cdtproject
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .cdtproject 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.make.core.make">
+<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser">
+<attribute key="addr2line" value="addr2line"/>
+<attribute key="c++filt" value="c++filt"/>
+</extension>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
+</item>
+<item id="cdt_indexer">
+<indexEnabled indexValue="false"/>
+<indexerProblemsEnabled indexProblemsValue="0"/>
+</item>
+</data>
+</cdtproject>
Index: .project
===================================================================
RCS file: .project
diff -N .project
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .project 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>gtkglext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.make.core.makeBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>org.eclipse.cdt.core.errorOutputParser</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>clean all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.incrementalBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.ScannerConfigDiscoveryEnabled</key>
+ <value>false</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.make.core.makeNature</nature>
+ <nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
Index: multisamples.patch
===================================================================
RCS file: multisamples.patch
diff -N multisamples.patch
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ multisamples.patch 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,96 @@
+Index: gdk/gdkglconfig.c
+===================================================================
+RCS file: /cvsroot/gtkglext/gtkglext/gdk/gdkglconfig.c,v
+retrieving revision 1.36
+diff -u -r1.36 gdkglconfig.c
+--- gdk/gdkglconfig.c 20 Feb 2004 09:38:10 -0000 1.36
++++ gdk/gdkglconfig.c 18 May 2006 03:16:11 -0000
+@@ -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
+Index: gdk/gdkglconfig.h
+===================================================================
+RCS file: /cvsroot/gtkglext/gtkglext/gdk/gdkglconfig.h,v
+retrieving revision 1.24
+diff -u -r1.24 gdkglconfig.h
+--- gdk/gdkglconfig.h 20 Feb 2004 09:38:10 -0000 1.24
++++ gdk/gdkglconfig.h 18 May 2006 03:16:12 -0000
+@@ -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;
+@@ -71,6 +72,12 @@
+ guint has_depth_buffer : 1;
+ guint has_stencil_buffer : 1;
+ guint has_accum_buffer : 1;
++ /* TODO: When ready to break ABI, enable the following, and remove n_sample_buffers
++ * According to the spec, GLX_SAMPLE_BUFFERS_ARB has no meaning for values > 1
++ * See also gdkglconfig-x11.c
++ guint n_sample_buffers : 1;
++ guint n_samples;
++ */
+ };
+
+ struct _GdkGLConfigClass
+Index: gdk/x11/gdkglconfig-x11.c
+===================================================================
+RCS file: /cvsroot/gtkglext/gtkglext/gdk/x11/gdkglconfig-x11.c,v
+retrieving revision 1.60
+diff -u -r1.60 gdkglconfig-x11.c
+--- gdk/x11/gdkglconfig-x11.c 20 Feb 2004 09:38:14 -0000 1.60
++++ gdk/x11/gdkglconfig-x11.c 18 May 2006 03:16:12 -0000
+@@ -480,8 +480,18 @@
+ _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;
++
++ /* TODO: When ready to break ABI, enable the following:
++ See also gdkglconfig.h
++ _GET_CONFIG( GLX_SAMPLE_BUFFERS_ARB);
++ glconfig->n_sample_buffers = value ? TRUE : FALSE;
++
++ _GET_CONFIG( GLX_SAMPLES_ARB);
++ glconfig->n_samples = value;
++ */
+
+ #undef _GET_CONFIG
+ }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]