--- gtkgl/gtkglarea.h	2009-07-17 21:29:39 +0000
+++ gtkgl/gtkglarea.h	2013-09-08 10:20:08 +0000
@@ -1,4 +1,4 @@
-/*
+﻿/*
  * Copyright (C) 1997-1998 Janne Löf <jlof@mail.student.oulu.fi>
  *
  * This library is free software; you can redistribute it and/or
@@ -22,7 +22,12 @@
 
 #include <gdk/gdk.h>
 #include <gtkgl/gdkgl.h>
+
+#if defined __GTK2__
 #include <gtk/gtkdrawingarea.h>
+#elif defined __GTK3__
+#include <gtk/gtk.h>
+#endif
 
 
 G_BEGIN_DECLS
--- gtkgl/gtkglarea.c	2009-07-17 21:29:39 +0000
+++ gtkgl/gtkglarea.c	2013-09-08 10:27:38 +0000
@@ -1,4 +1,4 @@
-/*
+﻿/*
  * Copyright (C) 1997-1998 Janne Löf <jlof@mail.student.oulu.fi>
  *
  * This library is free software; you can redistribute it and/or
@@ -23,9 +23,14 @@
 #include "gdkgl.h"
 #include "gtkglarea.h"
 
+
 static void gtk_gl_area_class_init    (GtkGLAreaClass *klass);
 static void gtk_gl_area_init          (GtkGLArea      *glarea);
-static void gtk_gl_area_destroy       (GtkObject      *object); /* change to finalize? */
+#if defined __GTK2__
+static void gtk_gl_area_destroy       (GtkObject      *object);
+#elif defined __GTK3__
+static void gtk_gl_area_destroy       (GtkWidget      *object);
+#endif
 
 static GtkDrawingAreaClass *parent_class = NULL;
 
@@ -60,10 +65,18 @@
 static void
 gtk_gl_area_class_init (GtkGLAreaClass *klass)
 {
-  GtkObjectClass *object_class;
+#if defined __GTK2__
+GtkObjectClass *object_class;
+#elif defined __GTK3__
+GtkWidgetClass *object_class;
+#endif
 
   parent_class = g_type_class_peek_parent(klass);
+#if defined __GTK2__
   object_class = (GtkObjectClass*) klass;
+#elif defined __GTK3__
+  object_class = (GtkWidgetClass*) klass;
+#endif
 
   object_class->destroy = gtk_gl_area_destroy;
 }
@@ -156,7 +169,11 @@
 
 
 static void
+#if defined __GTK2__
 gtk_gl_area_destroy(GtkObject *object)
+#elif defined __GTK3__
+gtk_gl_area_destroy(GtkWidget *object)
+#endif
 {
   GtkGLArea *gl_area;
 
@@ -169,8 +186,12 @@
     g_object_unref(gl_area->glcontext);
   gl_area->glcontext = NULL;
 
+#if defined __GTK2__
   if (GTK_OBJECT_CLASS (parent_class)->destroy)
     (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+#elif defined __GTK3__
+// WOT ?
+#endif
 }
 
 
@@ -178,16 +199,34 @@
 {
   g_return_val_if_fail(gl_area != NULL, FALSE);
   g_return_val_if_fail(GTK_IS_GL_AREA (gl_area), FALSE);
+#if defined __GTK2__
   g_return_val_if_fail(GTK_WIDGET_REALIZED(gl_area), FALSE);
+#elif defined __GTK3__
+  g_return_val_if_fail(gtk_widget_get_realized(gl_area), FALSE);
+#endif
 
+#if defined __GTK2__
   return gdk_gl_make_current(GTK_WIDGET(gl_area)->window, gl_area->glcontext);
+#elif defined __GTK3__
+  GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(gl_area));
+  return gdk_gl_make_current(window, gl_area->glcontext);
+#endif
 }
 
 void gtk_gl_area_swap_buffers(GtkGLArea *gl_area)
 {
   g_return_if_fail(gl_area != NULL);
   g_return_if_fail(GTK_IS_GL_AREA(gl_area));
+#if defined __GTK2__
   g_return_if_fail(GTK_WIDGET_REALIZED(gl_area));
+#elif defined __GTK3__
+  g_return_if_fail(gtk_widget_get_realized(gl_area));
+#endif
 
+#if defined __GTK2__
   gdk_gl_swap_buffers(GTK_WIDGET(gl_area)->window);
+#elif defined __GTK3__
+  GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(gl_area));
+  gdk_gl_swap_buffers(window);
+#endif
 }
--- gtkgl/gdkgl.h	2009-07-17 21:29:39 +0000
+++ gtkgl/gdkgl.h	2013-09-08 10:30:12 +0000
@@ -1,4 +1,4 @@
-/*
+﻿/*
  * Copyright (C) 1998 Janne Löf <jlof@mail.student.oulu.fi>
  *
  * This library is free software; you can redistribute it and/or
@@ -90,9 +90,13 @@
 GdkGLContext *gdk_gl_context_share_new(GdkVisual *visual, GdkGLContext *sharelist, gint direct);
 GdkGLContext *gdk_gl_context_attrlist_share_new(int *attrlist, GdkGLContext *sharelist, gint direct);
 
+#if defined __GTK2__
 gint          gdk_gl_make_current(GdkDrawable *drawable, GdkGLContext *context);
 void          gdk_gl_swap_buffers(GdkDrawable *drawable);
-
+#elif defined __GTK3__
+gint          gdk_gl_make_current(GdkWindow *window, GdkGLContext *context);
+void          gdk_gl_swap_buffers(GdkWindow *window);
+#endif
 
 void          gdk_gl_wait_gdk(void);
 void          gdk_gl_wait_gl(void);
@@ -110,13 +114,21 @@
 typedef struct _GdkGLPixmap GdkGLPixmap;
 
 GType        gdk_gl_pixmap_get_type(void);
+#if defined __GTK2__
 GdkGLPixmap *gdk_gl_pixmap_new(GdkVisual *visual, GdkPixmap *pixmap);
+#elif defined __GTK3__
+GdkGLPixmap *gdk_gl_pixmap_new(GdkVisual *visual, GdkPixbuf *pixbuf);
+#endif
 
 gint         gdk_gl_pixmap_make_current(GdkGLPixmap *glpixmap, GdkGLContext *context);
 
 
 /* fonts */
+#if defined __GTK2__
 void gdk_gl_use_gdk_font(GdkFont *font, int first, int count, int list_base);
+#elif defined __GTK3__
+void gdk_gl_use_gdk_font(PangoFont *font, int first, int count, int list_base);
+#endif
 
 
 #ifndef GTKGL_DISABLE_DEPRECATED
--- gtkgl/gdkgl.c	2009-07-17 23:07:58 +0000
+++ gtkgl/gdkgl.c	2013-09-08 10:39:28 +0000
@@ -1,4 +1,4 @@
-/*
+﻿/*
  * Copyright (C) 1998 Janne Löf <jlof@mail.student.oulu.fi>
  *           (c) 2008, 2009 Sam Hocevar <sam@hocevar.net>
  *
@@ -17,6 +17,9 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+//
+#include <stdio.h>
+
 #include "config.h"
 
 #include <string.h>
@@ -74,11 +77,19 @@
   gboolean  initialised;
   HDC       hdc;
   HBITMAP   hbitmap;
+#if defined __GTK2__
   GdkPixmap *pixmap;
+#elif defined __GTK3__
+  GdkPixbuf *pixbuf;
+#endif
 #elif defined GDK_WINDOWING_X11
   Display   *xdisplay;
   GLXPixmap glxpixmap;
+#if defined __GTK2__
   GdkPixmap *front_left;
+#elif defined __GTK3__
+  GdkPixbuf *front_left;
+#endif
 #endif
 };
 
@@ -374,17 +385,28 @@
 #endif
 }
 
-
+#if defined __GTK2__
 gint gdk_gl_make_current(GdkDrawable *drawable, GdkGLContext *context)
+#elif defined __GTK3__
+gint gdk_gl_make_current(GdkWindow *window, GdkGLContext *context)
+#endif
 {
+#if defined __GTK2__
   g_return_val_if_fail (GDK_IS_DRAWABLE(drawable), FALSE);
+#elif defined __GTK3__
+  g_return_val_if_fail (GDK_IS_WINDOW(window), FALSE);
+#endif
   g_return_val_if_fail (GDK_IS_GL_CONTEXT(context), FALSE);
 
 #if defined GDK_WINDOWING_WIN32
   if (!context->initialised)
   {
     int pf;
+#if defined __GTK2__
     HWND hwnd = (HWND) gdk_win32_drawable_get_handle (drawable);
+#elif defined __GTK3__
+    HWND hwnd = (HWND) gdk_win32_window_get_handle (window);
+#endif
 
     context->hdc = GetDC (hwnd);
 
@@ -416,7 +438,11 @@
 
   return TRUE;
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(drawable),
+#elif defined __GTK3__
+  return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(window),
+#endif
 			 context->glxcontext) == True) ? TRUE : FALSE;
 
 #if 0
@@ -427,7 +453,11 @@
     }
   else
     {
+#if defined __GTK2__
       return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(drawable), context->glxcontext) == True) ? TRUE : FALSE;
+#elif defined __GTK3__
+      return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(window), context->glxcontext) == True) ? TRUE : FALSE;
+#endif
     }
 #endif
 #else
@@ -435,17 +465,29 @@
 #endif
 }
 
+#if defined __GTK2__
 void gdk_gl_swap_buffers(GdkDrawable *drawable)
+#elif defined __GTK3__
+void gdk_gl_swap_buffers(GdkWindow *window)
+#endif
 {
 #if defined GDK_WINDOWING_WIN32
   HDC   hdc;
   HWND  hwnd;
 #endif
 
-  g_return_if_fail (GDK_IS_DRAWABLE(drawable));
+#if defined __GTK2__
+g_return_if_fail (GDK_IS_DRAWABLE(drawable));
+#elif defined __GTK3__
+g_return_if_fail (GDK_IS_WINDOW(window));
+#endif
 
 #if defined GDK_WINDOWING_WIN32
+#if defined __GTK2__
   hwnd = (HWND) gdk_win32_drawable_get_handle (drawable);
+#elif defined __GTK3__
+  hwnd = (HWND) gdk_win32_window_get_handle (window);
+#endif
   hdc  = GetDC (hwnd);
   if (hdc  == NULL)
   {
@@ -455,7 +497,11 @@
   SwapBuffers (hdc);
   ReleaseDC (hwnd, hdc);
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   glXSwapBuffers(GDK_WINDOW_XDISPLAY(drawable), GDK_WINDOW_XWINDOW(drawable));
+#elif defined __GTK3__
+  glXSwapBuffers(GDK_WINDOW_XDISPLAY(window), GDK_WINDOW_XWINDOW(window));
+#endif
 #else
   g_warning ("gdk_gl_swap_buffers not implemented on " PLATFORM);
 #endif
@@ -521,7 +567,11 @@
 #if defined GDK_WINDOWING_WIN32
   glFinish ();
   SelectObject (pixmap->hdc, pixmap->hbitmap);
+#if defined __GTK2__
   gdk_pixmap_unref (pixmap->pixmap);
+#elif defined __GTK3__
+  g_object_unref (pixmap->pixbuf);
+#endif
 #elif defined GDK_WINDOWING_X11
   if (pixmap->glxpixmap != None) {
     glXDestroyGLXPixmap(pixmap->xdisplay, pixmap->glxpixmap);
@@ -529,7 +579,11 @@
   }
   pixmap->glxpixmap = None;
   if (pixmap->front_left) {
+#if defined __GTK2__
     gdk_pixmap_unref(pixmap->front_left);
+#elif defined __GTK3__
+    g_object_unref(pixmap->front_left);
+#endif
     glXWaitX();
   }
   pixmap->front_left = NULL;
@@ -550,7 +604,11 @@
 }
 
 GdkGLPixmap *
+#if defined __GTK2__
 gdk_gl_pixmap_new(GdkVisual *visual, GdkPixmap *pixmap)
+#elif defined __GTK3__
+gdk_gl_pixmap_new(GdkVisual *visual, GdkPixbuf *pixbuf)
+#endif
 {
   GdkGLPixmap *glpixmap;
 #ifndef GDK_WINDOWING_WIN32
@@ -568,7 +626,11 @@
 #endif
 
   g_return_val_if_fail(GDK_IS_VISUAL(visual), NULL);
+#if defined __GTK2__
   g_return_val_if_fail(GDK_IS_PIXMAP(pixmap), NULL);
+#elif defined __GTK3__
+  g_return_val_if_fail(GDK_IS_PIXBUF(pixbuf), NULL);
+#endif
 
   glpixmap = g_object_new(GDK_TYPE_GL_PIXMAP, NULL);
   if (!glpixmap)
@@ -578,10 +640,18 @@
   glpixmap->initialised = FALSE;
   glpixmap->hdc = NULL;
   glpixmap->hbitmap = NULL;
+#if defined __GTK2__
   glpixmap->pixmap = gdk_pixmap_ref (pixmap);
+#elif defined __GTK3__
+  glpixmap->pixbuf = g_object_ref (pixbuf);
+#endif
 #elif defined GDK_WINDOWING_X11
   dpy = GDK_DISPLAY();
+#if defined __GTK2__
   xpixmap = (Pixmap)GDK_DRAWABLE_XID(pixmap);
+#elif defined __GTK3__
+  xpixmap = (Pixbuf)GDK_DRAWABLE_XID(pixbuf);
+#endif
 
   g_return_val_if_fail(XGetGeometry(dpy, xpixmap, &root_return,
 				    &x_ret, &y_ret, &w_ret, &h_ret,
@@ -599,7 +669,11 @@
 
   glpixmap->xdisplay   = dpy;
   glpixmap->glxpixmap  = glxpixmap;
+#if defined __GTK2__
   glpixmap->front_left = gdk_pixmap_ref(pixmap);
+#elif defined __GTK3__
+  glpixmap->front_left = g_object_ref(pixbuf);
+#endif
 #endif
 
   return glpixmap;
@@ -628,7 +702,11 @@
 
     context->hdc = CreateCompatibleDC (NULL);
     glpixmap->hdc = context->hdc;
+#if defined __GTK2__
     glpixmap->hbitmap = SelectObject (context->hdc, (HBITMAP) gdk_win32_drawable_get_handle (glpixmap->pixmap));
+#elif defined __GTK3__
+    glpixmap->hbitmap = SelectObject (context->hdc, (HBITMAP) gdk_win32_drawable_get_handle (glpixmap->pixbuf));
+#endif
 
     pf = ChoosePixelFormat (context->hdc, &context->pfd);
 
@@ -670,11 +748,23 @@
  *  Font support
  */
 
+#if defined __GTK3__
+__declspec(dllimport) HFONT		_pango_win32_font_get_hfont         (PangoFont          *font);
+#endif
+
+#if defined __GTK2__
 void gdk_gl_use_gdk_font(GdkFont *font, int first, int count, int list_base)
+#elif defined __GTK3__
+void gdk_gl_use_gdk_font(PangoFont *font, int first, int count, int list_base)
+#endif
 {
 #if defined GDK_WINDOWING_WIN32
   HDC dc = CreateCompatibleDC (NULL);
+#if defined __GTK2__
   HFONT old_font = SelectObject (dc, (void *)gdk_font_id (font));
+#elif defined __GTK3__
+  HFONT old_font = _pango_win32_font_get_hfont (font);
+#endif
 
   wglUseFontBitmaps (dc, first, count, list_base);
 
