Hi,
Thanks for the patches! I took the filename fix and the Python example.
Is there a way to try out the example without having to install
GtkGLExt?
For the third patch see below.
> > int attrib[] = { GDK_GL_DOUBLEBUFFER, FALSE, GDK_GL_RED_SIZE, 8,
> > GDK_GL_GREEN_SIZE, 8, GDK_GL_BLUE_SIZE, 8, 0 };
> >
> > FALSE is equal to 0, so the binding code will abort there and
> > never reach the RGB sizes. The only solution is to pass the array
> > length as an extra parameter to the C function.
> I don't think this code is correct. GDK_GL_DOUBLEBUFFER does not has
> an argument, so the FALSE will be interpreted as the terminating
> GDK_GL_ATTRIB_LIST_NONE in the C code anyway.
You're right, the example wouldn't work. But the point is clear.
>
> attribs = [ GdkGLExt.ConfigAttrib.DEPTH_SIZE , 0,
> GdkGLExt.ConfigAttrib.RGBA,
> GdkGLExt.ConfigAttrib.DOUBLEBUFFER,
> GdkGLExt.ConfigAttrib.RED_SIZE, 1,
> GdkGLExt.ConfigAttrib.GREEN_SIZE, 1,
> GdkGLExt.ConfigAttrib.BLUE_SIZE, 1,
> GdkGLExt.ATTRIB_LIST_NONE
> ]
> With this attributes works the same whether or not the
> zero-terminated=1 is there, so the array is passed by the binding to
> the C function altogether without looking into it.
> I dont think an API change is needed and made an new patch with the
> zero-terminated removed.
This is just one program in one language. I don't trust this to work in
the general case. The annotation website [1] is clear about annotating
arrays.
'For reference types, zero-terminated arrays are the easiest to work
with. Arrays of primitive type such as "int" will require length
metadata.'
Meanwhile I made some changes to make the GLConfig functions require the
number of entries in the attribute array. You can find the patches
attached; in case you want to have a look at them. The first two patches
are target-specific, the third patch modifies the public interface.
Best regards
Thomas
>
> >
> > If you don't have a better idea, I think we should do this and
> > deprecate the zero-termination completely.
> >
> >
> >> Btw, are you interested in Python examples in your git tree?
> >> They demonstrate the usage of g-i, as bindings like
> >> python-gtkglext1 are not needed any more.
> >
> > I won't have the resources for maintaining the code, but I wouldn't
> > mind putting the sources of some small, self-contained examples
> > into my tree (e.g., into examples/python/).
> Attached an patch with an example.
>
> >
> > Best regards Thomas
> >
> >
>
> Best regards, BC
> _______________________________________________
> gtkglext-list mailing list
> gtkglext-list gnome org
> https://mail.gnome.org/mailman/listinfo/gtkglext-list
--
GnuPG: http://tdz.users.sourceforge.net/tdz.asc
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08
jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See
http://jsapigen.sourceforge.net for more information.
From 361609c43522aad66b57fe09a0351a5ef1292809 Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <tdz users sourceforge net>
Date: Sun, 3 Jun 2012 17:05:24 +0200
Subject: x11: Don't 0-terminate attribute list of configuration.
The configuration's attribute list is now supposed to not be
0-terminated for the X11 target. In practice, 0-termination is
still necessary and the supplied length is set to an arbitrary
value. Future patches will update the public interface to support
passing the length of the attribute list.
---
gdk/gdkglconfig.c | 4 +-
gdk/x11/gdkglconfig-x11.c | 117 ++++++++++++++++++++++++++++++++++++++++++---
gdk/x11/gdkglconfig-x11.h | 6 ++-
gdk/x11/gdkx11glconfig.c | 10 ++--
gdk/x11/gdkx11glconfig.h | 6 ++-
5 files changed, 126 insertions(+), 17 deletions(-)
diff --git a/gdk/gdkglconfig.c b/gdk/gdkglconfig.c
index a66abd5..ecf96b4 100644
--- a/gdk/gdkglconfig.c
+++ b/gdk/gdkglconfig.c
@@ -450,7 +450,7 @@ gdk_gl_config_new_for_display (GdkDisplay *display, const int *attrib_list)
#ifdef GDKGLEXT_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(display))
{
- glconfig = gdk_x11_gl_config_new_for_display(display, attrib_list);
+ glconfig = gdk_x11_gl_config_new_for_display(display, attrib_list, 64);
}
else
#endif
@@ -505,7 +505,7 @@ gdk_gl_config_new_for_screen (GdkScreen *screen,
#ifdef GDKGLEXT_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(display))
{
- glconfig = gdk_x11_gl_config_new_for_screen(screen, attrib_list);
+ glconfig = gdk_x11_gl_config_new_for_screen(screen, attrib_list, 64);
}
else
#endif
diff --git a/gdk/x11/gdkglconfig-x11.c b/gdk/x11/gdkglconfig-x11.c
index c67da68..66fc126 100644
--- a/gdk/x11/gdkglconfig-x11.c
+++ b/gdk/x11/gdkglconfig-x11.c
@@ -154,15 +154,103 @@ gdk_x11_gl_config_impl_init_attrib (GdkGLConfig *glconfig)
#undef _GET_CONFIG
}
+static int *
+glx_attrib_list_from_attrib_list (const gint *attrib_list, gsize n_attribs)
+{
+ static const guchar has_param[] =
+ {
+ [GDK_GL_BUFFER_SIZE] = 1,
+ [GDK_GL_LEVEL] = 1,
+ [GDK_GL_AUX_BUFFERS] = 1,
+ [GDK_GL_RED_SIZE] = 1,
+ [GDK_GL_GREEN_SIZE] = 1,
+ [GDK_GL_BLUE_SIZE] = 1,
+ [GDK_GL_ALPHA_SIZE] = 1,
+ [GDK_GL_DEPTH_SIZE] = 1,
+ [GDK_GL_STENCIL_SIZE] = 1,
+ [GDK_GL_ACCUM_RED_SIZE] = 1,
+ [GDK_GL_ACCUM_GREEN_SIZE] = 1,
+ [GDK_GL_ACCUM_BLUE_SIZE] = 1,
+ [GDK_GL_ACCUM_ALPHA_SIZE] = 1
+ };
+
+ static const int glx_attrib_of_attrib[] =
+ {
+ [GDK_GL_USE_GL] = GLX_USE_GL,
+ [GDK_GL_BUFFER_SIZE] = GLX_BUFFER_SIZE,
+ [GDK_GL_LEVEL] = GLX_LEVEL,
+ [GDK_GL_RGBA] = GLX_RGBA,
+ [GDK_GL_DOUBLEBUFFER] = GLX_DOUBLEBUFFER,
+ [GDK_GL_STEREO] = GLX_STEREO,
+ [GDK_GL_AUX_BUFFERS] = GLX_AUX_BUFFERS,
+ [GDK_GL_RED_SIZE] = GLX_RED_SIZE,
+ [GDK_GL_GREEN_SIZE] = GLX_GREEN_SIZE,
+ [GDK_GL_BLUE_SIZE] = GLX_BLUE_SIZE,
+ [GDK_GL_ALPHA_SIZE] = GLX_ALPHA_SIZE,
+ [GDK_GL_DEPTH_SIZE] = GLX_DEPTH_SIZE,
+ [GDK_GL_STENCIL_SIZE] = GLX_STENCIL_SIZE,
+ [GDK_GL_ACCUM_RED_SIZE] = GLX_ACCUM_RED_SIZE,
+ [GDK_GL_ACCUM_GREEN_SIZE] = GLX_ACCUM_GREEN_SIZE,
+ [GDK_GL_ACCUM_BLUE_SIZE] = GLX_ACCUM_BLUE_SIZE,
+ [GDK_GL_ACCUM_ALPHA_SIZE] = GLX_ACCUM_ALPHA_SIZE
+ };
+
+ int *glx_attrib_list;
+ gsize i;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ glx_attrib_list = g_malloc( sizeof(*glx_attrib_list)*(n_attribs+3) );
+
+ if (!glx_attrib_list)
+ goto err_g_malloc;
+
+ for (i = 0; (i < n_attribs) && attrib_list[i]; ++i)
+ {
+ switch (attrib_list[i])
+ {
+ case GDK_GL_USE_GL:
+ /* legacy from GLX 1.2 and always true; will be removed */
+ case GDK_GL_RGBA:
+ /* not supported anymore; skip now, remove later */
+ break;
+
+ default:
+ glx_attrib_list[i] = glx_attrib_of_attrib[attrib_list[i]];
+ if ( has_param[attrib_list[i]] )
+ {
+ ++i;
+ if (i == n_attribs)
+ goto err_n_attribs;
+ glx_attrib_list[i] = attrib_list[i];
+ }
+ break;
+ }
+ }
+
+ glx_attrib_list[i++] = GLX_RGBA;
+ glx_attrib_list[i++] = GLX_USE_GL;
+ glx_attrib_list[i++] = 0;
+
+ return glx_attrib_list;
+
+err_n_attribs:
+ g_free(glx_attrib_list);
+err_g_malloc:
+ return NULL;
+}
+
static GdkGLConfig *
gdk_x11_gl_config_impl_new_common (GdkGLConfig *glconfig,
GdkScreen *screen,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GdkGLConfigImplX11 *x11_impl;
Display *xdisplay;
int screen_num;
+ int *glx_attrib_list;
XVisualInfo *xvinfo;
int is_rgba;
@@ -177,11 +265,17 @@ gdk_x11_gl_config_impl_new_common (GdkGLConfig *glconfig,
* Find an OpenGL-capable visual.
*/
+ glx_attrib_list = glx_attrib_list_from_attrib_list(attrib_list, n_attribs);
+
+ if (glx_attrib_list == NULL)
+ goto err_glx_attrib_list_from_attrib_list;
+
GDK_GL_NOTE_FUNC_IMPL ("glXChooseVisual");
- xvinfo = glXChooseVisual (xdisplay, screen_num, (int *) attrib_list);
+ xvinfo = glXChooseVisual (xdisplay, screen_num, glx_attrib_list);
+
if (xvinfo == NULL)
- return NULL;
+ goto err_glXChooseVisual;
GDK_GL_NOTE (MISC,
g_message (" -- glXChooseVisual: screen number = %d", xvinfo->screen));
@@ -214,12 +308,20 @@ gdk_x11_gl_config_impl_new_common (GdkGLConfig *glconfig,
gdk_x11_gl_config_impl_init_attrib (glconfig);
+ g_free(glx_attrib_list);
+
return glconfig;
+
+err_glXChooseVisual:
+ g_free(glx_attrib_list);
+err_glx_attrib_list_from_attrib_list:
+ return NULL;
}
GdkGLConfig *
_gdk_x11_gl_config_impl_new (GdkGLConfig *glconfig,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GdkScreen *screen;
@@ -230,13 +332,14 @@ _gdk_x11_gl_config_impl_new (GdkGLConfig *glconfig,
screen = gdk_screen_get_default ();
- return gdk_x11_gl_config_impl_new_common (glconfig, screen, attrib_list);
+ return gdk_x11_gl_config_impl_new_common (glconfig, screen, attrib_list, n_attribs);
}
GdkGLConfig *
_gdk_x11_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
GdkScreen *screen,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GDK_GL_NOTE_FUNC ();
@@ -244,7 +347,7 @@ _gdk_x11_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
g_return_val_if_fail (attrib_list != NULL, NULL);
- return gdk_x11_gl_config_impl_new_common (glconfig, screen, attrib_list);
+ return gdk_x11_gl_config_impl_new_common (glconfig, screen, attrib_list, n_attribs);
}
/*
diff --git a/gdk/x11/gdkglconfig-x11.h b/gdk/x11/gdkglconfig-x11.h
index 1edc9fa..daf6b7c 100644
--- a/gdk/x11/gdkglconfig-x11.h
+++ b/gdk/x11/gdkglconfig-x11.h
@@ -59,10 +59,12 @@ struct _GdkGLConfigImplX11Class
GType gdk_gl_config_impl_x11_get_type (void);
GdkGLConfig *_gdk_x11_gl_config_impl_new (GdkGLConfig *glconfig,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *_gdk_x11_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
GdkScreen *screen,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *_gdk_x11_gl_config_impl_new_from_visualid_for_screen (GdkGLConfig *glconfig,
GdkScreen *screen,
VisualID xvisualid);
diff --git a/gdk/x11/gdkx11glconfig.c b/gdk/x11/gdkx11glconfig.c
index 1a7c41a..ce72369 100644
--- a/gdk/x11/gdkx11glconfig.c
+++ b/gdk/x11/gdkx11glconfig.c
@@ -65,13 +65,14 @@ gdk_x11_gl_config_class_init (GdkX11GLConfigClass *klass)
* gdk_x11_gl_config_new_for_display:
* @display: display.
* @attrib_list: the attribute list.
+ * @n_attribs: the number of attributes and values in attrib_list
*
* Creates a #GdkGLConfig on the given display.
*
* Return value: the new #GdkGLConfig.
**/
GdkGLConfig *
-gdk_x11_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list)
+gdk_x11_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list, gsize n_attribs)
{
GdkGLConfig *glconfig;
GdkGLConfig *impl;
@@ -82,7 +83,7 @@ gdk_x11_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list)
g_return_val_if_fail(glconfig != NULL, NULL);
- impl = _gdk_x11_gl_config_impl_new(glconfig, attrib_list);
+ impl = _gdk_x11_gl_config_impl_new(glconfig, attrib_list, n_attribs);
if (impl == NULL)
g_object_unref(glconfig);
@@ -96,13 +97,14 @@ gdk_x11_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list)
* gdk_x11_gl_config_new_for_screen:
* @screen: target screen.
* @attrib_list: the attribute list.
+ * @n_attribs: the number of attributes and values in attrib_list
*
* Creates a #GdkGLConfig on the given display.
*
* Return value: the new #GdkGLConfig.
**/
GdkGLConfig *
-gdk_x11_gl_config_new_for_screen(GdkScreen *screen, const int *attrib_list)
+gdk_x11_gl_config_new_for_screen(GdkScreen *screen, const int *attrib_list, gsize n_attribs)
{
GdkGLConfig *glconfig;
GdkGLConfig *impl;
@@ -113,7 +115,7 @@ gdk_x11_gl_config_new_for_screen(GdkScreen *screen, const int *attrib_list)
g_return_val_if_fail(glconfig != NULL, NULL);
- impl = _gdk_x11_gl_config_impl_new(glconfig, attrib_list);
+ impl = _gdk_x11_gl_config_impl_new(glconfig, attrib_list, n_attribs);
if (impl == NULL)
g_object_unref(glconfig);
diff --git a/gdk/x11/gdkx11glconfig.h b/gdk/x11/gdkx11glconfig.h
index 45fbb58..abebd9f 100644
--- a/gdk/x11/gdkx11glconfig.h
+++ b/gdk/x11/gdkx11glconfig.h
@@ -45,10 +45,12 @@ typedef struct _GdkX11GLConfigClass GdkX11GLConfigClass;
GType gdk_x11_gl_config_get_type (void);
GdkGLConfig *gdk_x11_gl_config_new_for_display (GdkDisplay *display,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *gdk_x11_gl_config_new_for_screen (GdkScreen *screen,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
#ifndef GDK_MULTIHEAD_SAFE
GdkGLConfig *gdk_x11_gl_config_new_from_visualid (VisualID xvisualid);
--
1.7.7.6
From a032b5e6491549345a578e62d08012a56985edcf Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <tdz users sourceforge net>
Date: Sun, 3 Jun 2012 18:00:14 +0200
Subject: win32: Don't 0-terminate attribute list of configuration.
The Win32 target's configuration now receives the number of elements
in the supplied configuration. In practice, the implementation still
respects a terminator character.
---
gdk/gdkglconfig.c | 4 +-
gdk/win32/gdkglconfig-win32.c | 205 ++++++++++++++++++++++-------------------
gdk/win32/gdkglconfig-win32.h | 6 +-
gdk/win32/gdkwin32glconfig.c | 10 +-
gdk/win32/gdkwin32glconfig.h | 6 +-
5 files changed, 128 insertions(+), 103 deletions(-)
diff --git a/gdk/gdkglconfig.c b/gdk/gdkglconfig.c
index ecf96b4..5be121d 100644
--- a/gdk/gdkglconfig.c
+++ b/gdk/gdkglconfig.c
@@ -457,7 +457,7 @@ gdk_gl_config_new_for_display (GdkDisplay *display, const int *attrib_list)
#ifdef GDKGLEXT_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY(display))
{
- glconfig = gdk_win32_gl_config_new_for_display(display, attrib_list);
+ glconfig = gdk_win32_gl_config_new_for_display(display, attrib_list, 64);
}
else
#endif
@@ -512,7 +512,7 @@ gdk_gl_config_new_for_screen (GdkScreen *screen,
#ifdef GDKGLEXT_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY(display))
{
- glconfig = gdk_win32_gl_config_new_for_screen(screen, attrib_list);
+ glconfig = gdk_win32_gl_config_new_for_screen(screen, attrib_list, 64);
}
else
#endif
diff --git a/gdk/win32/gdkglconfig-win32.c b/gdk/win32/gdkglconfig-win32.c
index cf43173..b783ccc 100644
--- a/gdk/win32/gdkglconfig-win32.c
+++ b/gdk/win32/gdkglconfig-win32.c
@@ -85,9 +85,11 @@ gdk_gl_config_impl_win32_class_init (GdkGLConfigImplWin32Class *klass)
*/
static void
gdk_gl_config_parse_attrib_list (const int *attrib_list,
+ gsize n_attribs,
PIXELFORMATDESCRIPTOR *pfd)
{
int *p;
+ int i;
gboolean buffer_size_is_specified = FALSE;
BYTE buffer_size;
int layer_plane;
@@ -125,95 +127,109 @@ gdk_gl_config_parse_attrib_list (const int *attrib_list,
pfd->iLayerType = PFD_MAIN_PLANE;
p = (int *) attrib_list;
- while (*p != GDK_GL_ATTRIB_LIST_NONE)
+
+ for (i = 0; (i < n_attribs) && (*p != GDK_GL_ATTRIB_LIST_NONE); ++i)
{
switch (*p)
{
- case GDK_GL_USE_GL:
- /* The buffer supports OpenGL drawing. */
- pfd->dwFlags |= PFD_SUPPORT_OPENGL;
- break;
- case GDK_GL_BUFFER_SIZE:
- /* Specifies the number of color bitplanes in each color buffer. */
- pfd->cColorBits = *(++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)
- pfd->iLayerType = PFD_OVERLAY_PLANE;
- else if (layer_plane < 0)
- pfd->iLayerType = PFD_UNDERLAY_PLANE;
- break;
- case GDK_GL_RGBA:
- /* RGBA pixels. */
- pfd->iPixelType = PFD_TYPE_RGBA;
- break;
- case GDK_GL_DOUBLEBUFFER:
- /* The buffer is double-buffered. */
- pfd->dwFlags &= ~PFD_SUPPORT_GDI;
- pfd->dwFlags |= PFD_DOUBLEBUFFER;
- break;
- case GDK_GL_STEREO:
- /* The buffer is stereoscopic.
- This flag is not supported in the current generic implementation. */
- pfd->dwFlags |= PFD_STEREO;
- break;
- case GDK_GL_AUX_BUFFERS:
- /* Specifies the number of auxiliary buffers.
- Auxiliary buffers are not supported. */
- pfd->cAuxBuffers = *(++p);
- break;
- case GDK_GL_RED_SIZE:
- /* Specifies the number of red bitplanes in each RGBA color buffer.
- Not used by ChoosePixelFormat. */
- pfd->cRedBits = *(++p);
- break;
- case GDK_GL_GREEN_SIZE:
- /* Specifies the number of green bitplanes in each RGBA color buffer.
- Not used by ChoosePixelFormat. */
- pfd->cGreenBits = *(++p);
- break;
- case GDK_GL_BLUE_SIZE:
- /* Specifies the number of blue bitplanes in each RGBA color buffer.
- Not used by ChoosePixelFormat. */
- pfd->cBlueBits = *(++p);
- break;
- case GDK_GL_ALPHA_SIZE:
- /* Specifies the number of alpha bitplanes in each RGBA color buffer.
- Alpha bitplanes are not supported. */
- pfd->cAlphaBits = *(++p);
- break;
- case GDK_GL_DEPTH_SIZE:
- /* Specifies the depth of the depth (z-axis) buffer. */
- pfd->cDepthBits = *(++p);
- break;
- case GDK_GL_STENCIL_SIZE:
- /* Specifies the depth of the stencil buffer. */
- pfd->cStencilBits = *(++p);
- break;
- case GDK_GL_ACCUM_RED_SIZE:
- /* Specifies the number of red bitplanes in the accumulation buffer.
- Not used by ChoosePixelFormat. */
- pfd->cAccumRedBits = *(++p);
- break;
- case GDK_GL_ACCUM_GREEN_SIZE:
- /* Specifies the number of green bitplanes in the accumulation buffer.
- Not used by ChoosePixelFormat. */
- pfd->cAccumGreenBits = *(++p);
- break;
- case GDK_GL_ACCUM_BLUE_SIZE:
- /* Specifies the number of blue bitplanes in the accumulation buffer.
- Not used by ChoosePixelFormat. */
- pfd->cAccumBlueBits = *(++p);
- break;
- case GDK_GL_ACCUM_ALPHA_SIZE:
- /* Specifies the number of alpha bitplanes in the accumulation buffer.
- Not used by ChoosePixelFormat.*/
- pfd->cAccumAlphaBits = *(++p);
- break;
+ case GDK_GL_USE_GL:
+ /* The buffer supports OpenGL drawing. */
+ pfd->dwFlags |= PFD_SUPPORT_OPENGL;
+ break;
+ case GDK_GL_BUFFER_SIZE:
+ /* Specifies the number of color bitplanes in each color buffer. */
+ pfd->cColorBits = *(++p);
+ buffer_size_is_specified = TRUE;
+ ++i;
+ 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)
+ pfd->iLayerType = PFD_OVERLAY_PLANE;
+ else if (layer_plane < 0)
+ pfd->iLayerType = PFD_UNDERLAY_PLANE;
+ ++i;
+ break;
+ case GDK_GL_RGBA:
+ /* RGBA pixels. */
+ pfd->iPixelType = PFD_TYPE_RGBA;
+ break;
+ case GDK_GL_DOUBLEBUFFER:
+ /* The buffer is double-buffered. */
+ pfd->dwFlags &= ~PFD_SUPPORT_GDI;
+ pfd->dwFlags |= PFD_DOUBLEBUFFER;
+ break;
+ case GDK_GL_STEREO:
+ /* The buffer is stereoscopic.
+ This flag is not supported in the current generic implementation. */
+ pfd->dwFlags |= PFD_STEREO;
+ break;
+ case GDK_GL_AUX_BUFFERS:
+ /* Specifies the number of auxiliary buffers.
+ Auxiliary buffers are not supported. */
+ pfd->cAuxBuffers = *(++p);
+ ++i;
+ break;
+ case GDK_GL_RED_SIZE:
+ /* Specifies the number of red bitplanes in each RGBA color buffer.
+ Not used by ChoosePixelFormat. */
+ pfd->cRedBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_GREEN_SIZE:
+ /* Specifies the number of green bitplanes in each RGBA color buffer.
+ Not used by ChoosePixelFormat. */
+ pfd->cGreenBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_BLUE_SIZE:
+ /* Specifies the number of blue bitplanes in each RGBA color buffer.
+ Not used by ChoosePixelFormat. */
+ pfd->cBlueBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_ALPHA_SIZE:
+ /* Specifies the number of alpha bitplanes in each RGBA color buffer.
+ Alpha bitplanes are not supported. */
+ pfd->cAlphaBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_DEPTH_SIZE:
+ /* Specifies the depth of the depth (z-axis) buffer. */
+ pfd->cDepthBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_STENCIL_SIZE:
+ /* Specifies the depth of the stencil buffer. */
+ pfd->cStencilBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_ACCUM_RED_SIZE:
+ /* Specifies the number of red bitplanes in the accumulation buffer.
+ Not used by ChoosePixelFormat. */
+ pfd->cAccumRedBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_ACCUM_GREEN_SIZE:
+ /* Specifies the number of green bitplanes in the accumulation buffer.
+ Not used by ChoosePixelFormat. */
+ pfd->cAccumGreenBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_ACCUM_BLUE_SIZE:
+ /* Specifies the number of blue bitplanes in the accumulation buffer.
+ Not used by ChoosePixelFormat. */
+ pfd->cAccumBlueBits = *(++p);
+ ++i;
+ break;
+ case GDK_GL_ACCUM_ALPHA_SIZE:
+ /* Specifies the number of alpha bitplanes in the accumulation buffer.
+ Not used by ChoosePixelFormat.*/
+ pfd->cAccumAlphaBits = *(++p);
+ ++i;
+ break;
}
++p;
}
@@ -223,7 +239,7 @@ gdk_gl_config_parse_attrib_list (const int *attrib_list,
{
buffer_size = pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits;
if (buffer_size != 0)
- pfd->cColorBits = buffer_size;
+ pfd->cColorBits = buffer_size;
}
/* Specifies the total number of bitplanes in the accumulation buffer. */
@@ -433,7 +449,8 @@ gdk_win32_gl_config_impl_init_attrib (GdkGLConfig *glconfig)
static GdkGLConfig *
gdk_win32_gl_config_impl_new_common (GdkGLConfig *glconfig,
GdkScreen *screen,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GdkGLConfigImplWin32 *win32_impl;
PIXELFORMATDESCRIPTOR pfd;
@@ -444,7 +461,7 @@ gdk_win32_gl_config_impl_new_common (GdkGLConfig *glconfig,
* Parse GLX style attrib_list.
*/
- gdk_gl_config_parse_attrib_list (attrib_list, &pfd);
+ gdk_gl_config_parse_attrib_list (attrib_list, n_attribs, &pfd);
GDK_GL_NOTE (MISC, _gdk_win32_gl_print_pfd (&pfd));
@@ -491,7 +508,8 @@ gdk_win32_gl_config_impl_new_common (GdkGLConfig *glconfig,
GdkGLConfig *
_gdk_win32_gl_config_impl_new (GdkGLConfig *glconfig,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GdkScreen *screen;
@@ -502,13 +520,14 @@ _gdk_win32_gl_config_impl_new (GdkGLConfig *glconfig,
screen = gdk_screen_get_default ();
- return gdk_win32_gl_config_impl_new_common (glconfig, screen, attrib_list);
+ return gdk_win32_gl_config_impl_new_common (glconfig, screen, attrib_list, n_attribs);
}
GdkGLConfig *
_gdk_win32_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
GdkScreen *screen,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GDK_GL_NOTE_FUNC ();
@@ -516,7 +535,7 @@ _gdk_win32_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
g_return_val_if_fail (attrib_list != NULL, NULL);
- return gdk_win32_gl_config_impl_new_common (glconfig, screen, attrib_list);
+ return gdk_win32_gl_config_impl_new_common (glconfig, screen, attrib_list, n_attribs);
}
GdkGLConfig *
diff --git a/gdk/win32/gdkglconfig-win32.h b/gdk/win32/gdkglconfig-win32.h
index c0900e3..1a089e3 100644
--- a/gdk/win32/gdkglconfig-win32.h
+++ b/gdk/win32/gdkglconfig-win32.h
@@ -58,10 +58,12 @@ struct _GdkGLConfigImplWin32Class
GType gdk_gl_config_impl_win32_get_type (void);
GdkGLConfig *_gdk_win32_gl_config_impl_new (GdkGLConfig *glconfig,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *_gdk_win32_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
GdkScreen *screen,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *_gdk_win32_gl_config_impl_new_from_pixel_format (GdkGLConfig *glconfig,
int pixel_format);
diff --git a/gdk/win32/gdkwin32glconfig.c b/gdk/win32/gdkwin32glconfig.c
index 2ef603d..13d6963 100644
--- a/gdk/win32/gdkwin32glconfig.c
+++ b/gdk/win32/gdkwin32glconfig.c
@@ -65,13 +65,14 @@ gdk_win32_gl_config_class_init (GdkWin32GLConfigClass *klass)
* gdk_win32_gl_config_new_for_display:
* @display: display.
* @attrib_list: the attribute list.
+ * @n_attribs: the number of attributes and values in attrib_list
*
* Creates a #GdkGLConfig on the given display.
*
* Return value: the new #GdkGLConfig.
**/
GdkGLConfig *
-gdk_win32_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list)
+gdk_win32_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list, gsize n_attribs)
{
GdkGLConfig *glconfig;
GdkGLConfig *impl;
@@ -82,7 +83,7 @@ gdk_win32_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list)
g_return_val_if_fail(glconfig != NULL, NULL);
- impl = _gdk_win32_gl_config_impl_new(glconfig, attrib_list);
+ impl = _gdk_win32_gl_config_impl_new(glconfig, attrib_list, n_attribs);
if (impl == NULL)
g_object_unref(glconfig);
@@ -96,13 +97,14 @@ gdk_win32_gl_config_new_for_display(GdkDisplay *display, const int *attrib_list)
* gdk_win32_gl_config_new_for_screen:
* @screen: target screen.
* @attrib_list: the attribute list.
+ * @n_attribs: the number of attributes and values in attrib_list
*
* Creates a #GdkGLConfig on the given display.
*
* Return value: the new #GdkGLConfig.
**/
GdkGLConfig *
-gdk_win32_gl_config_new_for_screen(GdkScreen *screen, const int *attrib_list)
+gdk_win32_gl_config_new_for_screen(GdkScreen *screen, const int *attrib_list, gsize n_attribs)
{
GdkGLConfig *glconfig;
GdkGLConfig *impl;
@@ -111,7 +113,7 @@ gdk_win32_gl_config_new_for_screen(GdkScreen *screen, const int *attrib_list)
g_return_val_if_fail(glconfig != NULL, NULL);
- impl = _gdk_win32_gl_config_impl_new(glconfig, attrib_list);
+ impl = _gdk_win32_gl_config_impl_new(glconfig, attrib_list, n_attribs);
if (impl == NULL)
g_object_unref(glconfig);
diff --git a/gdk/win32/gdkwin32glconfig.h b/gdk/win32/gdkwin32glconfig.h
index 8bec11f..eaf4403 100644
--- a/gdk/win32/gdkwin32glconfig.h
+++ b/gdk/win32/gdkwin32glconfig.h
@@ -45,9 +45,11 @@ typedef struct _GdkWin32GLConfigClass GdkWin32GLConfigClass;
GType gdk_win32_gl_config_get_type (void);
GdkGLConfig *gdk_win32_gl_config_new_for_display (GdkDisplay *display,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *gdk_win32_gl_config_new_for_screen (GdkScreen *screen,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *gdk_win32_gl_config_new_from_pixel_format (int pixel_format);
PIXELFORMATDESCRIPTOR *gdk_win32_gl_config_get_pfd (GdkGLConfig *glconfig);
--
1.7.7.6
From b9acf3421854752fa1d1b156df6f70574ff051c1 Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <tdz users sourceforge net>
Date: Wed, 6 Jun 2012 18:42:15 +0200
Subject: gdk: Don't 0-terminate attribute array of configuration.
When creating a configuration, the caller must now supply the number
of elements in the attribute array. This is necessary for reliably
supporting GObject annotations. This patch changes the public interface.
---
examples/low-level.c | 5 ++---
gdk/gdkglconfig.c | 46 ++++++++++++++++++++++++++++------------------
gdk/gdkglconfig.h | 9 ++++++---
3 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/examples/low-level.c b/examples/low-level.c
index 952f1b6..c19460e 100644
--- a/examples/low-level.c
+++ b/examples/low-level.c
@@ -34,7 +34,6 @@ static const int config_attributes[] = {
GDK_GL_GREEN_SIZE, 1,
GDK_GL_BLUE_SIZE, 1,
GDK_GL_DEPTH_SIZE, 12,
- GDK_GL_ATTRIB_LIST_NONE
};
static void
@@ -312,14 +311,14 @@ main (int argc,
*/
/* Try double-buffered visual */
- glconfig = gdk_gl_config_new (&config_attributes[0]);
+ glconfig = gdk_gl_config_new (&config_attributes[0], G_N_ELEMENTS(config_attributes));
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 (&config_attributes[1]);
+ glconfig = gdk_gl_config_new (&config_attributes[1], G_N_ELEMENTS(config_attributes)-1);
if (glconfig == NULL)
{
g_print ("*** No appropriate OpenGL-capable visual found.\n");
diff --git a/gdk/gdkglconfig.c b/gdk/gdkglconfig.c
index 5be121d..4b7d43e 100644
--- a/gdk/gdkglconfig.c
+++ b/gdk/gdkglconfig.c
@@ -80,7 +80,6 @@ gdk_gl_config_new_ci (GdkScreen *screen,
list[n++] = GDK_GL_STENCIL_SIZE;
list[n++] = 1;
}
- list[n] = GDK_GL_ATTRIB_LIST_NONE;
/* from GLUT */
/* glXChooseVisual specify GLX_BUFFER_SIZE prefers the
@@ -96,7 +95,7 @@ gdk_gl_config_new_ci (GdkScreen *screen,
/* XXX Assumes list[1] is where GDK_GL_BUFFER_SIZE parameter is. */
list[1] = buf_size_list[i];
- glconfig = gdk_gl_config_new_for_screen (screen, list);
+ glconfig = gdk_gl_config_new_for_screen (screen, list, n);
if (glconfig != NULL)
return glconfig;
@@ -156,9 +155,8 @@ gdk_gl_config_new_rgb (GdkScreen *screen,
list[n++] = 1;
}
}
- list[n] = GDK_GL_ATTRIB_LIST_NONE;
- return gdk_gl_config_new_for_screen (screen, list);
+ return gdk_gl_config_new_for_screen (screen, list, n);
}
static GdkGLConfig *
@@ -400,8 +398,8 @@ gdk_gl_config_has_accum_buffer (GdkGLConfig *glconfig)
/**
* gdk_gl_config_new:
- * @attrib_list: a list of attribute/value pairs. The last attribute must
- * be GDK_GL_ATTRIB_LIST_NONE.
+ * @attrib_list: a list of attribute/value pairs.
+ * @n_attribs: the number of attributes and values in attrib_list.
*
* Returns an OpenGL frame buffer configuration that match the specified
* attributes.
@@ -417,17 +415,18 @@ gdk_gl_config_has_accum_buffer (GdkGLConfig *glconfig)
* Return value: the new #GdkGLConfig.
**/
GdkGLConfig *
-gdk_gl_config_new (const int *attrib_list)
+gdk_gl_config_new (const int *attrib_list, gsize n_attribs)
{
return gdk_gl_config_new_for_display(gdk_display_get_default(),
- attrib_list);
+ attrib_list,
+ n_attribs);
}
/**
* gdk_gl_config_new_for_display:
* @screen: target display.
- * @attrib_list: a list of attribute/value pairs. The last attribute must
- * be GDK_GL_ATTRIB_LIST_NONE.
+ * @attrib_list: a list of attribute/value pairs.
+ * @n_attribs: the number of attributes and values in attrib_list.
*
* Returns an OpenGL frame buffer configuration that match the specified
* attributes.
@@ -443,21 +442,27 @@ gdk_gl_config_new (const int *attrib_list)
* Return value: the new #GdkGLConfig.
**/
GdkGLConfig *
-gdk_gl_config_new_for_display (GdkDisplay *display, const int *attrib_list)
+gdk_gl_config_new_for_display (GdkDisplay *display,
+ const int *attrib_list,
+ gsize n_attribs)
{
GdkGLConfig *glconfig = NULL;
#ifdef GDKGLEXT_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(display))
{
- glconfig = gdk_x11_gl_config_new_for_display(display, attrib_list, 64);
+ glconfig = gdk_x11_gl_config_new_for_display(display,
+ attrib_list,
+ n_attribs);
}
else
#endif
#ifdef GDKGLEXT_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY(display))
{
- glconfig = gdk_win32_gl_config_new_for_display(display, attrib_list, 64);
+ glconfig = gdk_win32_gl_config_new_for_display(display,
+ attrib_list,
+ n_attribs);
}
else
#endif
@@ -471,8 +476,8 @@ gdk_gl_config_new_for_display (GdkDisplay *display, const int *attrib_list)
/**
* gdk_gl_config_new_for_screen:
* @screen: target screen.
- * @attrib_list: a list of attribute/value pairs. The last attribute must
- * be GDK_GL_ATTRIB_LIST_NONE.
+ * @attrib_list: a list of attribute/value pairs.
+ * @n_attribs: the number of attributes and values in attrib_list.
*
* Returns an OpenGL frame buffer configuration that match the specified
* attributes.
@@ -489,7 +494,8 @@ gdk_gl_config_new_for_display (GdkDisplay *display, const int *attrib_list)
**/
GdkGLConfig *
gdk_gl_config_new_for_screen (GdkScreen *screen,
- const int *attrib_list)
+ const int *attrib_list,
+ gsize n_attribs)
{
GdkDisplay *display;
GdkGLConfig *glconfig = NULL;
@@ -505,14 +511,18 @@ gdk_gl_config_new_for_screen (GdkScreen *screen,
#ifdef GDKGLEXT_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(display))
{
- glconfig = gdk_x11_gl_config_new_for_screen(screen, attrib_list, 64);
+ glconfig = gdk_x11_gl_config_new_for_screen(screen,
+ attrib_list,
+ n_attribs);
}
else
#endif
#ifdef GDKGLEXT_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY(display))
{
- glconfig = gdk_win32_gl_config_new_for_screen(screen, attrib_list, 64);
+ glconfig = gdk_win32_gl_config_new_for_screen(screen,
+ attrib_list,
+ n_attribs);
}
else
#endif
diff --git a/gdk/gdkglconfig.h b/gdk/gdkglconfig.h
index 3aadb2e..58e5917 100644
--- a/gdk/gdkglconfig.h
+++ b/gdk/gdkglconfig.h
@@ -73,14 +73,17 @@ struct _GdkGLConfigClass
GType gdk_gl_config_get_type (void);
#ifndef GDK_MULTIHEAD_SAFE
-GdkGLConfig *gdk_gl_config_new (const int *attrib_list);
+GdkGLConfig *gdk_gl_config_new (const int *attrib_list,
+ gsize n_attribs);
#endif /* GDK_MULTIHEAD_SAFE */
GdkGLConfig *gdk_gl_config_new_for_display (GdkDisplay *display,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
GdkGLConfig *gdk_gl_config_new_for_screen (GdkScreen *screen,
- const int *attrib_list);
+ const int *attrib_list,
+ gsize n_attribs);
#ifndef GDK_MULTIHEAD_SAFE
GdkGLConfig *gdk_gl_config_new_by_mode (GdkGLConfigMode mode);
--
1.7.7.6
Attachment:
signature.asc
Description: This is a digitally signed message part