summaryrefslogtreecommitdiff
path: root/plugins/gtkui/gtkglext-gtk3/gdk
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2013-08-15 20:38:57 +0200
committerGravatar waker <wakeroid@gmail.com>2013-08-15 20:38:57 +0200
commit60b4644d37583566563641185d13aaa1a453f908 (patch)
treed0f1bb918840647b0e9f18b22b3c270e6d8601ec /plugins/gtkui/gtkglext-gtk3/gdk
parent1ab7955320ef408889a220bd87af33ccc7de7a52 (diff)
gtkui: added experimental gtkglext port to GTK3, fixed GTK3 build errors
Diffstat (limited to 'plugins/gtkui/gtkglext-gtk3/gdk')
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgl.h40
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.c603
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.h127
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.c70
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.h74
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.c254
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.h84
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.c59
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.h61
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgldebug.h73
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgldefs.h44
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.c126
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.h70
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglenumtypes.h0
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglext-config.h27
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.c226
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.h43
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglprivate.h46
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.c271
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.h52
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgltokens.h248
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkgltypes.h45
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.c88
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.h68
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.c347
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.h88
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.c60
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.h58
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.c559
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.h74
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.c591
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.h85
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglprivate-x11.h39
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.c417
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.h39
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.c262
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.h68
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglx.h39
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.c245
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.h82
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.c115
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.h65
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glquery.h34
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.c80
-rw-r--r--plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.h62
45 files changed, 6208 insertions, 0 deletions
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgl.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgl.h
new file mode 100644
index 00000000..b996f5b0
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgl.h
@@ -0,0 +1,40 @@
+/* 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_H__
+#define __GDK_GL_H__
+
+#define __GDKGL_H_INSIDE__
+
+#include "gdkglext-config.h"
+
+#include "gdkgldefs.h"
+#include "gdkglversion.h"
+#include "gdkgltokens.h"
+#include "gdkgltypes.h"
+#include "gdkglenumtypes.h"
+#include "gdkglinit.h"
+#include "gdkglquery.h"
+#include "gdkglconfig.h"
+#include "gdkglcontext.h"
+#include "gdkgldrawable.h"
+#include "gdkglwindow.h"
+
+#undef __GDKGL_H_INSIDE__
+
+#endif /* __GDK_GL_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.c
new file mode 100644
index 00000000..6fa328b7
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.c
@@ -0,0 +1,603 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gdkglprivate.h"
+#include "gdkglconfig.h"
+
+#include <gdk/gdk.h>
+
+#ifdef GDKGLEXT_WINDOWING_X11
+#include "x11/gdkx11glconfig.h"
+#include "x11/gdkglconfig-x11.h"
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+#include "win32/gdkwin32glconfig.h"
+#include "win32/gdkglconfig-win32.h"
+#endif
+
+G_DEFINE_TYPE (GdkGLConfig, \
+ gdk_gl_config, \
+ G_TYPE_OBJECT)
+
+static void
+gdk_gl_config_init (GdkGLConfig *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_gl_config_class_init (GdkGLConfigClass *klass)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static GdkGLConfig *
+gdk_gl_config_new_ci (GdkScreen *screen,
+ GdkGLConfigMode mode)
+{
+ GdkGLConfig *glconfig = NULL;
+ static const int buf_size_list[] = { 16, 12, 8, 4, 2, 1, 0 };
+ int list[32];
+ int n = 0;
+ int i;
+
+ list[n++] = GDK_GL_BUFFER_SIZE;
+ list[n++] = 1;
+ if (mode & GDK_GL_MODE_DOUBLE)
+ {
+ list[n++] = GDK_GL_DOUBLEBUFFER;
+ }
+ if (mode & GDK_GL_MODE_STEREO)
+ {
+ list[n++] = GDK_GL_STEREO;
+ }
+ if (mode & GDK_GL_MODE_DEPTH)
+ {
+ list[n++] = GDK_GL_DEPTH_SIZE;
+ list[n++] = 1;
+ }
+ if (mode & GDK_GL_MODE_STENCIL)
+ {
+ list[n++] = GDK_GL_STENCIL_SIZE;
+ list[n++] = 1;
+ }
+
+ /* from GLUT */
+ /* glXChooseVisual specify GLX_BUFFER_SIZE prefers the
+ "smallest index buffer of at least the specified size".
+ This would be reasonable if GLUT allowed the user to
+ specify the required buffe size, but GLUT's display mode
+ is too simplistic (easy to use?). GLUT should try to find
+ the "largest". So start with a large buffer size and
+ shrink until we find a matching one that exists. */
+
+ for (i = 0; buf_size_list[i]; i++)
+ {
+ /* 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, n);
+
+ if (glconfig != NULL)
+ return glconfig;
+ }
+
+ return NULL;
+}
+
+static GdkGLConfig *
+gdk_gl_config_new_rgb (GdkScreen *screen,
+ GdkGLConfigMode mode)
+{
+ int list[32];
+ int n = 0;
+
+ list[n++] = GDK_GL_RGBA;
+ list[n++] = GDK_GL_RED_SIZE;
+ list[n++] = 1;
+ list[n++] = GDK_GL_GREEN_SIZE;
+ list[n++] = 1;
+ list[n++] = GDK_GL_BLUE_SIZE;
+ list[n++] = 1;
+ if (mode & GDK_GL_MODE_ALPHA)
+ {
+ list[n++] = GDK_GL_ALPHA_SIZE;
+ list[n++] = 1;
+ }
+ if (mode & GDK_GL_MODE_DOUBLE)
+ {
+ list[n++] = GDK_GL_DOUBLEBUFFER;
+ }
+ if (mode & GDK_GL_MODE_STEREO)
+ {
+ list[n++] = GDK_GL_STEREO;
+ }
+ if (mode & GDK_GL_MODE_DEPTH)
+ {
+ list[n++] = GDK_GL_DEPTH_SIZE;
+ list[n++] = 1;
+ }
+ if (mode & GDK_GL_MODE_STENCIL)
+ {
+ list[n++] = GDK_GL_STENCIL_SIZE;
+ list[n++] = 1;
+ }
+ if (mode & GDK_GL_MODE_ACCUM)
+ {
+ list[n++] = GDK_GL_ACCUM_RED_SIZE;
+ list[n++] = 1;
+ list[n++] = GDK_GL_ACCUM_GREEN_SIZE;
+ list[n++] = 1;
+ list[n++] = GDK_GL_ACCUM_BLUE_SIZE;
+ list[n++] = 1;
+ if (mode & GDK_GL_MODE_ALPHA)
+ {
+ list[n++] = GDK_GL_ACCUM_ALPHA_SIZE;
+ list[n++] = 1;
+ }
+ }
+
+ return gdk_gl_config_new_for_screen (screen, list, n);
+}
+
+static GdkGLConfig *
+gdk_gl_config_new_by_mode_common (GdkScreen *screen,
+ GdkGLConfigMode mode)
+{
+ GdkGLConfig *glconfig;
+
+#define _GL_CONFIG_NEW_BY_MODE(__screen, __mode) \
+ ( ((__mode) & GDK_GL_MODE_INDEX) ? \
+ gdk_gl_config_new_ci (__screen, __mode) : \
+ gdk_gl_config_new_rgb (__screen, __mode) )
+
+ glconfig = _GL_CONFIG_NEW_BY_MODE (screen, mode);
+ if (glconfig == NULL)
+ {
+ /* Fallback cases when can't get exactly what was asked for... */
+ if (!(mode & GDK_GL_MODE_DOUBLE))
+ {
+ /* If we can't find a single buffered visual, try looking
+ for a double buffered visual. We can treat a double
+ buffered visual as a single buffered visual by changing
+ the draw buffer to GL_FRONT and treating any swap
+ buffers as no-ops. */
+ mode |= GDK_GL_MODE_DOUBLE;
+ glconfig = _GL_CONFIG_NEW_BY_MODE (screen, mode);
+ if (glconfig != NULL)
+ glconfig->impl->as_single_mode = TRUE;
+ }
+ }
+
+#undef _GL_CONFIG_NEW_BY_MODE
+
+ return glconfig;
+}
+
+/**
+ * gdk_gl_config_new_by_mode:
+ * @mode: display mode bit mask.
+ *
+ * Returns an OpenGL frame buffer configuration that match the specified
+ * display mode.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_gl_config_new_by_mode (GdkGLConfigMode mode)
+{
+ GdkScreen *screen;
+
+ screen = gdk_screen_get_default ();
+
+ return gdk_gl_config_new_by_mode_common (screen, mode);
+}
+
+/**
+ * gdk_gl_config_new_by_mode_for_screen:
+ * @screen: target screen.
+ * @mode: display mode bit mask.
+ *
+ * Returns an OpenGL frame buffer configuration that match the specified
+ * display mode.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_gl_config_new_by_mode_for_screen (GdkScreen *screen,
+ GdkGLConfigMode mode)
+{
+ return gdk_gl_config_new_by_mode_common (screen, mode);
+}
+
+/**
+ * gdk_gl_config_get_layer_plane:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets the layer plane (level) of the frame buffer.
+ * Zero is the default frame buffer.
+ * Positive layer planes correspond to frame buffers that overlay the default
+ * buffer, and negative layer planes correspond to frame buffers that underlie
+ * the default frame buffer.
+ *
+ * Return value: layer plane.
+ **/
+gint
+gdk_gl_config_get_layer_plane (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), 0);
+
+ return glconfig->impl->layer_plane;
+}
+
+/**
+ * gdk_gl_config_get_n_aux_buffers:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets the number of auxiliary color buffers.
+ *
+ * Return value: number of auxiliary color buffers.
+ **/
+gint
+gdk_gl_config_get_n_aux_buffers (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), 0);
+
+ return glconfig->impl->n_aux_buffers;
+}
+
+/**
+ * gdk_gl_config_get_n_sample_buffers:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets the number of multisample buffers.
+ *
+ * Return value: number of multisample buffers.
+ **/
+gint
+gdk_gl_config_get_n_sample_buffers (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), 0);
+
+ return glconfig->impl->n_sample_buffers;
+}
+
+/**
+ * gdk_gl_config_is_rgba:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configured frame buffer is RGBA mode.
+ *
+ * Return value: TRUE if the configured frame buffer is RGBA mode, FALSE
+ * otherwise.
+ **/
+gboolean
+gdk_gl_config_is_rgba (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return glconfig->impl->is_rgba;
+}
+
+/**
+ * gdk_gl_config_is_double_buffered:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configuration supports the double-buffered visual.
+ *
+ * Return value: TRUE if the double-buffered visual is supported, FALSE
+ * otherwise.
+ **/
+gboolean
+gdk_gl_config_is_double_buffered (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return (glconfig->impl->is_double_buffered && (!glconfig->impl->as_single_mode));
+}
+
+/**
+ * gdk_gl_config_is_stereo:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configuration supports the stereo visual.
+ *
+ * Return value: TRUE if the stereo visual is supported, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_config_is_stereo (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return glconfig->impl->is_stereo;
+}
+
+/**
+ * gdk_gl_config_has_alpha:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configured color buffer has alpha bits.
+ *
+ * Return value: TRUE if the color buffer has alpha bits, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_config_has_alpha (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return glconfig->impl->has_alpha;
+}
+
+/**
+ * gdk_gl_config_has_depth_buffer:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configured frame buffer has depth buffer.
+ *
+ * Return value: TRUE if the frame buffer has depth buffer, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_config_has_depth_buffer (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return glconfig->impl->has_depth_buffer;
+}
+
+/**
+ * gdk_gl_config_has_stencil_buffer:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configured frame buffer has stencil buffer.
+ *
+ * Return value: TRUE if the frame buffer has stencil buffer, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_config_has_stencil_buffer (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return glconfig->impl->has_stencil_buffer;
+}
+
+/**
+ * gdk_gl_config_has_accum_buffer:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Returns whether the configured frame buffer has accumulation buffer.
+ *
+ * Return value: TRUE if the frame buffer has accumulation buffer, FALSE
+ * otherwise.
+ **/
+gboolean
+gdk_gl_config_has_accum_buffer (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return glconfig->impl->has_accum_buffer;
+}
+
+/**
+ * gdk_gl_config_new:
+ * @attrib_list: (array length=n_attribs): 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.
+ *
+ * attrib_list is a int array that contains the attribute/value pairs.
+ * Available attributes are:
+ * GDK_GL_USE_GL, GDK_GL_BUFFER_SIZE, GDK_GL_LEVEL, GDK_GL_RGBA,
+ * 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.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_gl_config_new (const int *attrib_list, gsize n_attribs)
+{
+ return gdk_gl_config_new_for_display(gdk_display_get_default(),
+ attrib_list,
+ n_attribs);
+}
+
+/**
+ * gdk_gl_config_new_for_display:
+ * @screen: target display.
+ * @attrib_list: (array length=n_attribs): 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.
+ *
+ * attrib_list is a int array that contains the attribute/value pairs.
+ * Available attributes are:
+ * GDK_GL_USE_GL, GDK_GL_BUFFER_SIZE, GDK_GL_LEVEL, GDK_GL_RGBA,
+ * 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.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+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,
+ 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,
+ n_attribs);
+ }
+ else
+#endif
+ {
+ g_warning("Unsupported GDK backend");
+ }
+
+ return glconfig;
+}
+
+/**
+ * gdk_gl_config_new_for_screen:
+ * @screen: target screen.
+ * @attrib_list: (array length=n_attribs): 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.
+ *
+ * attrib_list is a int array that contains the attribute/value pairs.
+ * Available attributes are:
+ * GDK_GL_USE_GL, GDK_GL_BUFFER_SIZE, GDK_GL_LEVEL, GDK_GL_RGBA,
+ * 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.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_gl_config_new_for_screen (GdkScreen *screen,
+ const int *attrib_list,
+ gsize n_attribs)
+{
+ GdkDisplay *display;
+ GdkGLConfig *glconfig = NULL;
+
+ /* The linker returns undefined symbol '_gdk_win32_screen_get_type'
+ * for win32 builds when using GDK_IS_WIN32_SCREEN. Thus we lookup
+ * the screen's display and test the display instead.
+ */
+
+ display = gdk_screen_get_display(screen);
+ g_return_val_if_fail(display != NULL, NULL);
+
+#ifdef GDKGLEXT_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY(display))
+ {
+ 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,
+ n_attribs);
+ }
+ else
+#endif
+ {
+ g_warning("Unsupported GDK backend");
+ }
+
+ return glconfig;
+}
+
+/**
+ * gdk_gl_config_get_screen:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets #GdkScreen.
+ *
+ * Return value: the #GdkScreen.
+ **/
+GdkScreen *
+gdk_gl_config_get_screen (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return GDK_GL_CONFIG_IMPL_GET_CLASS (glconfig->impl)->get_screen (glconfig);
+}
+
+/**
+ * gdk_gl_config_get_attrib:
+ * @glconfig: a #GdkGLConfig.
+ * @attribute: the attribute to be returned.
+ * @value: returns the requested value.
+ *
+ * Gets information about a OpenGL frame buffer configuration.
+ *
+ * Return value: TRUE if it succeeded, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_config_get_attrib (GdkGLConfig *glconfig,
+ int attribute,
+ int *value)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return GDK_GL_CONFIG_IMPL_GET_CLASS (glconfig->impl)->get_attrib (glconfig, attribute, value);
+}
+
+/**
+ * gdk_gl_config_get_visual:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets the #GdkVisual that is appropriate for the OpenGL frame buffer
+ * configuration.
+ *
+ * Return value: the appropriate #GdkVisual.
+ **/
+GdkVisual *
+gdk_gl_config_get_visual (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return GDK_GL_CONFIG_IMPL_GET_CLASS (glconfig->impl)->get_visual (glconfig);
+}
+
+/**
+ * gdk_gl_config_get_depth:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets the color depth of the OpenGL-capable visual.
+ *
+ * Return value: number of bits per pixel
+ **/
+gint
+gdk_gl_config_get_depth (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
+
+ return GDK_GL_CONFIG_IMPL_GET_CLASS (glconfig->impl)->get_depth (glconfig);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.h
new file mode 100644
index 00000000..58e59178
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfig.h
@@ -0,0 +1,127 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_CONFIG_H__
+#define __GDK_GL_CONFIG_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgltypes.h>
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Display mode bit masks.
+ */
+typedef enum
+{
+ GDK_GL_MODE_RGB = 0,
+ GDK_GL_MODE_RGBA = 0, /* same as RGB */
+ GDK_GL_MODE_INDEX = 1 << 0,
+ GDK_GL_MODE_SINGLE = 0,
+ GDK_GL_MODE_DOUBLE = 1 << 1,
+ GDK_GL_MODE_STEREO = 1 << 2,
+ GDK_GL_MODE_ALPHA = 1 << 3,
+ 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 */
+} GdkGLConfigMode;
+
+struct _GdkGLConfigImpl;
+typedef struct _GdkGLConfigClass GdkGLConfigClass;
+
+#define GDK_TYPE_GL_CONFIG (gdk_gl_config_get_type ())
+#define GDK_GL_CONFIG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONFIG, GdkGLConfig))
+#define GDK_GL_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONFIG, GdkGLConfigClass))
+#define GDK_IS_GL_CONFIG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONFIG))
+#define GDK_IS_GL_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONFIG))
+#define GDK_GL_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONFIG, GdkGLConfigClass))
+
+struct _GdkGLConfig
+{
+ GObject parent_instance;
+
+ struct _GdkGLConfigImpl *impl;
+};
+
+struct _GdkGLConfigClass
+{
+ GObjectClass parent_class;
+};
+
+GType gdk_gl_config_get_type (void);
+
+#ifndef GDK_MULTIHEAD_SAFE
+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,
+ gsize n_attribs);
+
+GdkGLConfig *gdk_gl_config_new_for_screen (GdkScreen *screen,
+ const int *attrib_list,
+ gsize n_attribs);
+
+#ifndef GDK_MULTIHEAD_SAFE
+GdkGLConfig *gdk_gl_config_new_by_mode (GdkGLConfigMode mode);
+#endif /* GDK_MULTIHEAD_SAFE */
+
+GdkGLConfig *gdk_gl_config_new_by_mode_for_screen (GdkScreen *screen,
+ GdkGLConfigMode mode);
+
+GdkScreen *gdk_gl_config_get_screen (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_get_attrib (GdkGLConfig *glconfig,
+ int attribute,
+ int *value);
+
+GdkVisual *gdk_gl_config_get_visual (GdkGLConfig *glconfig);
+
+gint gdk_gl_config_get_depth (GdkGLConfig *glconfig);
+
+gint gdk_gl_config_get_layer_plane (GdkGLConfig *glconfig);
+
+gint gdk_gl_config_get_n_aux_buffers (GdkGLConfig *glconfig);
+
+gint gdk_gl_config_get_n_sample_buffers (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_is_rgba (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_is_double_buffered (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_is_stereo (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_has_alpha (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_has_depth_buffer (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_has_stencil_buffer (GdkGLConfig *glconfig);
+
+gboolean gdk_gl_config_has_accum_buffer (GdkGLConfig *glconfig);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_CONFIG_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.c
new file mode 100644
index 00000000..c74ad43a
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.c
@@ -0,0 +1,70 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gdk/gdk.h> /* for gdk_error_trap_(push|pop) () */
+
+#include "gdkgldebug.h"
+#include "gdkglconfigimpl.h"
+
+G_DEFINE_TYPE (GdkGLConfigImpl, gdk_gl_config_impl, G_TYPE_OBJECT);
+
+static void
+gdk_gl_config_impl_init (GdkGLConfigImpl *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ self->layer_plane = 0;
+ self->n_aux_buffers = 0;
+ self->n_sample_buffers = 0;
+ self->is_rgba = 0;
+ self->is_double_buffered = 0;
+ self->as_single_mode = 0;
+ self->is_stereo = 0;
+ self->has_alpha = 0;
+ self->has_depth_buffer = 0;
+ self->has_stencil_buffer = 0;
+ self->has_accum_buffer = 0;
+}
+
+static void
+gdk_gl_config_impl_finalize (GObject *object)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ G_OBJECT_CLASS (gdk_gl_config_impl_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_config_impl_class_init (GdkGLConfigImplClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ klass->create_gl_window = NULL;
+ klass->get_screen = NULL;
+ klass->get_attrib = NULL;
+ klass->get_visual = NULL;
+ klass->get_depth = NULL;
+
+ object_class->finalize = gdk_gl_config_impl_finalize;
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.h
new file mode 100644
index 00000000..9a034055
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglconfigimpl.h
@@ -0,0 +1,74 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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_CONFIG_IMPL_H__
+#define __GDK_GL_CONFIG_IMPL_H__
+
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_GL_CONFIG_IMPL (gdk_gl_config_impl_get_type ())
+#define GDK_GL_CONFIG_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONFIG_IMPL, GdkGLConfigImpl))
+#define GDK_GL_CONFIG_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONFIG_IMPL, GdkGLConfigImplClass))
+#define GDK_IS_GL_CONFIG_IMPL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONFIG_IMPL))
+#define GDK_IS_GL_CONFIG_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONFIG_IMPL))
+#define GDK_GL_CONFIG_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONFIG_IMPL, GdkGLConfigImplClass))
+
+typedef struct _GdkGLConfigImpl
+{
+ GObject parent;
+
+ gint layer_plane;
+
+ gint n_aux_buffers;
+
+ 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;
+} GdkGLConfigImpl;
+
+typedef struct _GdkGLConfigImplClass
+{
+ GObjectClass parent_class;
+
+ GdkGLWindow* (*create_gl_window) (GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list);
+
+ GdkScreen* (*get_screen) (GdkGLConfig *glconfig);
+ gboolean (*get_attrib) (GdkGLConfig *glconfig,
+ int attribute,
+ int *value);
+ GdkVisual* (*get_visual) (GdkGLConfig *glconfig);
+ gint (*get_depth) (GdkGLConfig *glconfig);
+
+} GdkGLConfigImplClass;
+
+GType gdk_gl_config_impl_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_CONFIG_IMPL_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.c
new file mode 100644
index 00000000..4196c44f
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.c
@@ -0,0 +1,254 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef GDKGLEXT_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+#include <gdk/gdkwin32.h>
+#endif
+
+#include "gdkglprivate.h"
+#include "gdkgldrawable.h"
+#include "gdkglconfig.h"
+#include "gdkglcontext.h"
+#include "gdkglcontextimpl.h"
+
+#ifdef GDKGLEXT_WINDOWING_X11
+#include "x11/gdkglcontext-x11.h"
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+#include "win32/gdkglcontext-win32.h"
+#endif
+
+gboolean _gdk_gl_context_force_indirect = FALSE;
+
+G_DEFINE_TYPE (GdkGLContext, \
+ gdk_gl_context, \
+ G_TYPE_OBJECT)
+
+static void
+gdk_gl_context_init (GdkGLContext *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_gl_context_class_init (GdkGLContextClass *klass)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+/**
+ * gdk_gl_context_new:
+ * @gldrawable: a #GdkGLDrawable.
+ * @share_list: the #GdkGLContext with which to share display lists and texture
+ * objects. NULL indicates that no sharing is to take place.
+ * @direct: whether rendering is to be done with a direct connection to
+ * the graphics system.
+ * @render_type: GDK_GL_RGBA_TYPE.
+ *
+ * Creates a new OpenGL rendering context.
+ *
+ * Return value: the new #GdkGLContext.
+ **/
+GdkGLContext *
+gdk_gl_context_new (GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type)
+{
+ g_return_val_if_fail (GDK_IS_GL_DRAWABLE (gldrawable), NULL);
+
+ return GDK_GL_DRAWABLE_GET_CLASS (gldrawable)->create_gl_context (gldrawable,
+ share_list,
+ direct,
+ render_type);
+}
+
+/**
+ * gdk_gl_context_copy:
+ * @glcontext: a #GdkGLContext.
+ * @src: the source context.
+ * @mask: which portions of @src state are to be copied to @glcontext.
+ *
+ * Copy state from @src rendering context to @glcontext.
+ *
+ * @mask contains the bitwise-OR of the same symbolic names that are passed to
+ * the glPushAttrib() function. You can use GL_ALL_ATTRIB_BITS to copy all the
+ * rendering state information.
+ *
+ * Return value: FALSE if it fails, TRUE otherwise.
+ **/
+gboolean
+gdk_gl_context_copy (GdkGLContext *glcontext,
+ GdkGLContext *src,
+ unsigned long mask)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->copy_gl_context_impl (glcontext,
+ src,
+ mask);
+}
+
+/**
+ * gdk_gl_context_get_gl_drawable:
+ * @glcontext: a #GdkGLContext.
+ *
+ * Gets #GdkGLDrawable to which the @glcontext is bound.
+ *
+ * Return value: the #GdkGLDrawable or NULL if no #GdkGLDrawable is bound.
+ **/
+GdkGLDrawable *
+gdk_gl_context_get_gl_drawable (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->get_gl_drawable (glcontext);
+}
+
+/**
+ * gdk_gl_context_get_gl_config:
+ * @glcontext: a #GdkGLContext.
+ *
+ * Gets #GdkGLConfig with which the @glcontext is configured.
+ *
+ * Return value: the #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_gl_context_get_gl_config (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->get_gl_config (glcontext);
+}
+
+/**
+ * gdk_gl_context_get_share_list:
+ * @glcontext: a #GdkGLContext.
+ *
+ * Gets #GdkGLContext with which the @glcontext shares the display lists and
+ * texture objects.
+ *
+ * Return value: the #GdkGLContext.
+ **/
+GdkGLContext *
+gdk_gl_context_get_share_list (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->get_share_list(glcontext);
+}
+
+/**
+ * gdk_gl_context_is_direct:
+ * @glcontext: a #GdkGLContext.
+ *
+ * Returns whether the @glcontext is a direct rendering context.
+ *
+ * Return value: TRUE if the @glcontext is a direct rendering contest.
+ **/
+gboolean
+gdk_gl_context_is_direct (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->is_direct(glcontext);
+}
+
+/**
+ * gdk_gl_context_get_render_type:
+ * @glcontext: a #GdkGLContext.
+ *
+ * Gets render_type of the @glcontext.
+ *
+ * Return value: GDK_GL_RGBA_TYPE.
+ **/
+int
+gdk_gl_context_get_render_type (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->get_render_type(glcontext);
+}
+
+gboolean
+gdk_gl_context_make_current(GdkGLContext *glcontext,
+ GdkGLDrawable *draw,
+ GdkGLDrawable *read)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->make_current(glcontext,
+ draw,
+ read);
+}
+
+/**
+ * gdk_gl_context_release_current:
+ *
+ * Releases the current #GdkGLContext.
+ **/
+void
+gdk_gl_context_release_current ()
+{
+ GdkGLContext *glcontext = gdk_gl_context_get_current();
+
+ g_return_if_fail(glcontext != NULL);
+
+ if (GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->make_uncurrent)
+ GDK_GL_CONTEXT_IMPL_GET_CLASS (glcontext->impl)->make_uncurrent(glcontext);
+}
+
+/**
+ * gdk_gl_context_get_current:
+ *
+ * Returns the current #GdkGLContext.
+ *
+ * Return value: the current #GdkGLContext or NULL if there is no current
+ * context.
+ **/
+GdkGLContext *
+gdk_gl_context_get_current ()
+{
+ /*
+ * There can only be one current context. So we try each target
+ * and take the first non-NULL result. Hopefully the underlying
+ * GL implementation behaves accordingly. But we probalby need
+ * a better strategy here.
+ */
+
+ GdkGLContext *current = NULL;
+
+#ifdef GDKGLEXT_WINDOWING_X11
+ current = _gdk_x11_gl_context_impl_get_current();
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+ if (current == NULL)
+ {
+ current = _gdk_win32_gl_context_impl_get_current();
+ }
+#endif
+
+ return current;
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.h
new file mode 100644
index 00000000..0ddd5194
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontext.h
@@ -0,0 +1,84 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_CONTEXT_H__
+#define __GDK_GL_CONTEXT_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgltypes.h>
+
+G_BEGIN_DECLS
+
+struct _GdkGLContextImpl;
+typedef struct _GdkGLContextClass GdkGLContextClass;
+
+#define GDK_TYPE_GL_CONTEXT (gdk_gl_context_get_type ())
+#define GDK_GL_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONTEXT, GdkGLContext))
+#define GDK_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT, GdkGLContextClass))
+#define GDK_IS_GL_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONTEXT))
+#define GDK_IS_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT))
+#define GDK_GL_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContextClass))
+
+struct _GdkGLContext
+{
+ GObject parent_instance;
+
+ struct _GdkGLContextImpl *impl;
+};
+
+struct _GdkGLContextClass
+{
+ GObjectClass parent_class;
+};
+
+GType gdk_gl_context_get_type (void);
+
+GdkGLContext *gdk_gl_context_new (GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type);
+
+gboolean gdk_gl_context_copy (GdkGLContext *glcontext,
+ GdkGLContext *src,
+ unsigned long mask);
+
+GdkGLDrawable *gdk_gl_context_get_gl_drawable (GdkGLContext *glcontext);
+
+GdkGLConfig *gdk_gl_context_get_gl_config (GdkGLContext *glcontext);
+
+GdkGLContext *gdk_gl_context_get_share_list (GdkGLContext *glcontext);
+
+gboolean gdk_gl_context_is_direct (GdkGLContext *glcontext);
+
+int gdk_gl_context_get_render_type (GdkGLContext *glcontext);
+
+gboolean gdk_gl_context_make_current (GdkGLContext *glcontext,
+ GdkGLDrawable *draw,
+ GdkGLDrawable *read);
+
+void gdk_gl_context_release_current (void);
+
+GdkGLContext *gdk_gl_context_get_current (void);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_CONTEXT_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.c
new file mode 100644
index 00000000..fdf51375
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.c
@@ -0,0 +1,59 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gdk/gdk.h> /* for gdk_error_trap_(push|pop) () */
+
+#include "gdkgldebug.h"
+#include "gdkglcontextimpl.h"
+
+G_DEFINE_TYPE (GdkGLContextImpl, gdk_gl_context_impl, G_TYPE_OBJECT);
+
+static void
+gdk_gl_context_impl_init (GdkGLContextImpl *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_gl_context_impl_finalize (GObject *object)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ G_OBJECT_CLASS (gdk_gl_context_impl_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_context_impl_class_init (GdkGLContextImplClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ klass->copy_gl_context_impl = NULL;
+ klass->get_gl_drawable = NULL;
+ klass->get_gl_config = NULL;
+ klass->get_share_list = NULL;
+ klass->is_direct = NULL;
+ klass->get_render_type = NULL;
+
+ object_class->finalize = gdk_gl_context_impl_finalize;
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.h
new file mode 100644
index 00000000..b6feb6fd
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglcontextimpl.h
@@ -0,0 +1,61 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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_CONTEXT_IMPL_H__
+#define __GDK_GL_CONTEXT_IMPL_H__
+
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_GL_CONTEXT_IMPL (gdk_gl_context_impl_get_type ())
+#define GDK_GL_CONTEXT_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONTEXT_IMPL, GdkGLContextImpl))
+#define GDK_GL_CONTEXT_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT_IMPL, GdkGLContextImplClass))
+#define GDK_IS_GL_CONTEXT_IMPL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONTEXT_IMPL))
+#define GDK_IS_GL_CONTEXT_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT_IMPL))
+#define GDK_GL_CONTEXT_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT_IMPL, GdkGLContextImplClass))
+
+typedef struct _GdkGLContextImpl
+{
+ GObject parent;
+} GdkGLContextImpl;
+
+typedef struct _GdkGLContextImplClass
+{
+ GObjectClass parent_class;
+
+ gboolean (*copy_gl_context_impl) (GdkGLContext *glcontext,
+ GdkGLContext *src,
+ unsigned long mask);
+ GdkGLDrawable* (*get_gl_drawable) (GdkGLContext *glcontext);
+ GdkGLConfig* (*get_gl_config) (GdkGLContext *glcontext);
+ GdkGLContext* (*get_share_list) (GdkGLContext *glcontext);
+ gboolean (*is_direct) (GdkGLContext *glcontext);
+ int (*get_render_type) (GdkGLContext *glcontext);
+ gboolean (*make_current)(GdkGLContext *glcontext,
+ GdkGLDrawable *draw,
+ GdkGLDrawable *read);
+ void (*make_uncurrent)(GdkGLContext *glcontext);
+
+} GdkGLContextImplClass;
+
+GType gdk_gl_context_impl_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_CONTEXT_IMPL_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldebug.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldebug.h
new file mode 100644
index 00000000..4a8a8663
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldebug.h
@@ -0,0 +1,73 @@
+/* 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_DEBUG_H__
+#define __GDK_GL_DEBUG_H__
+
+#include <glib.h>
+
+#include <gdk/gdkgldefs.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ GDK_GL_DEBUG_MISC = 1 << 0,
+ GDK_GL_DEBUG_FUNC = 1 << 1,
+ GDK_GL_DEBUG_IMPL = 1 << 2
+} GdkGLDebugFlag;
+
+#ifdef G_ENABLE_DEBUG
+
+#define GDK_GL_NOTE(type, action) G_STMT_START { \
+ if (gdk_gl_debug_flags & GDK_GL_DEBUG_##type) \
+ { action; }; } G_STMT_END
+
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2
+# define __func__ __FUNCTION__
+# else
+# define __func__ "<unknown>"
+# endif
+#endif
+
+#define GDK_GL_NOTE_FUNC() G_STMT_START { \
+ if (gdk_gl_debug_flags & GDK_GL_DEBUG_FUNC) \
+ g_message (" - %s ()", __func__); } G_STMT_END
+
+#define GDK_GL_NOTE_FUNC_PRIVATE() G_STMT_START { \
+ if (gdk_gl_debug_flags & GDK_GL_DEBUG_FUNC) \
+ g_message (" -- %s ()", __func__); } G_STMT_END
+
+#define GDK_GL_NOTE_FUNC_IMPL(func) G_STMT_START { \
+ if (gdk_gl_debug_flags & GDK_GL_DEBUG_IMPL) \
+ g_message (" ** %s ()", (func)); } G_STMT_END
+
+#else /* !G_ENABLE_DEBUG */
+
+#define GDK_GL_NOTE(type, action)
+#define GDK_GL_NOTE_FUNC()
+#define GDK_GL_NOTE_FUNC_PRIVATE()
+#define GDK_GL_NOTE_FUNC_IMPL(func)
+
+#endif /* G_ENABLE_DEBUG */
+
+GDK_GL_VAR guint gdk_gl_debug_flags;
+
+G_END_DECLS
+
+#endif /* __GDK_GL_DEBUG_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldefs.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldefs.h
new file mode 100644
index 00000000..e5f54c7c
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldefs.h
@@ -0,0 +1,44 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_DEFS_H__
+#define __GDK_GL_DEFS_H__
+
+#include <glib.h>
+
+#include <gdkglext-config.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_OS_WIN32
+# ifdef GDK_GL_COMPILATION
+# define GDK_GL_VAR __declspec(dllexport)
+# else
+# define GDK_GL_VAR extern __declspec(dllimport)
+# endif
+#else
+# define GDK_GL_VAR extern
+#endif
+
+G_END_DECLS
+
+#endif /* __GDK_GL_DEFS_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.c
new file mode 100644
index 00000000..86b1749c
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.c
@@ -0,0 +1,126 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <gdk/gdk.h>
+
+#include "gdkglprivate.h"
+#include "gdkglcontext.h"
+#include "gdkgldrawable.h"
+
+GType
+gdk_gl_drawable_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ {
+ static const GTypeInfo type_info = {
+ sizeof (GdkGLDrawableClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "GdkGLDrawable",
+ &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * gdk_gl_drawable_is_double_buffered:
+ * @gldrawable: a #GdkGLDrawable.
+ *
+ * Returns whether the @gldrawable supports the double-buffered visual.
+ *
+ * Return value: TRUE if the double-buffered visual is supported,
+ * FALSE otherwise.
+ **/
+gboolean
+gdk_gl_drawable_is_double_buffered (GdkGLDrawable *gldrawable)
+{
+ g_return_val_if_fail (GDK_IS_GL_DRAWABLE (gldrawable), FALSE);
+
+ return GDK_GL_DRAWABLE_GET_CLASS (gldrawable)->is_double_buffered (gldrawable);
+}
+
+/**
+ * gdk_gl_drawable_swap_buffers:
+ * @gldrawable: a #GdkGLDrawable.
+ *
+ * Exchange front and back buffers.
+ *
+ **/
+void
+gdk_gl_drawable_swap_buffers (GdkGLDrawable *gldrawable)
+{
+ g_return_if_fail (GDK_IS_GL_DRAWABLE (gldrawable));
+
+ GDK_GL_DRAWABLE_GET_CLASS (gldrawable)->swap_buffers (gldrawable);
+}
+
+/**
+ * gdk_gl_drawable_wait_gl:
+ * @gldrawable: a #GdkGLDrawable.
+ *
+ * Complete OpenGL execution prior to subsequent GDK drawing calls.
+ *
+ **/
+void
+gdk_gl_drawable_wait_gl (GdkGLDrawable *gldrawable)
+{
+ g_return_if_fail (GDK_IS_GL_DRAWABLE (gldrawable));
+
+ GDK_GL_DRAWABLE_GET_CLASS (gldrawable)->wait_gl (gldrawable);
+}
+
+/**
+ * gdk_gl_drawable_wait_gdk:
+ * @gldrawable: a #GdkGLDrawable.
+ *
+ * Complete GDK drawing execution prior to subsequent OpenGL calls.
+ *
+ **/
+void
+gdk_gl_drawable_wait_gdk (GdkGLDrawable *gldrawable)
+{
+ g_return_if_fail (GDK_IS_GL_DRAWABLE (gldrawable));
+
+ GDK_GL_DRAWABLE_GET_CLASS (gldrawable)->wait_gdk (gldrawable);
+}
+
+/**
+ * gdk_gl_drawable_get_gl_config:
+ * @gldrawable: a #GdkGLDrawable.
+ *
+ * Gets #GdkGLConfig with which the @gldrawable is configured.
+ *
+ * Return value: the #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_gl_drawable_get_gl_config (GdkGLDrawable *gldrawable)
+{
+ g_return_val_if_fail (GDK_IS_GL_DRAWABLE (gldrawable), NULL);
+
+ return GDK_GL_DRAWABLE_GET_CLASS (gldrawable)->get_gl_config (gldrawable);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.h
new file mode 100644
index 00000000..e69aa61f
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgldrawable.h
@@ -0,0 +1,70 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_DRAWABLE_H__
+#define __GDK_GL_DRAWABLE_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgltypes.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GdkGLDrawableClass GdkGLDrawableClass;
+
+#define GDK_TYPE_GL_DRAWABLE (gdk_gl_drawable_get_type ())
+#define GDK_GL_DRAWABLE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), GDK_TYPE_GL_DRAWABLE, GdkGLDrawable))
+#define GDK_GL_DRAWABLE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GDK_TYPE_GL_DRAWABLE, GdkGLDrawableClass))
+#define GDK_IS_GL_DRAWABLE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), GDK_TYPE_GL_DRAWABLE))
+#define GDK_IS_GL_DRAWABLE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GDK_TYPE_GL_DRAWABLE))
+#define GDK_GL_DRAWABLE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GDK_TYPE_GL_DRAWABLE, GdkGLDrawableClass))
+
+struct _GdkGLDrawableClass
+{
+ GTypeInterface base_iface;
+
+ GdkGLContext* (*create_gl_context) (GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type);
+
+ gboolean (*is_double_buffered) (GdkGLDrawable *gldrawable);
+ void (*swap_buffers) (GdkGLDrawable *gldrawable);
+ void (*wait_gl) (GdkGLDrawable *gldrawable);
+ void (*wait_gdk) (GdkGLDrawable *gldrawable);
+ GdkGLConfig* (*get_gl_config) (GdkGLDrawable *gldrawable);
+};
+
+GType gdk_gl_drawable_get_type (void);
+
+gboolean gdk_gl_drawable_is_double_buffered (GdkGLDrawable *gldrawable);
+
+void gdk_gl_drawable_swap_buffers (GdkGLDrawable *gldrawable);
+
+void gdk_gl_drawable_wait_gl (GdkGLDrawable *gldrawable);
+
+void gdk_gl_drawable_wait_gdk (GdkGLDrawable *gldrawable);
+
+GdkGLConfig *gdk_gl_drawable_get_gl_config (GdkGLDrawable *gldrawable);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_DRAWABLE_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglenumtypes.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglenumtypes.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglenumtypes.h
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglext-config.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglext-config.h
new file mode 100644
index 00000000..31b3d7c8
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglext-config.h
@@ -0,0 +1,27 @@
+/* gdkglext-config.h
+ *
+ * This is a generated file. Please modify `configure.ac'
+ */
+
+#ifndef GDKGLEXT_CONFIG_H
+#define GDKGLEXT_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#define GDKGLEXT_WINDOWING_X11
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GDKGLEXT_CONFIG_H */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.c
new file mode 100644
index 00000000..556b1165
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.c
@@ -0,0 +1,226 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+
+#include "gdkglprivate.h"
+#include "gdkglquery.h"
+#include "gdkglinit.h"
+
+static gboolean gdk_gl_initialized = FALSE;
+
+guint gdk_gl_debug_flags = 0; /* Global GdkGLExt debug flag */
+
+#ifdef G_ENABLE_DEBUG
+
+static const GDebugKey gdk_gl_debug_keys[] = {
+ {"misc", GDK_GL_DEBUG_MISC},
+ {"func", GDK_GL_DEBUG_FUNC},
+ {"impl", GDK_GL_DEBUG_IMPL}
+};
+
+static const guint gdk_gl_ndebug_keys = G_N_ELEMENTS (gdk_gl_debug_keys);
+
+#endif /* G_ENABLE_DEBUG */
+
+/**
+ * gdk_gl_parse_args:
+ * @argc: the number of command line arguments.
+ * @argv: the array of command line arguments.
+ *
+ * Parses command line arguments, and initializes global
+ * attributes of GdkGLExt.
+ *
+ * Any arguments used by GdkGLExt are removed from the array and
+ * @argc and @argv are updated accordingly.
+ *
+ * You shouldn't call this function explicitely if you are using
+ * gdk_gl_init(), or gdk_gl_init_check().
+ **/
+static void
+gdk_gl_parse_args (int *argc,
+ char ***argv)
+{
+ const gchar *env_string;
+
+ if (gdk_gl_initialized)
+ return;
+
+ env_string = g_getenv ("GDK_GL_FORCE_INDIRECT");
+ if (env_string != NULL)
+ {
+ _gdk_gl_context_force_indirect = !!g_ascii_strtoll (env_string, NULL, 0);
+ env_string = NULL;
+ }
+
+#ifdef G_ENABLE_DEBUG
+ env_string = g_getenv ("GDK_GL_DEBUG");
+ if (env_string != NULL)
+ {
+ gdk_gl_debug_flags = g_parse_debug_string (env_string,
+ gdk_gl_debug_keys,
+ gdk_gl_ndebug_keys);
+ env_string = NULL;
+ }
+#endif /* G_ENABLE_DEBUG */
+
+ if (argc && argv)
+ {
+ gint i, j, k;
+
+ for (i = 1; i < *argc;)
+ {
+ if (strcmp ("--gdk-gl-force-indirect", (*argv)[i]) == 0)
+ {
+ _gdk_gl_context_force_indirect = TRUE;
+ (*argv)[i] = NULL;
+ }
+#ifdef G_ENABLE_DEBUG
+ else if ((strcmp ("--gdk-gl-debug", (*argv)[i]) == 0) ||
+ (strncmp ("--gdk-gl-debug=", (*argv)[i], 15) == 0))
+ {
+ gchar *equal_pos = strchr ((*argv)[i], '=');
+
+ if (equal_pos != NULL)
+ {
+ gdk_gl_debug_flags |= g_parse_debug_string (equal_pos+1,
+ gdk_gl_debug_keys,
+ gdk_gl_ndebug_keys);
+ }
+ else if ((i + 1) < *argc && (*argv)[i + 1])
+ {
+ gdk_gl_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+ gdk_gl_debug_keys,
+ gdk_gl_ndebug_keys);
+ (*argv)[i] = NULL;
+ i += 1;
+ }
+ (*argv)[i] = NULL;
+ }
+ else if ((strcmp ("--gdk-gl-no-debug", (*argv)[i]) == 0) ||
+ (strncmp ("--gdk-gl-no-debug=", (*argv)[i], 18) == 0))
+ {
+ gchar *equal_pos = strchr ((*argv)[i], '=');
+
+ if (equal_pos != NULL)
+ {
+ gdk_gl_debug_flags &= ~g_parse_debug_string (equal_pos+1,
+ gdk_gl_debug_keys,
+ gdk_gl_ndebug_keys);
+ }
+ else if ((i + 1) < *argc && (*argv)[i + 1])
+ {
+ gdk_gl_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
+ gdk_gl_debug_keys,
+ gdk_gl_ndebug_keys);
+ (*argv)[i] = NULL;
+ i += 1;
+ }
+ (*argv)[i] = NULL;
+ }
+#endif /* G_ENABLE_DEBUG */
+ i += 1;
+ }
+
+ for (i = 1; i < *argc; i++)
+ {
+ for (k = i; k < *argc; k++)
+ if ((*argv)[k] != NULL)
+ break;
+
+ if (k > i)
+ {
+ k -= i;
+ for (j = i + k; j < *argc; j++)
+ (*argv)[j-k] = (*argv)[j];
+ *argc -= k;
+ }
+ }
+
+ }
+
+ /* Set the 'initialized' flag. */
+ gdk_gl_initialized = TRUE;
+}
+
+/**
+ * gdk_gl_init_check:
+ * @argc: Address of the <parameter>argc</parameter> parameter of your
+ * <function>main()</function> function. Changed if any arguments
+ * were handled.
+ * @argv: Address of the <parameter>argv</parameter> parameter of
+ * <function>main()</function>. Any parameters understood by
+ * gdk_gl_init() are stripped before return.
+ *
+ * This function does the same work as gdk_gl_init() with only
+ * a single change: It does not terminate the program if the library can't be
+ * initialized. Instead it returns %FALSE on failure.
+ *
+ * This way the application can fall back to some other means of communication
+ * with the user - for example a curses or command line interface.
+ *
+ * Return value: %TRUE if the GUI has been successfully initialized,
+ * %FALSE otherwise.
+ **/
+gboolean
+gdk_gl_init_check (int *argc,
+ char ***argv)
+{
+ /* Parse args and init GdkGLExt library. */
+ gdk_gl_parse_args (argc, argv);
+
+ /* Is OpenGL supported? */
+ if (!gdk_gl_query_extension ())
+ {
+ g_warning ("Window system doesn't support OpenGL.");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * gdk_gl_init:
+ * @argc: Address of the <parameter>argc</parameter> parameter of your
+ * main() function. Changed if any arguments were handled.
+ * @argv: Address of the <parameter>argv</parameter> parameter of
+ * main(). Any parameters understood by gdk_gl_init() are stripped
+ * before return.
+ *
+ * Call this function before using any other GdkGLExt functions in your
+ * applications. It will initialize everything needed to operate the
+ * library and parses some standard command line options. @argc and
+ * @argv are adjusted accordingly so your own code will never see those
+ * standard arguments.
+ *
+ * <note><para>This function will terminate your program if it was
+ * unable to initialize the library for some reason. If you want your
+ * program to fall back to a textual interface you want to call
+ * gdk_gl_init_check() instead.</para></note>
+ **/
+void
+gdk_gl_init (int *argc,
+ char ***argv)
+{
+ if (!gdk_gl_init_check (argc, argv))
+ g_error ("GdkGLExt library initialization fails.");
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.h
new file mode 100644
index 00000000..d3fe0549
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglinit.h
@@ -0,0 +1,43 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_INIT_H__
+#define __GDK_GL_INIT_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgltypes.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Initialization routines.
+ */
+
+gboolean gdk_gl_init_check (int *argc,
+ char ***argv);
+
+void gdk_gl_init (int *argc,
+ char ***argv);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_INIT_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglprivate.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglprivate.h
new file mode 100644
index 00000000..9bdafc98
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglprivate.h
@@ -0,0 +1,46 @@
+/* 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_PRIVATE_H__
+#define __GDK_GL_PRIVATE_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgldebug.h>
+#include <gdk/gdkgltokens.h>
+#include <gdk/gdkgltypes.h>
+#include <gdk/gdkgldrawable.h>
+
+G_BEGIN_DECLS
+
+#define _GDK_GL_CONCAT(x, y) x##y
+
+#define _GDK_GL_CONFIG_AS_SINGLE_MODE(glconfig) ((glconfig->impl)->as_single_mode)
+
+void _gdk_gl_window_get_size (GdkGLDrawable *gldrawable,
+ gint *width,
+ gint *height);
+
+void _gdk_gl_print_gl_info (void);
+
+/* Internal globals */
+
+extern gboolean _gdk_gl_context_force_indirect;
+
+G_END_DECLS
+
+#endif /* __GDK_GL_PRIVATE_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.c
new file mode 100644
index 00000000..341abc78
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.c
@@ -0,0 +1,271 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "gdkglprivate.h"
+#include "gdkglquery.h"
+
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifdef GDK_WINDOWING_QUARTZ
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
+
+#ifdef GDKGLEXT_WINDOWING_X11
+#include <gdk/gdkx.h>
+#include "x11/gdkglquery-x11.h"
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+#include <gdk/gdkwin32.h>
+#include "win32/gdkglquery-win32.h"
+#endif
+
+/*
+ * This code is based on glutExtensionSupported().
+ */
+
+/**
+ * gdk_gl_query_gl_extension:
+ * @extension: name of OpenGL extension.
+ *
+ * Determines whether a given OpenGL extension is supported.
+ *
+ * There must be a valid current rendering context to call
+ * gdk_gl_query_gl_extension().
+ *
+ * gdk_gl_query_gl_extension() returns information about OpenGL extensions
+ * only. This means that window system dependent extensions (for example,
+ * GLX extensions) are not reported by gdk_gl_query_gl_extension().
+ *
+ * Return value: TRUE if the OpenGL extension is supported, FALSE if not
+ * supported.
+ **/
+gboolean
+gdk_gl_query_gl_extension (const char *extension)
+{
+ static const GLubyte *extensions = NULL;
+ const GLubyte *start;
+ GLubyte *where, *terminator;
+
+ /* Extension names should not have spaces. */
+ where = (GLubyte *) strchr (extension, ' ');
+ if (where || *extension == '\0')
+ return FALSE;
+
+ if (extensions == NULL)
+ extensions = glGetString (GL_EXTENSIONS);
+
+ /* It takes a bit of care to be fool-proof about parsing the
+ OpenGL extensions string. Don't be fooled by sub-strings,
+ etc. */
+ start = extensions;
+ for (;;)
+ {
+ /* If your application crashes in the strstr routine below,
+ you are probably calling gdk_gl_query_gl_extension without
+ having a current window. Calling glGetString without
+ a current OpenGL context has unpredictable results.
+ Please fix your program. */
+ where = (GLubyte *) strstr ((const char *) start, extension);
+ if (where == NULL)
+ break;
+
+ terminator = where + strlen (extension);
+
+ if (where == start || *(where - 1) == ' ')
+ if (*terminator == ' ' || *terminator == '\0')
+ {
+ GDK_GL_NOTE (MISC, g_message (" - %s - supported", extension));
+ return TRUE;
+ }
+
+ start = terminator;
+ }
+
+ GDK_GL_NOTE (MISC, g_message (" - %s - not supported", extension));
+
+ return FALSE;
+}
+
+/**
+ * gdk_gl_query_extension:
+ *
+ * Indicates whether the window system supports the OpenGL extension
+ * (GLX, WGL, etc.).
+ *
+ * Return value: TRUE if OpenGL is supported, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_query_extension (void)
+{
+ return gdk_gl_query_extension_for_display(gdk_display_get_default());
+}
+
+/**
+ * gdk_gl_query_extension_for_display:
+ * @display: the #GdkDisplay where the query is sent to.
+ *
+ * Indicates whether the window system supports the OpenGL extension
+ * (GLX, WGL, etc.).
+ *
+ * Return value: TRUE if OpenGL is supported, FALSE otherwise.
+ **/
+gboolean
+gdk_gl_query_extension_for_display (GdkDisplay *display)
+{
+ gboolean supp = FALSE;
+
+#ifdef GDKGLEXT_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY(display))
+ {
+ supp = _gdk_x11_gl_query_extension_for_display(display);
+ }
+ else
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+ if (GDK_IS_WIN32_DISPLAY(display))
+ {
+ supp = _gdk_win32_gl_query_extension_for_display(display);
+ }
+ else
+#endif
+ {
+ g_warning("Unsupported GDK backend");
+ }
+
+ return supp;
+}
+
+/**
+ * gdk_gl_query_version:
+ * @major: returns the major version number of the OpenGL extension.
+ * @minor: returns the minor version number of the OpenGL extension.
+ *
+ * Returns the version numbers of the OpenGL extension to the window system.
+ *
+ * In the X Window System, it returns the GLX version.
+ *
+ * In the Microsoft Windows, it returns the Windows version.
+ *
+ * Return value: FALSE if it fails, TRUE otherwise.
+ **/
+gboolean
+gdk_gl_query_version (int *major,
+ int *minor)
+{
+ return gdk_gl_query_version_for_display(gdk_display_get_default(), major, minor);
+}
+
+/**
+ * gdk_gl_query_version_for_display:
+ * @display: the #GdkDisplay where the query is sent to.
+ * @major: returns the major version number of the OpenGL extension.
+ * @minor: returns the minor version number of the OpenGL extension.
+ *
+ * Returns the version numbers of the OpenGL extension to the window system.
+ *
+ * In the X Window System, it returns the GLX version.
+ *
+ * In the Microsoft Windows, it returns the Windows version.
+ *
+ * Return value: FALSE if it fails, TRUE otherwise.
+ **/
+gboolean
+gdk_gl_query_version_for_display (GdkDisplay *display,
+ int *major,
+ int *minor)
+{
+ gboolean succ = FALSE;
+
+#ifdef GDKGLEXT_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY(display))
+ {
+ succ = _gdk_x11_gl_query_version_for_display(display, major, minor);
+ }
+ else
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+ if (GDK_IS_WIN32_DISPLAY(display))
+ {
+ succ = _gdk_win32_gl_query_version_for_display(display, major, minor);
+ }
+ else
+#endif
+ {
+ g_warning("Unsupported GDK backend");
+ }
+
+ return succ;
+}
+
+/**
+ * gdk_gl_get_proc_address:
+ * @proc_name: function name.
+ *
+ * Returns the address of the OpenGL, GLU, or GLX function.
+ *
+ * Return value: the address of the function named by @proc_name.
+ **/
+GdkGLProc
+gdk_gl_get_proc_address (const char *proc_name)
+{
+ GdkGLProc addr = NULL;
+
+#ifdef GDKGLEXT_WINDOWING_X11
+ if (!addr)
+ {
+ addr = _gdk_x11_gl_get_proc_address(proc_name);
+ }
+#endif
+#ifdef GDKGLEXT_WINDOWING_WIN32
+ if (!addr)
+ {
+ addr = _gdk_win32_gl_get_proc_address(proc_name);
+ }
+#endif
+
+ return addr;
+}
+
+/*< private >*/
+void
+_gdk_gl_print_gl_info (void)
+{
+ static gboolean done = FALSE;
+
+ if (!done)
+ {
+ g_message (" -- GL_VENDOR : %s", glGetString (GL_VENDOR));
+ g_message (" -- GL_RENDERER : %s", glGetString (GL_RENDERER));
+ g_message (" -- GL_VERSION : %s", glGetString (GL_VERSION));
+ g_message (" -- GL_EXTENSIONS : %s", glGetString (GL_EXTENSIONS));
+
+ done = TRUE;
+ }
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.h
new file mode 100644
index 00000000..4235813c
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglquery.h
@@ -0,0 +1,52 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_QUERY_H__
+#define __GDK_GL_QUERY_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgltypes.h>
+
+G_BEGIN_DECLS
+
+#ifndef GDK_MULTIHEAD_SAFE
+gboolean gdk_gl_query_extension (void);
+#endif /* GDK_MULTIHEAD_SAFE */
+
+gboolean gdk_gl_query_extension_for_display (GdkDisplay *display);
+
+#ifndef GDK_MULTIHEAD_SAFE
+gboolean gdk_gl_query_version (int *major,
+ int *minor);
+#endif /* GDK_MULTIHEAD_SAFE */
+
+gboolean gdk_gl_query_version_for_display (GdkDisplay *display,
+ int *major,
+ int *minor);
+
+gboolean gdk_gl_query_gl_extension (const char *extension);
+
+GdkGLProc gdk_gl_get_proc_address (const char *proc_name);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_QUERY_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgltokens.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgltokens.h
new file mode 100644
index 00000000..5d9a025c
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgltokens.h
@@ -0,0 +1,248 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_TOKENS_H__
+#define __GDK_GL_TOKENS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * Success return value
+ */
+#define GDK_GL_SUCCESS 0 /* same as 'Success' of X11 */
+
+/*
+ * Attribute list terminator
+ */
+#define GDK_GL_ATTRIB_LIST_NONE 0 /* same as 'None' of X11 */
+
+/*
+ * This source is based on the OpenGL(R) Sample Implementation by SGI.
+ */
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+/*
+ * Visual Config Attributes.
+ */
+typedef enum
+{
+ GDK_GL_USE_GL = 1, /* support GLX rendering */
+ GDK_GL_BUFFER_SIZE = 2, /* depth of the color buffer */
+ GDK_GL_LEVEL = 3, /* level in plane stacking */
+ GDK_GL_RGBA = 4, /* true if RGBA mode */
+ GDK_GL_DOUBLEBUFFER = 5, /* double buffering supported */
+ GDK_GL_STEREO = 6, /* stereo buffering supported */
+ GDK_GL_AUX_BUFFERS = 7, /* number of aux buffers */
+ GDK_GL_RED_SIZE = 8, /* number of red component bits */
+ GDK_GL_GREEN_SIZE = 9, /* number of green component bits */
+ GDK_GL_BLUE_SIZE = 10, /* number of blue component bits */
+ GDK_GL_ALPHA_SIZE = 11, /* number of alpha component bits */
+ GDK_GL_DEPTH_SIZE = 12, /* number of depth bits */
+ GDK_GL_STENCIL_SIZE = 13, /* number of stencil bits */
+ GDK_GL_ACCUM_RED_SIZE = 14, /* number of red accum bits */
+ GDK_GL_ACCUM_GREEN_SIZE = 15, /* number of green accum bits */
+ GDK_GL_ACCUM_BLUE_SIZE = 16, /* number of blue accum bits */
+ GDK_GL_ACCUM_ALPHA_SIZE = 17, /* number of alpha accum bits */
+
+ /*
+ * FBConfig-specific attributes.
+ * [ GLX 1.3 and later ]
+ */
+ GDK_GL_CONFIG_CAVEAT = 0x20,
+ GDK_GL_X_VISUAL_TYPE = 0x22,
+ GDK_GL_TRANSPARENT_TYPE = 0x23,
+ GDK_GL_TRANSPARENT_INDEX_VALUE = 0x24,
+ GDK_GL_TRANSPARENT_RED_VALUE = 0x25,
+ GDK_GL_TRANSPARENT_GREEN_VALUE = 0x26,
+ GDK_GL_TRANSPARENT_BLUE_VALUE = 0x27,
+ GDK_GL_TRANSPARENT_ALPHA_VALUE = 0x28,
+ GDK_GL_DRAWABLE_TYPE = 0x8010,
+ GDK_GL_RENDER_TYPE = 0x8011,
+ GDK_GL_X_RENDERABLE = 0x8012,
+ GDK_GL_FBCONFIG_ID = 0x8013,
+ GDK_GL_VISUAL_ID = 0x800B,
+ GDK_GL_SCREEN = 0x800C,
+
+ /*
+ * Multisampling configuration attributes.
+ * [ GLX 1.4 and later ]
+ */
+ GDK_GL_SAMPLE_BUFFERS = 100000,
+ GDK_GL_SAMPLES = 100001
+
+} GdkGLConfigAttrib;
+
+/*
+ * Generic "don't care" value.
+ * [ GLX 1.3 and later ]
+ */
+#define GDK_GL_DONT_CARE 0xFFFFFFFF
+
+/*
+ * "none" value.
+ * [ GLX 1.3 and later ]
+ */
+#define GDK_GL_NONE 0x8000
+
+/*
+ * GLX_CONFIG_CAVEAT attribute values.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_CONFIG_CAVEAT_DONT_CARE = (int)0xFFFFFFFF, /* GDK_GL_DONT_CARE */
+ GDK_GL_CONFIG_CAVEAT_NONE = 0x8000, /* GDK_GL_NONE */
+ GDK_GL_SLOW_CONFIG = 0x8001,
+ GDK_GL_NON_CONFORMANT_CONFIG = 0x800D
+} GdkGLConfigCaveat;
+
+/*
+ * GLX_X_VISUAL_TYPE attribute values.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_VISUAL_TYPE_DONT_CARE = (int)0xFFFFFFFF, /* GDK_GL_DONT_CARE */
+ GDK_GL_TRUE_COLOR = 0x8002,
+ GDK_GL_DIRECT_COLOR = 0x8003,
+} GdkGLVisualType;
+
+/*
+ * GLX_TRANSPARENT_TYPE attribute values.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_TRANSPARENT_NONE = 0x8000, /* GDK_GL_NONE */
+ GDK_GL_TRANSPARENT_RGB = 0x8008,
+} GdkGLTransparentType;
+
+/*
+ * GLX_DRAWABLE_TYPE bits.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_WINDOW_BIT = 1 << 0, /* 0x00000001 */
+} GdkGLDrawableTypeMask;
+
+/*
+ * GLX_RENDER_TYPE bits.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_RGBA_BIT = 1 << 0, /* 0x00000001 */
+} GdkGLRenderTypeMask;
+
+/*
+ * Buffer mask bits.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_FRONT_LEFT_BUFFER_BIT = 1 << 0, /* 0x00000001 */
+ GDK_GL_FRONT_RIGHT_BUFFER_BIT = 1 << 1, /* 0x00000002 */
+ GDK_GL_BACK_LEFT_BUFFER_BIT = 1 << 2, /* 0x00000004 */
+ GDK_GL_BACK_RIGHT_BUFFER_BIT = 1 << 3, /* 0x00000008 */
+ GDK_GL_AUX_BUFFERS_BIT = 1 << 4, /* 0x00000010 */
+ GDK_GL_DEPTH_BUFFER_BIT = 1 << 5, /* 0x00000020 */
+ GDK_GL_STENCIL_BUFFER_BIT = 1 << 6, /* 0x00000040 */
+ GDK_GL_ACCUM_BUFFER_BIT = 1 << 7 /* 0x00000080 */
+} GdkGLBufferMask;
+
+/*
+ * Error return values from glXGetConfig. Success is indicated by
+ * a value of 0.
+ */
+typedef enum
+{
+ GDK_GL_BAD_SCREEN = 1, /* screen # is bad */
+ GDK_GL_BAD_ATTRIBUTE = 2, /* attribute to get is bad */
+ GDK_GL_NO_EXTENSION = 3, /* no glx extension on server */
+ GDK_GL_BAD_VISUAL = 4, /* visual # not known by GLX */
+ GDK_GL_BAD_CONTEXT = 5, /* returned only by import_context EXT? */
+ GDK_GL_BAD_VALUE = 6, /* returned only by glXSwapIntervalSGI? */
+ GDK_GL_BAD_ENUM = 7 /* unused? */
+} GdkGLConfigError;
+
+/*
+ * glXCreateNewContext render_type attribute values.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_RGBA_TYPE = 0x8014,
+} GdkGLRenderType;
+
+/*
+ * glXQueryDrawable attributes.
+ * [ GLX 1.3 and later ]
+ */
+typedef enum
+{
+ GDK_GL_PRESERVED_CONTENTS = 0x801B,
+ GDK_GL_WIDTH = 0x801D,
+ GDK_GL_HEIGHT = 0x801E,
+ GDK_GL_EVENT_MASK = 0x801F
+} GdkGLDrawableAttrib;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GDK_GL_TOKENS_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkgltypes.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgltypes.h
new file mode 100644
index 00000000..c1bfc1d0
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkgltypes.h
@@ -0,0 +1,45 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_TYPES_H__
+#define __GDK_GL_TYPES_H__
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Forward declarations of commonly used types
+ */
+
+typedef void (*GdkGLProc)(void);
+
+typedef struct _GdkGLConfig GdkGLConfig;
+typedef struct _GdkGLContext GdkGLContext;
+
+typedef struct _GdkGLDrawable GdkGLDrawable;
+
+typedef struct _GdkGLWindow GdkGLWindow;
+
+G_END_DECLS
+
+#endif /* __GDK_GL_TYPES_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.c
new file mode 100644
index 00000000..972dae37
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.c
@@ -0,0 +1,88 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gdkglversion.h"
+
+/**
+ * gdk_gl_get_major_version:
+ *
+ * Returns the GtkGLExt library major version number.
+ *
+ * Returns: The major version number of the GtkGLExt library.
+ **/
+int
+gdk_gl_get_major_version (void)
+{
+ return (GDKGLEXT_MAJOR_VERSION);
+}
+
+/**
+ * gdk_gl_get_minor_version:
+ *
+ * Returns the GtkGLExt library minor version number.
+ *
+ * Returns: The minor version number of the GtkGLExt library.
+ **/
+int
+gdk_gl_get_minor_version (void)
+{
+ return (GDKGLEXT_MINOR_VERSION);
+}
+
+/**
+ * gdk_gl_get_micro_version:
+ *
+ * Returns the GtkGLExt library micro version number.
+ *
+ * Returns: The micro version number of the GtkGLExt library.
+ **/
+int
+gdk_gl_get_micro_version (void)
+{
+ return (GDKGLEXT_MICRO_VERSION);
+}
+
+/**
+ * gdk_gl_get_interface_age:
+ *
+ * Returns the GtkGLExt library interface age.
+ *
+ * Returns: The interface age of the GtkGLExt library.
+ **/
+int
+gdk_gl_get_interface_age (void)
+{
+ return (GDKGLEXT_INTERFACE_AGE);
+}
+
+/**
+ * gdk_gl_get_binary_age:
+ *
+ * Returns the GtkGLExt library binary age.
+ *
+ * Returns: The binary age of the GtkGLExt library.
+ **/
+int
+gdk_gl_get_binary_age (void)
+{
+ return (GDKGLEXT_BINARY_AGE);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.h
new file mode 100644
index 00000000..40f5ca33
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglversion.h
@@ -0,0 +1,68 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_VERSION_H__
+#define __GDK_GL_VERSION_H__
+
+#include <glib.h>
+
+#include <gdk/gdkgldefs.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Compile time version.
+ */
+#define GDKGLEXT_MAJOR_VERSION (2)
+#define GDKGLEXT_MINOR_VERSION (99)
+#define GDKGLEXT_MICRO_VERSION (0)
+#define GDKGLEXT_INTERFACE_AGE (0)
+#define GDKGLEXT_BINARY_AGE (9900)
+
+/*
+ * Check whether a GdkGLExt version equal to or greater than
+ * major.minor.micro is present.
+ */
+#define GDKGLEXT_CHECK_VERSION(major, minor, micro) \
+ (GDKGLEXT_MAJOR_VERSION > (major) || \
+ (GDKGLEXT_MAJOR_VERSION == (major) && GDKGLEXT_MINOR_VERSION > (minor)) || \
+ (GDKGLEXT_MAJOR_VERSION == (major) && GDKGLEXT_MINOR_VERSION == (minor) && \
+ GDKGLEXT_MICRO_VERSION >= (micro)))
+
+int
+gdk_gl_get_major_version (void);
+
+int
+gdk_gl_get_minor_version (void);
+
+int
+gdk_gl_get_micro_version (void);
+
+int
+gdk_gl_get_interface_age (void);
+
+int
+gdk_gl_get_binary_age (void);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_VERSION_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.c
new file mode 100644
index 00000000..ca65ee7e
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.c
@@ -0,0 +1,347 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <gdk/gdk.h>
+
+#include "gdkglprivate.h"
+#include "gdkglconfig.h"
+#include "gdkglconfigimpl.h"
+#include "gdkglwindow.h"
+#include "gdkglwindowimpl.h"
+
+static GdkGLContext *_gdk_gl_window_create_gl_context (GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type);
+static gboolean _gdk_gl_window_is_double_buffered (GdkGLDrawable *gldrawable);
+static void _gdk_gl_window_swap_buffers (GdkGLDrawable *gldrawable);
+static void _gdk_gl_window_wait_gl (GdkGLDrawable *gldrawable);
+static void _gdk_gl_window_wait_gdk (GdkGLDrawable *gldrawable);
+static GdkGLConfig *_gdk_gl_window_get_gl_config (GdkGLDrawable *gldrawable);
+
+static void gdk_gl_window_gl_drawable_interface_init (GdkGLDrawableClass *iface);
+
+G_DEFINE_TYPE_EXTENDED (GdkGLWindow,
+ gdk_gl_window,
+ G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE (
+ GDK_TYPE_GL_DRAWABLE,
+ gdk_gl_window_gl_drawable_interface_init))
+
+static void
+gdk_gl_window_init (GdkGLWindow *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ self->window = NULL;
+}
+
+static void
+gdk_gl_window_finalize (GObject *object)
+{
+ GdkGLWindow *glwindow = GDK_GL_WINDOW (object);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (glwindow->window != NULL)
+ g_object_remove_weak_pointer (G_OBJECT (glwindow->window),
+ (gpointer *) &(glwindow->window));
+
+ G_OBJECT_CLASS (gdk_gl_window_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_window_class_init (GdkGLWindowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ object_class->finalize = gdk_gl_window_finalize;
+}
+
+static void
+gdk_gl_window_gl_drawable_interface_init (GdkGLDrawableClass *iface)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ iface->create_gl_context = _gdk_gl_window_create_gl_context;
+ iface->is_double_buffered = _gdk_gl_window_is_double_buffered;
+ iface->swap_buffers = _gdk_gl_window_swap_buffers;
+ iface->wait_gl = _gdk_gl_window_wait_gl;
+ iface->wait_gdk = _gdk_gl_window_wait_gdk;
+ iface->get_gl_config = _gdk_gl_window_get_gl_config;
+}
+
+static GdkGLContext *
+_gdk_gl_window_create_gl_context (GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type)
+{
+ GdkGLWindow *glwindow;
+
+ g_return_val_if_fail(GDK_IS_GL_WINDOW(gldrawable), NULL);
+
+ glwindow = GDK_GL_WINDOW (gldrawable);
+
+ return GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->create_gl_context (glwindow,
+ share_list,
+ direct,
+ render_type);
+}
+
+static gboolean
+_gdk_gl_window_is_double_buffered (GdkGLDrawable *gldrawable)
+{
+ GdkGLWindow *glwindow;
+
+ g_return_val_if_fail(GDK_IS_GL_WINDOW(gldrawable), FALSE);
+
+ glwindow = GDK_GL_WINDOW (gldrawable);
+
+ return GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->is_double_buffered (glwindow);
+}
+
+static void
+_gdk_gl_window_swap_buffers (GdkGLDrawable *gldrawable)
+{
+ GdkGLWindow *glwindow;
+
+ g_return_if_fail(GDK_IS_GL_WINDOW(gldrawable));
+
+ glwindow = GDK_GL_WINDOW (gldrawable);
+
+ GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->swap_buffers (glwindow);
+}
+
+static void
+_gdk_gl_window_wait_gl (GdkGLDrawable *gldrawable)
+{
+ GdkGLWindow *glwindow;
+
+ g_return_if_fail(GDK_IS_GL_WINDOW(gldrawable));
+
+ glwindow = GDK_GL_WINDOW (gldrawable);
+
+ GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->wait_gl (glwindow);
+}
+
+static void
+_gdk_gl_window_wait_gdk (GdkGLDrawable *gldrawable)
+{
+ GdkGLWindow *glwindow;
+
+ g_return_if_fail(GDK_IS_GL_WINDOW(gldrawable));
+
+ glwindow = GDK_GL_WINDOW (gldrawable);
+
+ GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->wait_gdk (glwindow);
+}
+
+static GdkGLConfig *
+_gdk_gl_window_get_gl_config (GdkGLDrawable *gldrawable)
+{
+ GdkGLWindow *glwindow;
+
+ g_return_val_if_fail(GDK_IS_GL_WINDOW(gldrawable), NULL);
+
+ glwindow = GDK_GL_WINDOW (gldrawable);
+
+ return GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->get_gl_config (glwindow);
+}
+
+/**
+ * gdk_gl_window_new:
+ * @glconfig: a #GdkGLConfig.
+ * @window: the #GdkWindow to be used as the rendering area.
+ * @attrib_list: this must be set to NULL or empty (first attribute of None).
+ *
+ * Creates an on-screen rendering area.
+ * attrib_list is currently unused. This must be set to NULL or empty
+ * (first attribute of None). See GLX 1.3 spec.
+ *
+ * Return value: the new #GdkGLWindow.
+ **/
+GdkGLWindow *
+gdk_gl_window_new (GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list)
+{
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), NULL);
+
+ return GDK_GL_CONFIG_IMPL_GET_CLASS (glconfig->impl)->create_gl_window (glconfig,
+ window,
+ attrib_list);
+}
+
+/**
+ * gdk_gl_window_get_window:
+ * @glwindow: a #GdkGLWindow.
+ *
+ * Returns the #GdkWindow associated with @glwindow.
+ *
+ * Return value: the #GdkWindow associated with @glwindow.
+ **/
+GdkWindow *
+gdk_gl_window_get_window (GdkGLWindow *glwindow)
+{
+ g_return_val_if_fail (GDK_IS_GL_WINDOW (glwindow), NULL);
+
+ return glwindow->window;
+}
+
+/*
+ * OpenGL extension to GdkWindow
+ */
+
+static const gchar quark_gl_window_string[] = "gdk-gl-window-gl-window";
+static GQuark quark_gl_window = 0;
+
+/**
+ * gdk_window_set_gl_capability:
+ * @window: the #GdkWindow to be used as the rendering area.
+ * @glconfig: a #GdkGLConfig.
+ * @attrib_list: this must be set to NULL or empty (first attribute of None).
+ *
+ * Set the OpenGL-capability to the @window.
+ * This function creates a new #GdkGLWindow held by the @window.
+ * attrib_list is currently unused. This must be set to NULL or empty
+ * (first attribute of None).
+ *
+ * Return value: the #GdkGLWindow used by the @window if it is successful,
+ * NULL otherwise.
+ **/
+GdkGLWindow *
+gdk_window_set_gl_capability (GdkWindow *window,
+ GdkGLConfig *glconfig,
+ const int *attrib_list)
+{
+ GdkGLWindow *glwindow;
+
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), NULL);
+
+ if (quark_gl_window == 0)
+ quark_gl_window = g_quark_from_static_string (quark_gl_window_string);
+
+ /* If already set */
+ glwindow = g_object_get_qdata (G_OBJECT (window), quark_gl_window);
+ if (glwindow != NULL)
+ return glwindow;
+
+ /*
+ * Create GdkGLWindow
+ */
+
+ glwindow = gdk_gl_window_new (glconfig, window, attrib_list);
+ if (glwindow == NULL)
+ {
+ g_warning ("cannot create GdkGLWindow\n");
+ return NULL;
+ }
+
+ g_object_set_qdata_full (G_OBJECT (window), quark_gl_window, glwindow,
+ (GDestroyNotify) g_object_unref);
+
+ /*
+ * Set a background of "None" on window to avoid AIX X server crash
+ */
+
+ GDK_GL_NOTE (MISC,
+ g_message (" - window->bg_pixmap = %p",
+ (void*)gdk_window_get_background_pattern (window)));
+
+ gdk_window_set_background_pattern (window, NULL);
+
+ GDK_GL_NOTE (MISC,
+ g_message (" - window->bg_pixmap = %p",
+ (void*)gdk_window_get_background_pattern (window)));
+
+ return glwindow;
+}
+
+/**
+ * gdk_window_unset_gl_capability:
+ * @window: a #GdkWindow.
+ *
+ * Unset the OpenGL-capability of the @window.
+ * This function destroys the #GdkGLWindow held by the @window.
+ *
+ **/
+void
+gdk_window_unset_gl_capability (GdkWindow *window)
+{
+ GdkGLWindow *glwindow;
+
+ GDK_GL_NOTE_FUNC ();
+
+ if (quark_gl_window == 0)
+ quark_gl_window = g_quark_from_static_string (quark_gl_window_string);
+
+ /*
+ * Destroy OpenGL resources explicitly, then unref.
+ */
+
+ glwindow = g_object_get_qdata (G_OBJECT (window), quark_gl_window);
+ if (glwindow == NULL)
+ return;
+
+ GDK_GL_WINDOW_IMPL_GET_CLASS(glwindow->impl)->destroy_gl_window_impl(glwindow);
+
+ g_object_set_qdata (G_OBJECT (window), quark_gl_window, NULL);
+}
+
+/**
+ * gdk_window_is_gl_capable:
+ * @window: a #GdkWindow.
+ *
+ * Returns whether the @window is OpenGL-capable.
+ *
+ * Return value: TRUE if the @window is OpenGL-capable, FALSE otherwise.
+ **/
+gboolean
+gdk_window_is_gl_capable (GdkWindow *window)
+{
+ g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+
+ return g_object_get_qdata (G_OBJECT (window), quark_gl_window) != NULL ? TRUE : FALSE;
+}
+
+/**
+ * gdk_window_get_gl_window:
+ * @window: a #GdkWindow.
+ *
+ * Returns the #GdkGLWindow held by the @window.
+ *
+ * Return value: the #GdkGLWindow.
+ **/
+GdkGLWindow *
+gdk_window_get_gl_window (GdkWindow *window)
+{
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+ return g_object_get_qdata (G_OBJECT (window), quark_gl_window);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.h
new file mode 100644
index 00000000..8e43b36b
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindow.h
@@ -0,0 +1,88 @@
+/* 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.
+ */
+
+#if !defined (__GDKGL_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkgl.h> can be included directly."
+#endif
+
+#ifndef __GDK_GL_WINDOW_H__
+#define __GDK_GL_WINDOW_H__
+
+#include <gdk/gdkgldefs.h>
+#include <gdk/gdkgltypes.h>
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+struct _GdkGLWindowImpl;
+typedef struct _GdkGLWindowClass GdkGLWindowClass;
+
+#define GDK_TYPE_GL_WINDOW (gdk_gl_window_get_type ())
+#define GDK_GL_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_WINDOW, GdkGLWindow))
+#define GDK_GL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_WINDOW, GdkGLWindowClass))
+#define GDK_IS_GL_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_WINDOW))
+#define GDK_IS_GL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_WINDOW))
+#define GDK_GL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_WINDOW, GdkGLWindowClass))
+
+struct _GdkGLWindow
+{
+ GObject parent_instance;
+
+ struct _GdkGLWindowImpl *impl;
+
+ GdkWindow *window; /* Associated GdkWindow */
+};
+
+struct _GdkGLWindowClass
+{
+ GObjectClass parent_class;
+};
+
+GType gdk_gl_window_get_type (void);
+
+/*
+ * attrib_list is currently unused. This must be set to NULL or empty
+ * (first attribute of None). See GLX 1.3 spec.
+ */
+GdkGLWindow *gdk_gl_window_new (GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list);
+
+GdkWindow *gdk_gl_window_get_window (GdkGLWindow *glwindow);
+
+/*
+ * OpenGL extension to GdkWindow
+ */
+
+GdkGLWindow *gdk_window_set_gl_capability (GdkWindow *window,
+ GdkGLConfig *glconfig,
+ const int *attrib_list);
+
+void gdk_window_unset_gl_capability (GdkWindow *window);
+
+gboolean gdk_window_is_gl_capable (GdkWindow *window);
+
+GdkGLWindow *gdk_window_get_gl_window (GdkWindow *window);
+
+#define gdk_window_get_gl_drawable(window) \
+ GDK_GL_DRAWABLE (gdk_window_get_gl_window (window))
+
+G_END_DECLS
+
+#endif /* __GDK_GL_WINDOW_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.c b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.c
new file mode 100644
index 00000000..5682e3d2
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.c
@@ -0,0 +1,60 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gdk/gdk.h> /* for gdk_error_trap_(push|pop) () */
+
+#include "gdkgldebug.h"
+#include "gdkglwindowimpl.h"
+
+G_DEFINE_TYPE (GdkGLWindowImpl, gdk_gl_window_impl, G_TYPE_OBJECT);
+
+static void
+gdk_gl_window_impl_init (GdkGLWindowImpl *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_gl_window_impl_finalize (GObject *object)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ G_OBJECT_CLASS (gdk_gl_window_impl_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_window_impl_class_init (GdkGLWindowImplClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ klass->create_gl_context = NULL;
+ klass->is_double_buffered = NULL;
+ klass->swap_buffers = NULL;
+ klass->wait_gl = NULL;
+ klass->wait_gdk = NULL;
+ klass->get_gl_config = NULL;
+ klass->destroy_gl_window_impl = NULL;
+
+ object_class->finalize = gdk_gl_window_impl_finalize;
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.h b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.h
new file mode 100644
index 00000000..6d6780dc
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/gdkglwindowimpl.h
@@ -0,0 +1,58 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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_WINDOW_IMPL_H__
+#define __GDK_GL_WINDOW_IMPL_H__
+
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_GL_WINDOW_IMPL (gdk_gl_window_impl_get_type ())
+#define GDK_GL_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_WINDOW_IMPL, GdkGLWindowImpl))
+#define GDK_GL_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_WINDOW_IMPL, GdkGLWindowImplClass))
+#define GDK_IS_GL_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_WINDOW_IMPL))
+#define GDK_IS_GL_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_WINDOW_IMPL))
+#define GDK_GL_WINDOW_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_WINDOW_IMPL, GdkGLWindowImplClass))
+
+typedef struct _GdkGLWindowImpl
+{
+ GObject parent;
+} GdkGLWindowImpl;
+
+typedef struct _GdkGLWindowImplClass
+{
+ GObjectClass parent_class;
+
+ GdkGLContext* (*create_gl_context) (GdkGLWindow *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type);
+ gboolean (*is_double_buffered) (GdkGLWindow *glwindow);
+ void (*swap_buffers) (GdkGLWindow *glwindow);
+ void (*wait_gl) (GdkGLWindow *glwindow);
+ void (*wait_gdk) (GdkGLWindow *glwindow);
+ GdkGLConfig* (*get_gl_config) (GdkGLWindow *glwindow);
+ void (*destroy_gl_window_impl) (GdkGLWindow *glwindow);
+} GdkGLWindowImplClass;
+
+GType gdk_gl_window_impl_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_WINDOW_IMPL_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.c
new file mode 100644
index 00000000..03b4d5b2
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.c
@@ -0,0 +1,559 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+
+#include "gdkglx.h"
+#include "gdkglprivate-x11.h"
+#include "gdkglconfig-x11.h"
+#include "gdkglwindow-x11.h"
+
+#include <gdk/gdk.h>
+
+#ifdef HAVE_LIBXMU
+
+#include <X11/Xatom.h> /* for XA_RGB_DEFAULT_MAP atom */
+
+#ifdef HAVE_XMU_STDCMAP_H
+#include <Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
+#else
+#include <X11/Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
+#endif
+
+#endif /* HAVE_LIBXMU */
+
+static Display *_gdk_x11_gl_config_impl_get_xdisplay (GdkGLConfig *glconfig);
+static int _gdk_x11_gl_config_impl_get_screen_number (GdkGLConfig *glconfig);
+static XVisualInfo *_gdk_x11_gl_config_impl_get_xvinfo (GdkGLConfig *glconfig);
+static GdkGLWindow *_gdk_x11_gl_config_impl_create_gl_window (GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list);
+static GdkScreen *_gdk_x11_gl_config_impl_get_screen (GdkGLConfig *glconfig);
+static gboolean _gdk_x11_gl_config_impl_get_attrib (GdkGLConfig *glconfig,
+ int attribute,
+ int *value);
+static GdkVisual *_gdk_x11_gl_config_impl_get_visual (GdkGLConfig *glconfig);
+static gint _gdk_x11_gl_config_impl_get_depth (GdkGLConfig *glconfig);
+
+G_DEFINE_TYPE (GdkGLConfigImplX11, \
+ gdk_gl_config_impl_x11, \
+ GDK_TYPE_GL_CONFIG_IMPL)
+
+static void
+gdk_gl_config_impl_x11_init (GdkGLConfigImplX11 *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ self->xdisplay = NULL;
+ self->screen_num = 0;
+ self->xvinfo = NULL;
+ self->screen = 0;
+}
+
+static void
+gdk_gl_config_impl_x11_finalize (GObject *object)
+{
+ GdkGLConfigImplX11 *x11_impl = GDK_GL_CONFIG_IMPL_X11 (object);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ XFree (x11_impl->xvinfo);
+
+ G_OBJECT_CLASS (gdk_gl_config_impl_x11_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_config_impl_x11_class_init (GdkGLConfigImplX11Class *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ klass->get_xdisplay = _gdk_x11_gl_config_impl_get_xdisplay;
+ klass->get_screen_number = _gdk_x11_gl_config_impl_get_screen_number;
+ klass->get_xvinfo = _gdk_x11_gl_config_impl_get_xvinfo;
+
+ klass->parent_class.create_gl_window = _gdk_x11_gl_config_impl_create_gl_window;
+ klass->parent_class.get_screen = _gdk_x11_gl_config_impl_get_screen;
+ klass->parent_class.get_attrib = _gdk_x11_gl_config_impl_get_attrib;
+ klass->parent_class.get_visual = _gdk_x11_gl_config_impl_get_visual;
+ klass->parent_class.get_depth = _gdk_x11_gl_config_impl_get_depth;
+
+ object_class->finalize = gdk_gl_config_impl_x11_finalize;
+}
+
+static void
+gdk_x11_gl_config_impl_init_attrib (GdkGLConfig *glconfig)
+{
+ GdkGLConfigImplX11 *x11_impl;
+ int value;
+
+ x11_impl = GDK_GL_CONFIG_IMPL_X11 (glconfig->impl);
+
+#define _GET_CONFIG(__attrib) \
+ glXGetConfig (x11_impl->xdisplay, x11_impl->xvinfo, __attrib, &value)
+
+ /* RGBA mode? */
+ _GET_CONFIG (GLX_RGBA);
+ glconfig->impl->is_rgba = value ? TRUE : FALSE;
+
+ /* Layer plane. */
+ _GET_CONFIG (GLX_LEVEL);
+ glconfig->impl->layer_plane = value;
+
+ /* Double buffering is supported? */
+ _GET_CONFIG (GLX_DOUBLEBUFFER);
+ glconfig->impl->is_double_buffered = value ? TRUE : FALSE;
+
+ /* Stereo is supported? */
+ _GET_CONFIG (GLX_STEREO);
+ glconfig->impl->is_stereo = value ? TRUE : FALSE;
+
+ /* Number of aux buffers */
+ _GET_CONFIG (GLX_AUX_BUFFERS);
+ glconfig->impl->n_aux_buffers = value;
+
+ /* Has alpha bits? */
+ _GET_CONFIG (GLX_ALPHA_SIZE);
+ glconfig->impl->has_alpha = value ? TRUE : FALSE;
+
+ /* Has depth buffer? */
+ _GET_CONFIG (GLX_DEPTH_SIZE);
+ glconfig->impl->has_depth_buffer = value ? TRUE : FALSE;
+
+ /* Has stencil buffer? */
+ _GET_CONFIG (GLX_STENCIL_SIZE);
+ glconfig->impl->has_stencil_buffer = value ? TRUE : FALSE;
+
+ /* Has accumulation buffer? */
+ _GET_CONFIG (GLX_ACCUM_RED_SIZE);
+ glconfig->impl->has_accum_buffer = value ? TRUE : FALSE;
+
+ /* Number of multisample buffers (not supported yet) */
+ glconfig->impl->n_sample_buffers = 0;
+
+#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 attrib_index;
+ gsize glx_attrib_index;
+
+ 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 (attrib_index = 0, glx_attrib_index = 0; (attrib_index < n_attribs) && attrib_list[attrib_index]; ++attrib_index)
+ {
+ switch (attrib_list[attrib_index])
+ {
+ case GDK_GL_USE_GL:
+ /* legacy from GLX 1.2 and always true; will be removed */
+ case GDK_GL_RGBA:
+ /* not supported anymore */
+ break;
+
+ default:
+ glx_attrib_list[glx_attrib_index++] = glx_attrib_of_attrib[attrib_list[attrib_index]];
+ if ( has_param[attrib_list[attrib_index]] )
+ {
+ ++attrib_index;
+ if (attrib_index == n_attribs)
+ goto err_n_attribs;
+ glx_attrib_list[glx_attrib_index++] = attrib_list[attrib_index];
+ }
+ break;
+ }
+ }
+
+ glx_attrib_list[glx_attrib_index++] = GLX_RGBA;
+ glx_attrib_list[glx_attrib_index++] = GLX_USE_GL;
+ glx_attrib_list[glx_attrib_index++] = None;
+
+ 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,
+ gsize n_attribs)
+{
+ GdkGLConfigImplX11 *x11_impl;
+
+ Display *xdisplay;
+ int screen_num;
+ int *glx_attrib_list;
+ XVisualInfo *xvinfo;
+ int is_rgba;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ xdisplay = GDK_SCREEN_XDISPLAY (screen);
+ screen_num = GDK_SCREEN_XNUMBER (screen);
+
+ GDK_GL_NOTE (MISC, _gdk_x11_gl_print_glx_info (xdisplay, screen_num));
+
+ /*
+ * 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, glx_attrib_list);
+
+ if (xvinfo == NULL)
+ goto err_glXChooseVisual;
+
+ GDK_GL_NOTE (MISC,
+ g_message (" -- glXChooseVisual: screen number = %d", xvinfo->screen));
+ GDK_GL_NOTE (MISC,
+ g_message (" -- glXChooseVisual: visual id = 0x%lx", xvinfo->visualid));
+
+ /*
+ * Instantiate the GdkGLConfigImplX11 object.
+ */
+
+ x11_impl = g_object_new (GDK_TYPE_GL_CONFIG_IMPL_X11, NULL);
+
+ x11_impl->xdisplay = xdisplay;
+ x11_impl->screen_num = screen_num;
+ x11_impl->xvinfo = xvinfo;
+
+ x11_impl->screen = screen;
+
+ /* RGBA mode? */
+ glXGetConfig (xdisplay, xvinfo, GLX_RGBA, &is_rgba);
+
+ /*
+ * Init GdkGLConfig
+ */
+ glconfig->impl = GDK_GL_CONFIG_IMPL (x11_impl);
+
+ /*
+ * Init configuration attributes.
+ */
+
+ 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,
+ gsize n_attribs)
+{
+ GdkScreen *screen;
+
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG(glconfig), NULL);
+ g_return_val_if_fail (attrib_list != NULL, NULL);
+
+ screen = gdk_screen_get_default ();
+
+ 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,
+ gsize n_attribs)
+{
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG(glconfig), NULL);
+ 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, n_attribs);
+}
+
+/*
+ * XVisualInfo returned by this function should be freed by XFree ().
+ */
+static XVisualInfo *
+gdk_x11_gl_get_xvinfo (Display *xdisplay,
+ int screen_num,
+ VisualID xvisualid)
+{
+ XVisualInfo xvinfo_template;
+ XVisualInfo *xvinfo_list;
+ int nitems_return;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ xvinfo_template.visualid = xvisualid;
+ xvinfo_template.screen = screen_num;
+
+ xvinfo_list = XGetVisualInfo (xdisplay,
+ VisualIDMask | VisualScreenMask,
+ &xvinfo_template,
+ &nitems_return);
+
+ /* Returned XVisualInfo needs to be unique */
+ g_assert (xvinfo_list != NULL && nitems_return == 1);
+
+ return xvinfo_list;
+}
+
+static GdkGLConfig *
+gdk_x11_gl_config_impl_new_from_visualid_common (GdkGLConfig *glconfig,
+ GdkScreen *screen,
+ VisualID xvisualid)
+{
+ GdkGLConfigImplX11 *x11_impl;
+
+ Display *xdisplay;
+ int screen_num;
+ XVisualInfo *xvinfo;
+ int is_rgba;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ xdisplay = GDK_SCREEN_XDISPLAY (screen);
+ screen_num = GDK_SCREEN_XNUMBER (screen);
+
+ GDK_GL_NOTE (MISC,
+ g_message (" -- GLX_VENDOR : %s",
+ glXGetClientString (xdisplay, GLX_VENDOR)));
+ GDK_GL_NOTE (MISC,
+ g_message (" -- GLX_VERSION : %s",
+ glXGetClientString (xdisplay, GLX_VERSION)));
+ GDK_GL_NOTE (MISC,
+ g_message (" -- GLX_EXTENSIONS : %s",
+ glXGetClientString (xdisplay, GLX_EXTENSIONS)));
+
+ /*
+ * Get XVisualInfo.
+ */
+
+ xvinfo = gdk_x11_gl_get_xvinfo (xdisplay, screen_num, xvisualid);
+ if (xvinfo == NULL)
+ return NULL;
+
+ GDK_GL_NOTE (MISC,
+ g_message (" -- gdk_x11_gl_get_xvinfo: screen number = %d", xvinfo->screen));
+ GDK_GL_NOTE (MISC,
+ g_message (" -- gdk_x11_gl_get_xvinfo: visual id = 0x%lx", xvinfo->visualid));
+
+ /*
+ * Instantiate the GdkGLConfigImplX11 object.
+ */
+
+ x11_impl = g_object_new (GDK_TYPE_GL_CONFIG_IMPL_X11, NULL);
+
+ g_return_val_if_fail(x11_impl != NULL, NULL);
+
+ x11_impl->xdisplay = xdisplay;
+ x11_impl->screen_num = screen_num;
+ x11_impl->xvinfo = xvinfo;
+ x11_impl->screen = screen;
+
+ /* RGBA mode? */
+ glXGetConfig (xdisplay, xvinfo, GLX_RGBA, &is_rgba);
+
+ /*
+ * Init GdkGLConfig
+ */
+
+ glconfig->impl = GDK_GL_CONFIG_IMPL (x11_impl);
+
+ /*
+ * Init configuration attributes.
+ */
+
+ gdk_x11_gl_config_impl_init_attrib (glconfig);
+
+ return glconfig;
+}
+
+GdkGLConfig *
+_gdk_x11_gl_config_impl_new_from_visualid_for_screen (GdkGLConfig *glconfig,
+ GdkScreen *screen,
+ VisualID xvisualid)
+{
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG(glconfig), NULL);
+ g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+ return gdk_x11_gl_config_impl_new_from_visualid_common (glconfig, screen, xvisualid);
+}
+
+static Display *
+_gdk_x11_gl_config_impl_get_xdisplay (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ return GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->xdisplay;
+}
+
+static int
+_gdk_x11_gl_config_impl_get_screen_number (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), 0);
+
+ return GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->screen_num;
+}
+
+static XVisualInfo *
+_gdk_x11_gl_config_impl_get_xvinfo (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ return GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->xvinfo;
+}
+
+static GdkGLWindow *
+_gdk_x11_gl_config_impl_create_gl_window (GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list)
+{
+ GdkGLWindow *glwindow;
+ GdkGLWindow *impl;
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ glwindow = g_object_new (GDK_TYPE_X11_GL_WINDOW, NULL);
+
+ g_return_val_if_fail(glwindow != NULL, NULL);
+
+ impl = _gdk_x11_gl_window_impl_new(glwindow,
+ glconfig,
+ window,
+ attrib_list);
+ if (impl == NULL)
+ g_object_unref(glwindow);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glwindow;
+}
+
+static GdkScreen *
+_gdk_x11_gl_config_impl_get_screen (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ return GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->screen;
+}
+
+static gboolean
+_gdk_x11_gl_config_impl_get_attrib (GdkGLConfig *glconfig,
+ int attribute,
+ int *value)
+{
+ GdkGLConfigImplX11 *x11_impl;
+ int ret;
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), FALSE);
+
+ x11_impl = GDK_GL_CONFIG_IMPL_X11 (glconfig->impl);
+
+ ret = glXGetConfig (x11_impl->xdisplay, x11_impl->xvinfo, attribute, value);
+
+ return (ret == Success);
+}
+
+static GdkVisual *
+_gdk_x11_gl_config_impl_get_visual (GdkGLConfig *glconfig)
+{
+ GdkGLConfigImplX11 *x11_impl;
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ x11_impl = GDK_GL_CONFIG_IMPL_X11 (glconfig->impl);
+
+ return gdk_x11_screen_lookup_visual(x11_impl->screen, x11_impl->xvinfo->visualid);
+}
+
+static gint
+_gdk_x11_gl_config_impl_get_depth (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), 0);
+
+ return GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->xvinfo->depth;
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.h
new file mode 100644
index 00000000..daf6b7cc
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglconfig-x11.h
@@ -0,0 +1,74 @@
+/* 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_CONFIG_X11_H__
+#define __GDK_GL_CONFIG_X11_H__
+
+#include <gdk/gdkx.h>
+
+#include <gdk/gdkglconfig.h>
+#include <gdk/gdkglconfigimpl.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GdkGLConfigImplX11 GdkGLConfigImplX11;
+typedef struct _GdkGLConfigImplX11Class GdkGLConfigImplX11Class;
+
+#define GDK_TYPE_GL_CONFIG_IMPL_X11 (gdk_gl_config_impl_x11_get_type ())
+#define GDK_GL_CONFIG_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONFIG_IMPL_X11, GdkGLConfigImplX11))
+#define GDK_GL_CONFIG_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONFIG_IMPL_X11, GdkGLConfigImplX11Class))
+#define GDK_IS_GL_CONFIG_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONFIG_IMPL_X11))
+#define GDK_IS_GL_CONFIG_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONFIG_IMPL_X11))
+#define GDK_GL_CONFIG_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONFIG_IMPL_X11, GdkGLConfigImplX11Class))
+
+struct _GdkGLConfigImplX11
+{
+ GdkGLConfigImpl parent_instance;
+
+ Display *xdisplay;
+ int screen_num;
+ XVisualInfo *xvinfo;
+
+ GdkScreen *screen;
+};
+
+struct _GdkGLConfigImplX11Class
+{
+ GdkGLConfigImplClass parent_class;
+
+ Display* (*get_xdisplay) (GdkGLConfig *glconfig);
+ int (*get_screen_number) (GdkGLConfig *glconfig);
+ XVisualInfo* (*get_xvinfo) (GdkGLConfig *glconfig);
+};
+
+GType gdk_gl_config_impl_x11_get_type (void);
+
+GdkGLConfig *_gdk_x11_gl_config_impl_new (GdkGLConfig *glconfig,
+ const int *attrib_list,
+ gsize n_attribs);
+GdkGLConfig *_gdk_x11_gl_config_impl_new_for_screen (GdkGLConfig *glconfig,
+ GdkScreen *screen,
+ const int *attrib_list,
+ gsize n_attribs);
+GdkGLConfig *_gdk_x11_gl_config_impl_new_from_visualid_for_screen (GdkGLConfig *glconfig,
+ GdkScreen *screen,
+ VisualID xvisualid);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_CONFIG_X11_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.c
new file mode 100644
index 00000000..5fc0be54
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.c
@@ -0,0 +1,591 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gdk/gdk.h> /* for gdk_error_trap_(push|pop) () */
+
+#include "gdkglx.h"
+#include "gdkglprivate-x11.h"
+#include "gdkglconfig-x11.h"
+#include "gdkglwindow-x11.h"
+#include "gdkglcontext-x11.h"
+
+static void gdk_gl_context_insert (GdkGLContext *glcontext);
+static void gdk_gl_context_remove (GdkGLContext *glcontext);
+static GdkGLContext *gdk_gl_context_lookup (GLXContext glxcontext);
+
+static gboolean _gdk_x11_gl_context_impl_copy (GdkGLContext *glcontext,
+ GdkGLContext *src,
+ unsigned long mask);
+static GdkGLDrawable* _gdk_x11_gl_context_impl_get_gl_drawable (GdkGLContext *glcontext);
+static GdkGLConfig* _gdk_x11_gl_context_impl_get_gl_config (GdkGLContext *glcontext);
+static GdkGLContext* _gdk_x11_gl_context_impl_get_share_list (GdkGLContext *glcontext);
+static gboolean _gdk_x11_gl_context_impl_is_direct (GdkGLContext *glcontext);
+static int _gdk_x11_gl_context_impl_get_render_type (GdkGLContext *glcontext);
+static gboolean _gdk_x11_gl_context_impl_make_current (GdkGLContext *glcontext,
+ GdkGLDrawable *draw,
+ GdkGLDrawable *read);
+static GLXContext _gdk_x11_gl_context_impl_get_glxcontext (GdkGLContext *glcontext);
+
+G_DEFINE_TYPE (GdkGLContextImplX11, \
+ gdk_gl_context_impl_x11, \
+ GDK_TYPE_GL_CONTEXT_IMPL)
+
+static void
+gdk_gl_context_impl_x11_init (GdkGLContextImplX11 *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ self->glxcontext = NULL;
+ self->share_list = NULL;
+ self->is_direct = FALSE;
+ self->render_type = 0;
+ self->glconfig = NULL;
+ self->gldrawable = NULL;
+ self->gldrawable_read = NULL;
+ self->is_destroyed = 0;
+ self->is_foreign = 0;
+}
+
+void
+_gdk_gl_context_destroy (GdkGLContext *glcontext)
+{
+ GdkGLContextImplX11 *impl = GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl);
+ Display *xdisplay;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (impl->is_destroyed)
+ return;
+
+ gdk_gl_context_remove (glcontext);
+
+ xdisplay = GDK_GL_CONFIG_XDISPLAY (impl->glconfig);
+
+ if (impl->glxcontext == glXGetCurrentContext ())
+ {
+ glXWaitGL ();
+
+ GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");
+ glXMakeCurrent (xdisplay, None, NULL);
+ }
+
+ if (!impl->is_foreign)
+ {
+ GDK_GL_NOTE_FUNC_IMPL ("glXDestroyContext");
+ glXDestroyContext (xdisplay, impl->glxcontext);
+ impl->glxcontext = NULL;
+ }
+
+ if (impl->gldrawable != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (impl->gldrawable),
+ (gpointer *) &(impl->gldrawable));
+ impl->gldrawable = NULL;
+ }
+
+ /* currently unused. */
+ /*
+ if (impl->gldrawable_read != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (impl->gldrawable_read),
+ (gpointer *) &(impl->gldrawable_read));
+ impl->gldrawable_read = NULL;
+ }
+ */
+
+ impl->is_destroyed = TRUE;
+}
+
+static void
+gdk_gl_context_impl_x11_finalize (GObject *object)
+{
+ GdkGLContextImplX11 *impl = GDK_GL_CONTEXT_IMPL_X11 (object);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ _gdk_gl_context_destroy (GDK_GL_CONTEXT (object));
+
+ g_object_unref (G_OBJECT (impl->glconfig));
+
+ if (impl->share_list != NULL)
+ g_object_unref (G_OBJECT (impl->share_list));
+
+ G_OBJECT_CLASS (gdk_gl_context_impl_x11_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_context_impl_x11_class_init (GdkGLContextImplX11Class *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ klass->get_glxcontext = _gdk_x11_gl_context_impl_get_glxcontext;
+
+ klass->parent_class.copy_gl_context_impl = _gdk_x11_gl_context_impl_copy;
+ klass->parent_class.get_gl_drawable = _gdk_x11_gl_context_impl_get_gl_drawable;
+ klass->parent_class.get_gl_config = _gdk_x11_gl_context_impl_get_gl_config;
+ klass->parent_class.get_share_list = _gdk_x11_gl_context_impl_get_share_list;
+ klass->parent_class.is_direct = _gdk_x11_gl_context_impl_is_direct;
+ klass->parent_class.get_render_type = _gdk_x11_gl_context_impl_get_render_type;
+ klass->parent_class.make_current = _gdk_x11_gl_context_impl_make_current;
+ klass->parent_class.make_uncurrent = NULL;
+
+ object_class->finalize = gdk_gl_context_impl_x11_finalize;
+}
+
+static GdkGLContextImpl *
+gdk_x11_gl_context_impl_new_common (GdkGLContext *glcontext,
+ GdkGLConfig *glconfig,
+ GdkGLContext *share_list,
+ int render_type,
+ GLXContext glxcontext,
+ gboolean is_foreign)
+{
+ GdkGLContextImpl *impl;
+ GdkGLContextImplX11 *x11_impl;
+
+ Display *xdisplay;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ /*
+ * Instantiate the GdkGLContextImplX11 object.
+ */
+
+ impl = g_object_new (GDK_TYPE_GL_CONTEXT_IMPL_X11, NULL);
+ x11_impl = GDK_GL_CONTEXT_IMPL_X11 (impl);
+
+ x11_impl->glxcontext = glxcontext;
+
+ if (share_list != NULL && GDK_IS_GL_CONTEXT (share_list))
+ {
+ x11_impl->share_list = share_list;
+ g_object_ref (G_OBJECT (x11_impl->share_list));
+ }
+ else
+ {
+ x11_impl->share_list = NULL;
+ }
+
+ xdisplay = GDK_GL_CONFIG_XDISPLAY (glconfig);
+ x11_impl->is_direct = glXIsDirect (xdisplay, glxcontext) ? TRUE : FALSE;
+
+ x11_impl->render_type = render_type;
+
+ x11_impl->glconfig = glconfig;
+ g_object_ref (G_OBJECT (x11_impl->glconfig));
+
+ x11_impl->gldrawable = NULL;
+ x11_impl->gldrawable_read = NULL;
+
+ x11_impl->is_foreign = is_foreign;
+
+ x11_impl->is_destroyed = FALSE;
+
+ glcontext->impl = impl;
+
+ /*
+ * Insert into the GL context hash table.
+ */
+
+ gdk_gl_context_insert (glcontext);
+
+ return impl;
+}
+
+/*< private >*/
+GdkGLContextImpl *
+_gdk_x11_gl_context_impl_new (GdkGLContext *glcontext,
+ GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type)
+{
+ GdkGLConfig *glconfig;
+ GdkGLContextImplX11 *share_impl = NULL;
+ GLXContext share_glxcontext = NULL;
+
+ Display *xdisplay;
+ XVisualInfo *xvinfo;
+ GLXContext glxcontext;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ /*
+ * Create an OpenGL rendering context.
+ */
+
+ glconfig = gdk_gl_drawable_get_gl_config (gldrawable);
+
+ xdisplay = GDK_GL_CONFIG_XDISPLAY (glconfig);
+ xvinfo = GDK_GL_CONFIG_XVINFO (glconfig);
+
+ if (share_list != NULL && GDK_IS_GL_CONTEXT (share_list))
+ {
+ share_impl = GDK_GL_CONTEXT_IMPL_X11 (share_list->impl);
+ share_glxcontext = share_impl->glxcontext;
+ }
+
+ GDK_GL_NOTE_FUNC_IMPL ("glXCreateContext");
+
+ if (_gdk_gl_context_force_indirect)
+ {
+ GDK_GL_NOTE (MISC, g_message (" -- Force indirect"));
+
+ glxcontext = glXCreateContext (xdisplay,
+ xvinfo,
+ share_glxcontext,
+ False);
+ }
+ else
+ {
+ glxcontext = glXCreateContext (xdisplay,
+ xvinfo,
+ share_glxcontext,
+ (direct == TRUE) ? True : False);
+ }
+ if (glxcontext == NULL)
+ return NULL;
+
+ GDK_GL_NOTE (MISC,
+ g_message (" -- Context: screen number = %d", xvinfo->screen));
+ GDK_GL_NOTE (MISC,
+ g_message (" -- Context: visual id = 0x%lx", xvinfo->visualid));
+
+ /*
+ * Instantiate the GdkGLContextImplX11 object.
+ */
+
+ return gdk_x11_gl_context_impl_new_common (glcontext,
+ glconfig,
+ share_list,
+ render_type,
+ glxcontext,
+ FALSE);
+}
+
+GdkGLContextImpl *
+_gdk_x11_gl_context_impl_new_from_glxcontext (GdkGLContext *glcontext,
+ GdkGLConfig *glconfig,
+ GdkGLContext *share_list,
+ GLXContext glxcontext)
+{
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+ g_return_val_if_fail (glxcontext != NULL, NULL);
+
+ /*
+ * Instantiate the GdkGLContextImplX11 object.
+ */
+
+ return gdk_x11_gl_context_impl_new_common (glcontext,
+ glconfig,
+ share_list,
+ GDK_GL_RGBA_TYPE,
+ glxcontext,
+ TRUE);
+}
+
+static gboolean
+_gdk_x11_gl_context_impl_copy (GdkGLContext *glcontext,
+ GdkGLContext *src,
+ unsigned long mask)
+{
+ GLXContext dst_glxcontext, src_glxcontext;
+ GdkGLConfig *glconfig;
+
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), FALSE);
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (src), FALSE);
+
+ dst_glxcontext = GDK_GL_CONTEXT_GLXCONTEXT (glcontext);
+ if (dst_glxcontext == NULL)
+ return FALSE;
+
+ src_glxcontext = GDK_GL_CONTEXT_GLXCONTEXT (src);
+ if (src_glxcontext == NULL)
+ return FALSE;
+
+ glconfig = GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->glconfig;
+
+ gdk_error_trap_push ();
+
+ glXCopyContext (GDK_GL_CONFIG_XDISPLAY (glconfig),
+ src_glxcontext, dst_glxcontext,
+ mask);
+
+ return gdk_error_trap_pop () == Success;
+}
+
+/*< private >*/
+void
+_gdk_x11_gl_context_impl_set_gl_drawable (GdkGLContext *glcontext,
+ GdkGLDrawable *gldrawable)
+{
+ GdkGLContextImplX11 *impl = GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (impl->gldrawable == gldrawable)
+ return;
+
+ if (impl->gldrawable != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (impl->gldrawable),
+ (gpointer *) &(impl->gldrawable));
+ impl->gldrawable = NULL;
+ }
+
+ if (gldrawable != NULL && GDK_IS_GL_DRAWABLE (gldrawable))
+ {
+ impl->gldrawable = gldrawable;
+ g_object_add_weak_pointer (G_OBJECT (impl->gldrawable),
+ (gpointer *) &(impl->gldrawable));
+ }
+}
+
+/*< private >*/
+/* currently unused. */
+/*
+void
+_gdk_gl_context_set_gl_drawable_read (GdkGLContext *glcontext,
+ GdkGLDrawable *gldrawable_read)
+{
+ GdkGLContextImplX11 *impl = GDK_GL_CONTEXT_IMPL_X11 (glcontext);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (impl->gldrawable_read == gldrawable_read)
+ return;
+
+ if (impl->gldrawable_read != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (impl->gldrawable_read),
+ (gpointer *) &(impl->gldrawable_read));
+ impl->gldrawable_read = NULL;
+ }
+
+ if (gldrawable_read != NULL && GDK_IS_GL_DRAWABLE (gldrawable_read))
+ {
+ impl->gldrawable_read = gldrawable_read;
+ g_object_add_weak_pointer (G_OBJECT (impl->gldrawable_read),
+ (gpointer *) &(impl->gldrawable_read));
+ }
+}
+*/
+
+static GdkGLDrawable *
+_gdk_x11_gl_context_impl_get_gl_drawable (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), NULL);
+
+ return GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->gldrawable;
+}
+
+static GdkGLConfig *
+_gdk_x11_gl_context_impl_get_gl_config (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), NULL);
+
+ return GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->glconfig;
+}
+
+static GdkGLContext *
+_gdk_x11_gl_context_impl_get_share_list (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), NULL);
+
+ return GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->share_list;
+}
+
+static gboolean
+_gdk_x11_gl_context_impl_is_direct (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), FALSE);
+
+ return GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->is_direct;
+}
+
+static int
+_gdk_x11_gl_context_impl_get_render_type (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), 0);
+
+ return GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->render_type;
+}
+
+static gboolean
+_gdk_x11_gl_context_impl_make_current (GdkGLContext *glcontext,
+ GdkGLDrawable *draw,
+ GdkGLDrawable *read)
+{
+ GdkGLWindow *glwindow;
+ GdkGLWindowImplX11 *x11_impl;
+ GdkGLConfig *glconfig;
+ GdkWindow *window;
+ Window glxwindow;
+ GLXContext glxcontext;
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), FALSE);
+ g_return_val_if_fail (GDK_IS_X11_GL_WINDOW (draw), FALSE);
+
+ glwindow = GDK_GL_WINDOW(draw);
+ x11_impl = GDK_GL_WINDOW_IMPL_X11 (glwindow->impl);
+ glconfig = x11_impl->glconfig;
+ window = gdk_gl_window_get_window(glwindow);
+ glxwindow = x11_impl->glxwindow;
+ glxcontext = GDK_GL_CONTEXT_GLXCONTEXT (glcontext);
+
+ if (glxwindow == None || glxcontext == NULL)
+ return FALSE;
+
+ GDK_GL_NOTE (MISC,
+ g_message (" -- Window: screen number = %d",
+ GDK_SCREEN_XNUMBER (gdk_window_get_screen (window))));
+ GDK_GL_NOTE (MISC,
+ g_message (" -- Window: visual id = 0x%lx",
+ GDK_VISUAL_XVISUAL (gdk_window_get_visual (window))->visualid));
+
+ GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");
+
+ if (!glXMakeCurrent (GDK_GL_CONFIG_XDISPLAY (glconfig), glxwindow, glxcontext))
+ {
+ g_warning ("glXMakeCurrent() failed");
+ _gdk_x11_gl_context_impl_set_gl_drawable (glcontext, NULL);
+ /* currently unused. */
+ /* _gdk_gl_context_set_gl_drawable_read (glcontext, NULL); */
+ return FALSE;
+ }
+
+ _gdk_x11_gl_context_impl_set_gl_drawable (glcontext, draw);
+ /* currently unused. */
+ /* _gdk_gl_context_set_gl_drawable_read (glcontext, read); */
+
+ if (_GDK_GL_CONFIG_AS_SINGLE_MODE (glconfig))
+ {
+ /* We do this because we are treating a double-buffered frame
+ buffer as a single-buffered frame buffer because the system
+ does not appear to export any suitable single-buffered
+ visuals (in which the following are necessary). */
+ glDrawBuffer (GL_FRONT);
+ glReadBuffer (GL_FRONT);
+ }
+
+ GDK_GL_NOTE (MISC, _gdk_gl_print_gl_info ());
+
+ return TRUE;
+}
+
+GdkGLContext *
+_gdk_x11_gl_context_impl_get_current (void)
+{
+ static GdkGLContext *current = NULL;
+ GLXContext glxcontext;
+
+ GDK_GL_NOTE_FUNC ();
+
+ glxcontext = glXGetCurrentContext ();
+
+ if (glxcontext == NULL)
+ return NULL;
+
+ if (current && GDK_GL_CONTEXT_GLXCONTEXT (current) == glxcontext)
+ return current;
+
+ current = gdk_gl_context_lookup (glxcontext);
+
+ return current;
+}
+
+GLXContext
+_gdk_x11_gl_context_impl_get_glxcontext (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), NULL);
+
+ return GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->glxcontext;
+}
+
+/*
+ * GdkGLContext hash table.
+ */
+
+static GHashTable *gl_context_ht = NULL;
+
+static void
+gdk_gl_context_insert (GdkGLContext *glcontext)
+{
+ GdkGLContextImplX11 *impl;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (gl_context_ht == NULL)
+ {
+ GDK_GL_NOTE (MISC, g_message (" -- Create GL context hash table."));
+
+ /* We do not know the storage type of GLXContext from the GLX
+ specification. We assume that it is a pointer as NULL values
+ are specified for this type---this is consistent with the SGI
+ and Mesa GLX implementations. */
+ gl_context_ht = g_hash_table_new (g_direct_hash,
+ g_direct_equal);
+ }
+
+ impl = GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl);
+
+ g_hash_table_insert (gl_context_ht, impl->glxcontext, glcontext);
+}
+
+static void
+gdk_gl_context_remove (GdkGLContext *glcontext)
+{
+ GdkGLContextImplX11 *impl;
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (gl_context_ht == NULL)
+ return;
+
+ impl = GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl);
+
+ g_hash_table_remove (gl_context_ht, impl->glxcontext);
+
+ if (g_hash_table_size (gl_context_ht) == 0)
+ {
+ GDK_GL_NOTE (MISC, g_message (" -- Destroy GL context hash table."));
+ g_hash_table_destroy (gl_context_ht);
+ gl_context_ht = NULL;
+ }
+}
+
+static GdkGLContext *
+gdk_gl_context_lookup (GLXContext glxcontext)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ if (gl_context_ht == NULL)
+ return NULL;
+
+ return g_hash_table_lookup (gl_context_ht, glxcontext);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.h
new file mode 100644
index 00000000..bb21cd93
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglcontext-x11.h
@@ -0,0 +1,85 @@
+/* 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_CONTEXT_X11_H__
+#define __GDK_GL_CONTEXT_X11_H__
+
+#include <GL/glx.h>
+
+#include <gdk/gdkglcontext.h>
+#include <gdk/gdkglcontextimpl.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GdkGLContextImplX11 GdkGLContextImplX11;
+typedef struct _GdkGLContextImplX11Class GdkGLContextImplX11Class;
+
+#define GDK_TYPE_GL_CONTEXT_IMPL_X11 (gdk_gl_context_impl_x11_get_type ())
+#define GDK_GL_CONTEXT_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONTEXT_IMPL_X11, GdkGLContextImplX11))
+#define GDK_GL_CONTEXT_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT_IMPL_X11, GdkGLContextImplX11Class))
+#define GDK_IS_GL_CONTEXT_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONTEXT_IMPL_X11))
+#define GDK_IS_GL_CONTEXT_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT_IMPL_X11))
+#define GDK_GL_CONTEXT_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT_IMPL_X11, GdkGLContextImplX11Class))
+
+struct _GdkGLContextImplX11
+{
+ GdkGLContextImpl parent_instance;
+
+ GLXContext glxcontext;
+ GdkGLContext *share_list;
+ gboolean is_direct;
+ int render_type;
+
+ GdkGLConfig *glconfig;
+
+ GdkGLDrawable *gldrawable;
+ GdkGLDrawable *gldrawable_read; /* currently unused. */
+
+ guint is_destroyed : 1;
+ guint is_foreign : 1;
+};
+
+struct _GdkGLContextImplX11Class
+{
+ GdkGLContextImplClass parent_class;
+
+ GLXContext (*get_glxcontext) (GdkGLContext *glcontext);
+};
+
+GType gdk_gl_context_impl_x11_get_type (void);
+
+GdkGLContextImpl *_gdk_x11_gl_context_impl_new (GdkGLContext *glcontext,
+ GdkGLDrawable *gldrawable,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type);
+
+GdkGLContextImpl *_gdk_x11_gl_context_impl_new_from_glxcontext (GdkGLContext *glcontext,
+ GdkGLConfig *glconfig,
+ GdkGLContext *share_list,
+ GLXContext glxcontext);
+
+void _gdk_x11_gl_context_impl_set_gl_drawable (GdkGLContext *glcontext,
+ GdkGLDrawable *gldrawable);
+
+GdkGLContext *
+_gdk_x11_gl_context_impl_get_current (void);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_CONTEXT_X11_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglprivate-x11.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglprivate-x11.h
new file mode 100644
index 00000000..3beed7a3
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglprivate-x11.h
@@ -0,0 +1,39 @@
+/* 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_PRIVATE_X11_H__
+#define __GDK_GL_PRIVATE_X11_H__
+
+#include <gdk/gdkprivate.h>
+
+#include <gdk/gdkglprivate.h>
+
+G_BEGIN_DECLS
+
+void _gdk_x11_gl_print_glx_info (Display *xdisplay,
+ int screen_num);
+
+#define GDK_GL_CONTEXT_IS_DESTROYED(glcontext) \
+ ( ((GdkGLContextImplX11 *) (glcontext->impl))->is_destroyed )
+
+#define GDK_GL_WINDOW_IS_DESTROYED(glwindow) \
+ ( ((GdkGLWindowImplX11 *) (glwindow->impl))->is_destroyed )
+
+G_END_DECLS
+
+#endif /* __GDK_GL_PRIVATE_X11_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.c
new file mode 100644
index 00000000..d2ac7ae3
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.c
@@ -0,0 +1,417 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#else /* __APPLE__ */
+#include <gmodule.h>
+#endif /* __APPLE__ */
+
+#include <gdk/gdk.h>
+
+#include "gdkglx.h"
+#include "gdkglprivate-x11.h"
+#include "gdkglconfig-x11.h"
+#include "gdkglquery.h"
+
+#include "gdkglquery-x11.h"
+
+gboolean
+_gdk_x11_gl_query_extension_for_display (GdkDisplay *display)
+{
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+ return glXQueryExtension (GDK_DISPLAY_XDISPLAY (display),
+ NULL, NULL);
+}
+
+gboolean
+_gdk_x11_gl_query_version_for_display (GdkDisplay *display,
+ int *major,
+ int *minor)
+{
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+ return glXQueryVersion (GDK_DISPLAY_XDISPLAY (display),
+ major, minor);
+}
+
+/*
+ * This code is based on __glutIsSupportedByGLX().
+ */
+
+/**
+ * gdk_x11_gl_query_glx_extension:
+ * @glconfig: a #GdkGLConfig.
+ * @extension: name of GLX extension.
+ *
+ * Determines whether a given GLX extension is supported.
+ *
+ * Return value: TRUE if the GLX extension is supported, FALSE if not
+ * supported.
+ **/
+gboolean
+gdk_x11_gl_query_glx_extension (GdkGLConfig *glconfig,
+ const char *extension)
+{
+ static const char *extensions = NULL;
+ const char *start;
+ char *where, *terminator;
+ int major, minor;
+
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), FALSE);
+
+ /* Extension names should not have spaces. */
+ where = strchr (extension, ' ');
+ if (where || *extension == '\0')
+ return FALSE;
+
+ if (extensions == NULL)
+ {
+ /* Be careful not to call glXQueryExtensionsString if it
+ looks like the server doesn't support GLX 1.1.
+ Unfortunately, the original GLX 1.0 didn't have the notion
+ of GLX extensions. */
+
+ glXQueryVersion (GDK_GL_CONFIG_XDISPLAY (glconfig),
+ &major, &minor);
+
+ if ((major == 1 && minor < 1) || (major < 1))
+ return FALSE;
+
+ extensions = glXQueryExtensionsString (GDK_GL_CONFIG_XDISPLAY (glconfig),
+ GDK_GL_CONFIG_SCREEN_XNUMBER (glconfig));
+ }
+
+ /* It takes a bit of care to be fool-proof about parsing
+ the GLX extensions string. Don't be fooled by
+ sub-strings, etc. */
+ start = extensions;
+ for (;;)
+ {
+ where = strstr (start, extension);
+ if (where == NULL)
+ break;
+
+ terminator = where + strlen (extension);
+
+ if (where == start || *(where - 1) == ' ')
+ if (*terminator == ' ' || *terminator == '\0')
+ {
+ GDK_GL_NOTE (MISC, g_message (" - %s - supported", extension));
+ return TRUE;
+ }
+
+ start = terminator;
+ }
+
+ GDK_GL_NOTE (MISC, g_message (" - %s - not supported", extension));
+
+ return FALSE;
+}
+
+GdkGLProc
+_gdk_x11_gl_get_proc_address (const char *proc_name)
+{
+#ifdef __APPLE__
+
+ #define _GDK_GL_LIBGL_PATH "/usr/X11R6/lib/libGL.1.dylib"
+ #define _GDK_GL_LIBGLU_PATH "/usr/X11R6/lib/libGLU.1.dylib"
+
+ typedef GdkGLProc (*__glXGetProcAddressProc) (const GLubyte *);
+ static __glXGetProcAddressProc glx_get_proc_address = (__glXGetProcAddressProc) -1;
+ const char *image_name;
+ static const struct mach_header *libgl_image = NULL;
+ static const struct mach_header *libglu_image = NULL;
+ NSSymbol symbol;
+ char *symbol_name;
+ GdkGLProc proc_address;
+
+ GDK_GL_NOTE_FUNC ();
+
+ if (strncmp ("glu", proc_name, 3) != 0)
+ {
+ /* libGL */
+
+ if (libgl_image == NULL)
+ {
+ image_name = g_getenv ("GDK_GL_LIBGL_PATH");
+ if (image_name == NULL)
+ image_name = _GDK_GL_LIBGL_PATH;
+
+ GDK_GL_NOTE (MISC, g_message (" - Add Mach-O image %s", image_name));
+
+ libgl_image = NSAddImage (image_name, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
+ if (libgl_image == NULL)
+ {
+ g_warning ("Cannot add Mach-O image %s", image_name);
+ return NULL;
+ }
+ }
+
+ if (glx_get_proc_address == (__glXGetProcAddressProc) -1)
+ {
+ /*
+ * Look up glXGetProcAddress () function.
+ */
+
+ symbol = NSLookupSymbolInImage (libgl_image,
+ "_glXGetProcAddress",
+ NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
+ NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ if (symbol == NULL)
+ {
+ symbol = NSLookupSymbolInImage (libgl_image,
+ "_glXGetProcAddressARB",
+ NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
+ NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ if (symbol == NULL)
+ {
+ symbol = NSLookupSymbolInImage (libgl_image,
+ "_glXGetProcAddressEXT",
+ NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
+ NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ }
+ }
+ GDK_GL_NOTE (MISC, g_message (" - glXGetProcAddress () - %s",
+ symbol ? "supported" : "not supported"));
+ if (symbol != NULL)
+ glx_get_proc_address = NSAddressOfSymbol (symbol);
+ else
+ glx_get_proc_address = NULL;
+ }
+
+ /* Try glXGetProcAddress () */
+
+ if (glx_get_proc_address != NULL)
+ {
+ proc_address = glx_get_proc_address ((unsigned char *) proc_name);
+ GDK_GL_NOTE (IMPL, g_message (" ** glXGetProcAddress () - %s",
+ proc_address ? "succeeded" : "failed"));
+ if (proc_address != NULL)
+ return proc_address;
+ }
+
+ /* Try Mach-O dyld */
+
+ symbol_name = g_strconcat ("_", proc_name, NULL);
+
+ symbol = NSLookupSymbolInImage (libgl_image,
+ symbol_name,
+ NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
+ NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ GDK_GL_NOTE (MISC, g_message (" - NSLookupSymbolInImage () - %s",
+ symbol ? "succeeded" : "failed"));
+
+ g_free (symbol_name);
+
+ if (symbol != NULL)
+ return NSAddressOfSymbol (symbol);
+ }
+ else
+ {
+ /* libGLU */
+
+ if (libglu_image == NULL)
+ {
+ image_name = g_getenv ("GDK_GL_LIBGLU_PATH");
+ if (image_name == NULL)
+ image_name = _GDK_GL_LIBGLU_PATH;
+
+ GDK_GL_NOTE (MISC, g_message (" - Add Mach-O image %s", image_name));
+
+ libglu_image = NSAddImage (image_name, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
+ if (libglu_image == NULL)
+ {
+ g_warning ("Cannot add Mach-O image %s", image_name);
+ return NULL;
+ }
+ }
+
+ symbol_name = g_strconcat ("_", proc_name, NULL);
+
+ symbol = NSLookupSymbolInImage (libglu_image,
+ symbol_name,
+ NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
+ NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ GDK_GL_NOTE (MISC, g_message (" - NSLookupSymbolInImage () - %s",
+ symbol ? "succeeded" : "failed"));
+
+ g_free (symbol_name);
+
+ if (symbol != NULL)
+ return NSAddressOfSymbol (symbol);
+ }
+
+ return NULL;
+
+#else /* __APPLE__ */
+
+ typedef GdkGLProc (*__glXGetProcAddressProc) (const GLubyte *);
+ static __glXGetProcAddressProc glx_get_proc_address = (__glXGetProcAddressProc) -1;
+ gchar *file_name;
+ GModule *module;
+ GdkGLProc proc_address = NULL;
+
+ GDK_GL_NOTE_FUNC ();
+
+ if (strncmp ("glu", proc_name, 3) != 0)
+ {
+ if (glx_get_proc_address == (__glXGetProcAddressProc) -1)
+ {
+ /*
+ * Look up glXGetProcAddress () function.
+ */
+
+ file_name = g_module_build_path (NULL, "GL");
+ GDK_GL_NOTE (MISC, g_message (" - Open %s", file_name));
+ module = g_module_open (file_name, G_MODULE_BIND_LAZY);
+ g_free (file_name);
+
+ if (module != NULL)
+ {
+ g_module_symbol (module, "glXGetProcAddress",
+ (gpointer) &glx_get_proc_address);
+ if (glx_get_proc_address == NULL)
+ {
+ g_module_symbol (module, "glXGetProcAddressARB",
+ (gpointer) &glx_get_proc_address);
+ if (glx_get_proc_address == NULL)
+ {
+ g_module_symbol (module, "glXGetProcAddressEXT",
+ (gpointer) &glx_get_proc_address);
+ }
+ }
+ GDK_GL_NOTE (MISC, g_message (" - glXGetProcAddress () - %s",
+ glx_get_proc_address ? "supported" : "not supported"));
+ g_module_close (module);
+ }
+ else
+ {
+ g_warning ("Cannot open %s", file_name);
+ glx_get_proc_address = NULL;
+ return NULL;
+ }
+ }
+
+ /* Try glXGetProcAddress () */
+
+ if (glx_get_proc_address != NULL)
+ {
+ proc_address = glx_get_proc_address ((unsigned char *) proc_name);
+ GDK_GL_NOTE (IMPL, g_message (" ** glXGetProcAddress () - %s",
+ proc_address ? "succeeded" : "failed"));
+ if (proc_address != NULL)
+ return proc_address;
+ }
+
+ /* Try g_module_symbol () */
+
+ /* libGL */
+ file_name = g_module_build_path (NULL, "GL");
+ GDK_GL_NOTE (MISC, g_message (" - Open %s", file_name));
+ module = g_module_open (file_name, G_MODULE_BIND_LAZY);
+ g_free (file_name);
+
+ if (module != NULL)
+ {
+ g_module_symbol (module, proc_name, (gpointer) &proc_address);
+ GDK_GL_NOTE (MISC, g_message (" - g_module_symbol () - %s",
+ proc_address ? "succeeded" : "failed"));
+ g_module_close (module);
+ }
+ else
+ {
+ g_warning ("Cannot open %s", file_name);
+ }
+
+ if (proc_address == NULL)
+ {
+ /* libGLcore */
+ file_name = g_module_build_path (NULL, "GLcore");
+ GDK_GL_NOTE (MISC, g_message (" - Open %s", file_name));
+ module = g_module_open (file_name, G_MODULE_BIND_LAZY);
+ g_free (file_name);
+
+ if (module != NULL)
+ {
+ g_module_symbol (module, proc_name, (gpointer) &proc_address);
+ GDK_GL_NOTE (MISC, g_message (" - g_module_symbol () - %s",
+ proc_address ? "succeeded" : "failed"));
+ g_module_close (module);
+ }
+ }
+ }
+ else
+ {
+ /* libGLU */
+ file_name = g_module_build_path (NULL, "GLU");
+ GDK_GL_NOTE (MISC, g_message (" - Open %s", file_name));
+ module = g_module_open (file_name, G_MODULE_BIND_LAZY);
+ g_free (file_name);
+
+ if (module != NULL)
+ {
+ g_module_symbol (module, proc_name, (gpointer) &proc_address);
+ GDK_GL_NOTE (MISC, g_message (" - g_module_symbol () - %s",
+ proc_address ? "succeeded" : "failed"));
+ g_module_close (module);
+ }
+ else
+ {
+ g_warning ("Cannot open %s", file_name);
+ }
+ }
+
+ return proc_address;
+
+#endif /* __APPLE__ */
+}
+
+/*< private >*/
+void
+_gdk_x11_gl_print_glx_info (Display *xdisplay,
+ int screen_num)
+{
+ static gboolean done = FALSE;
+
+ if (!done)
+ {
+ g_message (" -- Server GLX_VENDOR : %s",
+ glXQueryServerString (xdisplay, screen_num, GLX_VENDOR));
+ g_message (" -- Server GLX_VERSION : %s",
+ glXQueryServerString (xdisplay, screen_num, GLX_VERSION));
+ g_message (" -- Server GLX_EXTENSIONS : %s",
+ glXQueryServerString (xdisplay, screen_num, GLX_EXTENSIONS));
+
+ g_message (" -- Client GLX_VENDOR : %s",
+ glXGetClientString (xdisplay, GLX_VENDOR));
+ g_message (" -- Client GLX_VERSION : %s",
+ glXGetClientString (xdisplay, GLX_VERSION));
+ g_message (" -- Client GLX_EXTENSIONS : %s",
+ glXGetClientString (xdisplay, GLX_EXTENSIONS));
+
+ done = TRUE;
+ }
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.h
new file mode 100644
index 00000000..23154099
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglquery-x11.h
@@ -0,0 +1,39 @@
+/* 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_QUERY_X11_H__
+#define __GDK_GL_QUERY_X11_H__
+
+#include "gdkglquery.h"
+
+G_BEGIN_DECLS
+
+gboolean
+_gdk_x11_gl_query_extension_for_display (GdkDisplay *display);
+
+gboolean
+_gdk_x11_gl_query_version_for_display (GdkDisplay *display,
+ int *major,
+ int *minor);
+
+GdkGLProc
+_gdk_x11_gl_get_proc_address (const char *proc_name);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_QUERY_X11_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.c
new file mode 100644
index 00000000..91e00383
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.c
@@ -0,0 +1,262 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+
+#include "gdkglx.h"
+#include "gdkglprivate-x11.h"
+#include "gdkglconfig-x11.h"
+#include "gdkglcontext-x11.h"
+#include "gdkglwindow-x11.h"
+
+#include <gdk/gdkglquery.h>
+
+static GdkGLContext *_gdk_x11_gl_window_impl_create_gl_context (GdkGLWindow *glwindow,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type);
+static gboolean _gdk_x11_gl_window_impl_is_double_buffered (GdkGLWindow *glwindow);
+static void _gdk_x11_gl_window_impl_swap_buffers (GdkGLWindow *glwindow);
+static void _gdk_x11_gl_window_impl_wait_gl (GdkGLWindow *glwindow);
+static void _gdk_x11_gl_window_impl_wait_gdk (GdkGLWindow *glwindow);
+static GdkGLConfig *_gdk_x11_gl_window_impl_get_gl_config (GdkGLWindow *glwindow);
+static Window _gdk_x11_gl_window_impl_get_glxwindow (GdkGLWindow *glwindow);
+
+G_DEFINE_TYPE (GdkGLWindowImplX11,
+ gdk_gl_window_impl_x11,
+ GDK_TYPE_GL_WINDOW_IMPL);
+
+static void
+gdk_gl_window_impl_x11_init (GdkGLWindowImplX11 *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ self->glxwindow = None;
+ self->glconfig = NULL;
+ self->is_destroyed = 0;
+}
+
+static void
+_gdk_x11_gl_window_impl_destroy (GdkGLWindow *glwindow)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ GdkGLWindowImplX11 *x11_impl = GDK_GL_WINDOW_IMPL_X11 (glwindow->impl);
+ Display *xdisplay;
+ Bool (APIENTRY *ReleaseBuffersMESA) (Display*, GLXDrawable);
+
+ if (x11_impl->is_destroyed)
+ return;
+
+ xdisplay = GDK_GL_CONFIG_XDISPLAY (x11_impl->glconfig);
+
+ if (x11_impl->glxwindow == glXGetCurrentDrawable ())
+ {
+ glXWaitGL ();
+
+ GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");
+ glXMakeCurrent (xdisplay, None, NULL);
+ }
+
+ if (gdk_x11_gl_query_glx_extension (x11_impl->glconfig, "GLX_MESA_release_buffers"))
+ {
+ /* Release buffers if GLX_MESA_release_buffers is supported. */
+
+ ReleaseBuffersMESA = (Bool (APIENTRY *)(Display*, GLXDrawable))
+ gdk_gl_get_proc_address("glXReleaseBuffersMESA");
+
+ GDK_GL_NOTE_FUNC_IMPL ("glXReleaseBuffersMESA");
+ if (ReleaseBuffersMESA)
+ ReleaseBuffersMESA (xdisplay, x11_impl->glxwindow);
+ }
+
+ x11_impl->glxwindow = None;
+
+ x11_impl->is_destroyed = TRUE;
+}
+
+static void
+gdk_gl_window_impl_x11_finalize (GObject *object)
+{
+ GdkGLWindowImplX11 *impl = GDK_GL_WINDOW_IMPL_X11 (object);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ _gdk_x11_gl_window_impl_destroy (GDK_GL_WINDOW (object));
+
+ g_object_unref (G_OBJECT (impl->glconfig));
+
+ G_OBJECT_CLASS (gdk_gl_window_impl_x11_parent_class)->finalize (object);
+}
+
+static void
+gdk_gl_window_impl_x11_class_init (GdkGLWindowImplX11Class *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ klass->get_glxwindow = _gdk_x11_gl_window_impl_get_glxwindow;
+
+ klass->parent_class.create_gl_context = _gdk_x11_gl_window_impl_create_gl_context;
+ klass->parent_class.is_double_buffered = _gdk_x11_gl_window_impl_is_double_buffered;
+ klass->parent_class.swap_buffers = _gdk_x11_gl_window_impl_swap_buffers;
+ klass->parent_class.wait_gl = _gdk_x11_gl_window_impl_wait_gl;
+ klass->parent_class.wait_gdk = _gdk_x11_gl_window_impl_wait_gdk;
+ klass->parent_class.get_gl_config = _gdk_x11_gl_window_impl_get_gl_config;
+ klass->parent_class.destroy_gl_window_impl = _gdk_x11_gl_window_impl_destroy;
+
+ object_class->finalize = gdk_gl_window_impl_x11_finalize;
+}
+
+/*
+ * attrib_list is currently unused. This must be set to NULL or empty
+ * (first attribute of None). See GLX 1.3 spec.
+ */
+GdkGLWindow *
+_gdk_x11_gl_window_impl_new (GdkGLWindow *glwindow,
+ GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list)
+{
+ GdkGLWindowImplX11 *x11_impl;
+
+ /* GLXWindow glxwindow; */
+ Window glxwindow;
+
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_X11_GL_WINDOW (glwindow), NULL);
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+ /*
+ * Get X Window.
+ */
+
+ glxwindow = GDK_WINDOW_XID (window);
+
+ /*
+ * Instantiate the GdkGLWindowImplX11 object.
+ */
+
+ x11_impl = g_object_new (GDK_TYPE_GL_WINDOW_IMPL_X11, NULL);
+ GDK_GL_NOTE_FUNC ();
+
+ x11_impl->glxwindow = glxwindow;
+ x11_impl->glconfig = glconfig;
+ g_object_ref (G_OBJECT (x11_impl->glconfig));
+
+ x11_impl->is_destroyed = FALSE;
+
+ glwindow->impl = GDK_GL_WINDOW_IMPL(x11_impl);
+ glwindow->window = window;
+ g_object_add_weak_pointer (G_OBJECT (glwindow->window),
+ (gpointer *) &(glwindow->window));
+
+ return glwindow;
+}
+
+static GdkGLContext *
+_gdk_x11_gl_window_impl_create_gl_context (GdkGLWindow *glwindow,
+ GdkGLContext *share_list,
+ gboolean direct,
+ int render_type)
+{
+ GdkGLContext *glcontext;
+ GdkGLContextImpl *impl;
+
+ glcontext = g_object_new(GDK_TYPE_X11_GL_CONTEXT, NULL);
+
+ g_return_val_if_fail(glcontext != NULL, NULL);
+
+ impl = _gdk_x11_gl_context_impl_new(glcontext,
+ GDK_GL_DRAWABLE(glwindow),
+ share_list,
+ direct,
+ render_type);
+ if (impl == NULL)
+ g_object_unref(glcontext);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glcontext;
+}
+
+static gboolean
+_gdk_x11_gl_window_impl_is_double_buffered (GdkGLWindow *glwindow)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_WINDOW (glwindow), FALSE);
+
+ return gdk_gl_config_is_double_buffered (GDK_GL_WINDOW_IMPL_X11 (glwindow->impl)->glconfig);
+}
+
+static void
+_gdk_x11_gl_window_impl_swap_buffers (GdkGLWindow *glwindow)
+{
+ Display *xdisplay;
+ Window glxwindow;
+
+ g_return_if_fail (GDK_IS_X11_GL_WINDOW (glwindow));
+
+ xdisplay = GDK_GL_CONFIG_XDISPLAY (GDK_GL_WINDOW_IMPL_X11 (glwindow->impl)->glconfig);
+ glxwindow = GDK_GL_WINDOW_IMPL_X11 (glwindow->impl)->glxwindow;
+
+ if (glxwindow == None)
+ return;
+
+ GDK_GL_NOTE_FUNC_IMPL ("glXSwapBuffers");
+
+ glXSwapBuffers (xdisplay, glxwindow);
+}
+
+static void
+_gdk_x11_gl_window_impl_wait_gl (GdkGLWindow *glwindow)
+{
+ g_return_if_fail (GDK_IS_X11_GL_WINDOW (glwindow));
+
+ glXWaitGL ();
+}
+
+static void
+_gdk_x11_gl_window_impl_wait_gdk (GdkGLWindow *glwindow)
+{
+ g_return_if_fail (GDK_IS_X11_GL_WINDOW (glwindow));
+
+ glXWaitX ();
+}
+
+static GdkGLConfig *
+_gdk_x11_gl_window_impl_get_gl_config (GdkGLWindow *glwindow)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_WINDOW (glwindow), NULL);
+
+ return GDK_GL_WINDOW_IMPL_X11 (glwindow->impl)->glconfig;
+}
+
+static Window
+_gdk_x11_gl_window_impl_get_glxwindow (GdkGLWindow *glwindow)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_WINDOW (glwindow), None);
+
+ return GDK_GL_WINDOW_IMPL_X11 (glwindow->impl)->glxwindow;
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.h
new file mode 100644
index 00000000..8c16517d
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglwindow-x11.h
@@ -0,0 +1,68 @@
+/* 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_WINDOW_X11_H__
+#define __GDK_GL_WINDOW_X11_H__
+
+#include <gdk/gdkx.h>
+
+#include <gdk/gdkglwindow.h>
+#include <gdk/gdkglwindowimpl.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GdkGLWindowImplX11 GdkGLWindowImplX11;
+typedef struct _GdkGLWindowImplX11Class GdkGLWindowImplX11Class;
+
+#define GDK_TYPE_GL_WINDOW_IMPL_X11 (gdk_gl_window_impl_x11_get_type ())
+#define GDK_GL_WINDOW_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_WINDOW_IMPL_X11, GdkGLWindowImplX11))
+#define GDK_GL_WINDOW_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_WINDOW_IMPL_X11, GdkGLWindowImplX11Class))
+#define GDK_IS_GL_WINDOW_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_WINDOW_IMPL_X11))
+#define GDK_IS_GL_WINDOW_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_WINDOW_IMPL_X11))
+#define GDK_GL_WINDOW_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_WINDOW_IMPL_X11, GdkGLWindowImplX11Class))
+
+struct _GdkGLWindowImplX11
+{
+ GdkGLWindowImpl parent_instance;
+
+ /* GLXWindow glxwindow; */
+ Window glxwindow;
+
+ GdkGLConfig *glconfig;
+
+ guint is_destroyed : 1;
+};
+
+struct _GdkGLWindowImplX11Class
+{
+ GdkGLWindowImplClass parent_class;
+
+ Window (*get_glxwindow) (GdkGLWindow *glwindow);
+};
+
+GType gdk_gl_window_impl_x11_get_type (void);
+
+GdkGLWindow *
+_gdk_x11_gl_window_impl_new (GdkGLWindow *glwindow,
+ GdkGLConfig *glconfig,
+ GdkWindow *window,
+ const int *attrib_list);
+
+G_END_DECLS
+
+#endif /* __GDK_GL_WINDOW_X11_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglx.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglx.h
new file mode 100644
index 00000000..2655e67f
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkglx.h
@@ -0,0 +1,39 @@
+/* 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_X_H__
+#define __GDK_GL_X_H__
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <gdk/gdkx.h>
+
+#include <GL/gl.h>
+#include <GL/glx.h>
+
+#define __GDKGLX_H_INSIDE__
+
+#include <gdk/x11/gdkx11glconfig.h>
+#include <gdk/x11/gdkx11glcontext.h>
+#include <gdk/x11/gdkx11glquery.h>
+#include <gdk/x11/gdkx11glwindow.h>
+
+#undef __GDKGLX_H_INSIDE__
+
+#endif /* __GDK_GL_X_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.c
new file mode 100644
index 00000000..426d28f7
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.c
@@ -0,0 +1,245 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <gdk/gdkgldebug.h>
+#include <gdk/x11/gdkglx.h>
+
+#include "gdkglconfig-x11.h"
+
+struct _GdkX11GLConfig
+{
+ GdkGLConfig parent;
+};
+
+struct _GdkX11GLConfigClass
+{
+ GdkGLConfigClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkX11GLConfig, gdk_x11_gl_config, GDK_TYPE_GL_CONFIG);
+
+static void
+gdk_x11_gl_config_init (GdkX11GLConfig *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_x11_gl_config_finalize (GObject *object)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ G_OBJECT_CLASS (gdk_x11_gl_config_parent_class)->finalize (object);
+}
+
+static void
+gdk_x11_gl_config_class_init (GdkX11GLConfigClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ object_class->finalize = gdk_x11_gl_config_finalize;
+}
+
+/**
+ * gdk_x11_gl_config_new_for_display:
+ * @display: display.
+ * @attrib_list: (array length=n_attribs): 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, gsize n_attribs)
+{
+ GdkGLConfig *glconfig;
+ GdkGLConfig *impl;
+
+ g_return_val_if_fail(GDK_IS_X11_DISPLAY(display), NULL);
+
+ glconfig = g_object_new(GDK_TYPE_X11_GL_CONFIG, NULL);
+
+ g_return_val_if_fail(glconfig != NULL, NULL);
+
+ impl = _gdk_x11_gl_config_impl_new(glconfig, attrib_list, n_attribs);
+
+ if (impl == NULL)
+ g_object_unref(glconfig);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glconfig;
+}
+
+/**
+ * gdk_x11_gl_config_new_for_screen:
+ * @screen: target screen.
+ * @attrib_list: (array length=n_attribs): 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, gsize n_attribs)
+{
+ GdkGLConfig *glconfig;
+ GdkGLConfig *impl;
+
+ g_return_val_if_fail(GDK_IS_X11_SCREEN(screen), NULL);
+
+ glconfig = g_object_new(GDK_TYPE_X11_GL_CONFIG, NULL);
+
+ g_return_val_if_fail(glconfig != NULL, NULL);
+
+ impl = _gdk_x11_gl_config_impl_new(glconfig, attrib_list, n_attribs);
+
+ if (impl == NULL)
+ g_object_unref(glconfig);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glconfig;
+}
+
+/**
+ * gdk_x11_gl_config_new_from_visualid:
+ * @xvisualid: visual ID.
+ *
+ * Creates #GdkGLConfig from given visual ID that specifies the OpenGL-capable
+ * visual.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_x11_gl_config_new_from_visualid (VisualID xvisualid)
+{
+ GdkScreen *screen;
+ GdkGLConfig *glconfig;
+ GdkGLConfig *impl;
+
+ GDK_GL_NOTE_FUNC ();
+
+ screen = gdk_screen_get_default ();
+
+ glconfig = g_object_new(GDK_TYPE_X11_GL_CONFIG, NULL);
+
+ g_return_val_if_fail(glconfig != NULL, NULL);
+
+ impl = _gdk_x11_gl_config_impl_new_from_visualid_for_screen (glconfig,
+ screen,
+ xvisualid);
+ if (impl == NULL)
+ g_object_unref(glconfig);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glconfig;
+}
+
+/**
+ * gdk_x11_gl_config_new_from_visualid_for_screen:
+ * @screen: target screen.
+ * @xvisualid: visual ID.
+ *
+ * Creates #GdkGLConfig from given visual ID that specifies the OpenGL-capable
+ * visual.
+ *
+ * Return value: the new #GdkGLConfig.
+ **/
+GdkGLConfig *
+gdk_x11_gl_config_new_from_visualid_for_screen (GdkScreen *screen,
+ VisualID xvisualid)
+{
+ GdkGLConfig *glconfig;
+ GdkGLConfig *impl;
+
+ GDK_GL_NOTE_FUNC ();
+
+ g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+ glconfig = g_object_new(GDK_TYPE_X11_GL_CONFIG, NULL);
+
+ g_return_val_if_fail(glconfig != NULL, NULL);
+
+ impl = _gdk_x11_gl_config_impl_new_from_visualid_for_screen (glconfig,
+ screen,
+ xvisualid);
+ if (impl == NULL)
+ g_object_unref(glconfig);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glconfig;
+}
+
+/**
+ * gdk_x11_gl_config_get_xdisplay:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets X Display.
+ *
+ * Return value: pointer to the Display.
+ **/
+Display *
+gdk_x11_gl_config_get_xdisplay (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ return GDK_GL_CONFIG_IMPL_X11_CLASS (glconfig)->get_xdisplay(glconfig);
+}
+
+/**
+ * gdk_x11_gl_config_get_screen_number:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets X screen number.
+ *
+ * Return value: the screen number.
+ **/
+int
+gdk_x11_gl_config_get_screen_number (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), 0);
+
+ return GDK_GL_CONFIG_IMPL_X11_CLASS (glconfig)->get_screen_number(glconfig);
+}
+
+/**
+ * gdk_x11_gl_config_get_xvinfo:
+ * @glconfig: a #GdkGLConfig.
+ *
+ * Gets XVisualInfo data.
+ *
+ * Return value: pointer to the XVisualInfo data.
+ **/
+XVisualInfo *
+gdk_x11_gl_config_get_xvinfo (GdkGLConfig *glconfig)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONFIG (glconfig), NULL);
+
+ return GDK_GL_CONFIG_IMPL_X11_CLASS (glconfig)->get_xvinfo(glconfig);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.h
new file mode 100644
index 00000000..abebd9f2
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glconfig.h
@@ -0,0 +1,82 @@
+/* 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.
+ */
+
+#if !defined (__GDKGLX_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkglx.h> can be included directly."
+#endif
+
+#ifndef __GDK_X11_GL_CONFIG_H__
+#define __GDK_X11_GL_CONFIG_H__
+
+#include <gdk/gdkx.h>
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_X11_GL_CONFIG (gdk_x11_gl_config_get_type ())
+#define GDK_X11_GL_CONFIG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_GL_CONFIG, GdkX11GLConfig))
+#define GDK_X11_GL_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_GL_CONFIG, GdkX11GLConfigClass))
+#define GDK_IS_X11_GL_CONFIG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_GL_CONFIG))
+#define GDK_IS_X11_GL_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_GL_CONFIG))
+#define GDK_X11_GL_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_GL_CONFIG, GdkX11GLConfigClass))
+
+#ifdef INSIDE_GDK_GL_X11
+typedef struct _GdkX11GLConfig GdkX11GLConfig;
+#else
+typedef GdkGLConfig GdkX11GLConfig;
+#endif
+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,
+ gsize n_attribs);
+
+GdkGLConfig *gdk_x11_gl_config_new_for_screen (GdkScreen *screen,
+ const int *attrib_list,
+ gsize n_attribs);
+
+#ifndef GDK_MULTIHEAD_SAFE
+GdkGLConfig *gdk_x11_gl_config_new_from_visualid (VisualID xvisualid);
+#endif /* GDK_MULTIHEAD_SAFE */
+
+GdkGLConfig *gdk_x11_gl_config_new_from_visualid_for_screen (GdkScreen *screen,
+ VisualID xvisualid);
+
+Display *gdk_x11_gl_config_get_xdisplay (GdkGLConfig *glconfig);
+int gdk_x11_gl_config_get_screen_number (GdkGLConfig *glconfig);
+XVisualInfo *gdk_x11_gl_config_get_xvinfo (GdkGLConfig *glconfig);
+
+#ifdef INSIDE_GDK_GL_X11
+
+#define GDK_GL_CONFIG_XDISPLAY(glconfig) (GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->xdisplay)
+#define GDK_GL_CONFIG_SCREEN_XNUMBER(glconfig) (GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->screen_num)
+#define GDK_GL_CONFIG_XVINFO(glconfig) (GDK_GL_CONFIG_IMPL_X11 (glconfig->impl)->xvinfo)
+
+#else
+
+#define GDK_GL_CONFIG_XDISPLAY(glconfig) (gdk_x11_gl_config_get_xdisplay (glconfig))
+#define GDK_GL_CONFIG_SCREEN_XNUMBER(glconfig) (gdk_x11_gl_config_get_screen_number (glconfig))
+#define GDK_GL_CONFIG_XVINFO(glconfig) (gdk_x11_gl_config_get_xvinfo (glconfig))
+
+#endif
+
+G_END_DECLS
+
+#endif /* __GDK_X11_GL_CONFIG_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.c
new file mode 100644
index 00000000..5cca77d1
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.c
@@ -0,0 +1,115 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <gdk/gdkgldebug.h>
+#include <gdk/x11/gdkglx.h>
+
+#include "gdkglcontext-x11.h"
+
+struct _GdkX11GLContext
+{
+ GdkGLContext parent;
+};
+
+struct _GdkX11GLContextClass
+{
+ GdkGLContextClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkX11GLContext, gdk_x11_gl_context, GDK_TYPE_GL_CONTEXT);
+
+static void
+gdk_x11_gl_context_init (GdkX11GLContext *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_x11_gl_context_finalize (GObject *object)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ G_OBJECT_CLASS (gdk_x11_gl_context_parent_class)->finalize (object);
+}
+
+static void
+gdk_x11_gl_context_class_init (GdkX11GLContextClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ object_class->finalize = gdk_x11_gl_context_finalize;
+}
+
+/**
+ * gdk_x11_gl_context_foreign_new:
+ * @glconfig: #GdkGLConfig that represents the visual the GLXContext uses.
+ * @share_list: the #GdkGLContext which shares display lists with the
+ * GLXContext, or NULL.
+ * @glxcontext: exsisting GLXContext.
+ *
+ * Creates #GdkGLContext from existing GLXContext.
+ *
+ * Return value: the newly-created #GdkGLContext wrapper.
+ **/
+GdkGLContext *
+gdk_x11_gl_context_foreign_new (GdkGLConfig *glconfig,
+ GdkGLContext *share_list,
+ GLXContext glxcontext)
+{
+ GdkGLContext *glcontext;
+ GdkGLContextImpl *impl;
+
+ GDK_GL_NOTE_FUNC ();
+
+ glcontext = g_object_new(GDK_TYPE_GL_CONTEXT_IMPL_X11, NULL);
+
+ g_return_val_if_fail(glcontext != NULL, NULL);
+
+ impl = _gdk_x11_gl_context_impl_new_from_glxcontext(glcontext,
+ glconfig,
+ share_list,
+ glxcontext);
+ if (impl == NULL)
+ g_object_unref(glcontext);
+
+ g_return_val_if_fail(impl != NULL, NULL);
+
+ return glcontext;
+}
+
+/**
+ * gdk_x11_gl_context_get_glxcontext:
+ * @glcontext: a #GdkGLContext.
+ *
+ * Gets GLXContext.
+ *
+ * Return value: the GLXContext.
+ **/
+GLXContext
+gdk_x11_gl_context_get_glxcontext (GdkGLContext *glcontext)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_CONTEXT (glcontext), NULL);
+
+ return GDK_GL_CONTEXT_IMPL_X11_CLASS (glcontext)->get_glxcontext(glcontext);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.h
new file mode 100644
index 00000000..88c857c7
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glcontext.h
@@ -0,0 +1,65 @@
+/* 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.
+ */
+
+#if !defined (__GDKGLX_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkglx.h> can be included directly."
+#endif
+
+#ifndef __GDK_X11_GL_CONTEXT_H__
+#define __GDK_X11_GL_CONTEXT_H__
+
+#include <gdk/gdkx.h>
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_X11_GL_CONTEXT (gdk_x11_gl_context_get_type ())
+#define GDK_X11_GL_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_GL_CONTEXT, GdkX11GLContext))
+#define GDK_X11_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_GL_CONTEXT, GdkX11GLContextClass))
+#define GDK_IS_X11_GL_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_GL_CONTEXT))
+#define GDK_IS_X11_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_GL_CONTEXT))
+#define GDK_X11_GL_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_GL_CONTEXT, GdkX11GLContextClass))
+
+#ifdef INSIDE_GDK_GL_X11
+typedef struct _GdkX11GLContext GdkX11GLContext;
+#else
+typedef GdkGLContext GdkX11GLContext;
+#endif
+typedef struct _GdkX11GLContextClass GdkX11GLContextClass;
+
+GType gdk_x11_gl_context_get_type (void);
+
+GdkGLContext *gdk_x11_gl_context_foreign_new (GdkGLConfig *glconfig,
+ GdkGLContext *share_list,
+ GLXContext glxcontext);
+
+GLXContext gdk_x11_gl_context_get_glxcontext (GdkGLContext *glcontext);
+
+#ifdef INSIDE_GDK_GL_X11
+
+#define GDK_GL_CONTEXT_GLXCONTEXT(glcontext) (GDK_GL_CONTEXT_IMPL_X11 (glcontext->impl)->glxcontext)
+
+#else
+
+#define GDK_GL_CONTEXT_GLXCONTEXT(glcontext) (gdk_x11_gl_context_get_glxcontext (glcontext))
+
+#endif
+
+G_END_DECLS
+
+#endif /* __GDK_GL_GL_CONFIG_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glquery.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glquery.h
new file mode 100644
index 00000000..130f0a68
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glquery.h
@@ -0,0 +1,34 @@
+/* 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.
+ */
+
+#if !defined (__GDKGLX_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkglx.h> can be included directly."
+#endif
+
+#ifndef __GDK_X11_GL_QUERY_H__
+#define __GDK_X11_GL_QUERY_H__
+
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+gboolean gdk_x11_gl_query_glx_extension (GdkGLConfig *glconfig,
+ const char *extension);
+G_END_DECLS
+
+#endif /* __GDK_X11_GL_QUERY_H__ */
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.c b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.c
new file mode 100644
index 00000000..f4cc8ff0
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.c
@@ -0,0 +1,80 @@
+/* GdkGLExt - OpenGL Extension to GDK
+ * Copyright (C) 2012 Thomas Zimmermann
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <gdk/gdkgldebug.h>
+#include <gdk/x11/gdkglx.h>
+
+#include "gdkglwindow-x11.h"
+
+struct _GdkX11GLWindow
+{
+ GdkGLWindow parent;
+};
+
+struct _GdkX11GLWindowClass
+{
+ GdkGLWindowClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkX11GLWindow,
+ gdk_x11_gl_window,
+ GDK_TYPE_GL_WINDOW)
+
+static void
+gdk_x11_gl_window_init (GdkX11GLWindow *self)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+}
+
+static void
+gdk_x11_gl_window_finalize (GObject *object)
+{
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ G_OBJECT_CLASS (gdk_x11_gl_window_parent_class)->finalize (object);
+}
+
+static void
+gdk_x11_gl_window_class_init (GdkX11GLWindowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GDK_GL_NOTE_FUNC_PRIVATE ();
+
+ object_class->finalize = gdk_x11_gl_window_finalize;
+}
+
+/**
+ * gdk_x11_gl_window_get_glxwindow:
+ * @glwindow: a #GdkGLWindow.
+ *
+ * Gets X Window.
+ *
+ * Return value: the Window.
+ **/
+Window
+gdk_x11_gl_window_get_glxwindow (GdkGLWindow *glwindow)
+{
+ g_return_val_if_fail (GDK_IS_X11_GL_WINDOW (glwindow), None);
+
+ return GDK_GL_WINDOW_IMPL_X11_CLASS (glwindow->impl)->get_glxwindow(glwindow);
+}
diff --git a/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.h b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.h
new file mode 100644
index 00000000..458a0f76
--- /dev/null
+++ b/plugins/gtkui/gtkglext-gtk3/gdk/x11/gdkx11glwindow.h
@@ -0,0 +1,62 @@
+/* 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.
+ */
+
+#if !defined (__GDKGLX_H_INSIDE__) && !defined (GDK_GL_COMPILATION)
+#error "Only <gdk/gdkglx.h> can be included directly."
+#endif
+
+#ifndef __GDK_X11_GL_WINDOW_H__
+#define __GDK_X11_GL_WINDOW_H__
+
+#include <gdk/gdkx.h>
+
+#include <gdk/gdkgl.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_X11_GL_WINDOW (gdk_x11_gl_window_get_type ())
+#define GDK_X11_GL_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_GL_WINDOW, GdkX11GLWindow))
+#define GDK_X11_GL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_GL_WINDOW, GdkX11GLWindowClass))
+#define GDK_IS_X11_GL_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_GL_WINDOW))
+#define GDK_IS_X11_GL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_GL_WINDOW))
+#define GDK_X11_GL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_GL_WINDOW, GdkX11GLWindowClass))
+
+#ifdef INSIDE_GDK_GL_X11
+typedef struct _GdkX11GLWindow GdkX11GLWindow;
+#else
+typedef GdkGLWindow GdkX11GLWindow;
+#endif
+typedef struct _GdkX11GLWindowClass GdkX11GLWindowClass;
+
+GType gdk_x11_gl_window_get_type (void);
+
+Window gdk_x11_gl_window_get_glxwindow (GdkGLWindow *glwindow);
+
+#ifdef INSIDE_GDK_GL_X11
+
+#define GDK_GL_WINDOW_GLXWINDOW(glwindow) (GDK_GL_WINDOW_IMPL_X11 (glwindow->impl)->glxwindow)
+
+#else
+
+#define GDK_GL_WINDOW_GLXWINDOW(glwindow) (gdk_x11_gl_window_get_glxwindow (glwindow))
+
+#endif
+
+G_END_DECLS
+
+#endif /* __GDK_X11_GL_WINDOW_H__ */