[Gtk-sharp-list] GTK 3 OpenGL widget under Windows
jarl.gullberg at gmail.com
Tue Sep 6 13:05:16 UTC 2016
I managed to solve it myself.
The new gdk_win32_window_get_handle function was indeed what I needed to
use, but I had misunderstood how it should have been imported and called.
The following is the short and sweet code which works:
> private IWindowInfo InitializeWindows()
> IntPtr windowHandle = gdk_win32_window_get_handle(this.Window.Handle);
> return Utilities.CreateWindowsWindowInfo(windowHandle);
> [SuppressUnmanagedCodeSecurity, DllImport("libgdk-3-0.dll",
> CallingConvention = CallingConvention.Cdecl)]
> public static extern IntPtr gdk_win32_window_get_handle(IntPtr w);
On 5 September 2016 at 22:44, Jarl Gullberg <jarl.gullberg at gmail.com> wrote:
> Heya fellas,
> I'm having some trouble updating an OpenTK-based GTK2/3 widget to pure
> GTK3. It works great on Linux, but on Windows (using the alpha installer
> for GTK#3) it fails to run.
> All code relevant to my issue is available here: https://github.com/
> In short, it's a drawing area onto which OpenGL draws its buffers. This
> widget is housed in a normal GTK3 UI created via Glade. The issue presents
> itself using gtk-sharp-2.99 on Windows 10.
> I've narrowed the problem down to a section in the code where the widget
> imports a native function from GDK, which allows it to get a drawable
> handle from the widget's window's handle.
> #region Windows Specific initalization
>> private IWindowInfo InitializeWindows()
>> IntPtr windowHandle = gdk_win32_drawable_get_handle(
>> return Utilities.CreateWindowsWindowInfo(windowHandle);
>> [SuppressUnmanagedCodeSecurity, DllImport("libgdk-win32-2.0-0.dll")]
>> public static extern IntPtr gdk_win32_drawable_get_handle(IntPtr d);
> Now, this library does not exist in the new GTK3 installation, and has
> been renamed to libgdk-3-0.dll. I hoped it would be a simple matter of
> changing the dll import statement to match the new library name, but
> unfortunately I wasn't so lucky. gdk_win32_drawable_get_handle is no longer
> defined in the library, and I haven't managed to see any obvious
> I attempted to use gdk_win32_window_get_handle (which returned a valid
> handle) instead, but unfortunately this produced a GraphicsContextException
> instead when the context was made current. The exception message was
> equally unhelpful, and simply stated that it was unable to make the context
> If you know of the new way to get the handle of the drawable or another
> solution to the issue, I would greatly appreciate it. If this question is
> not applicable here, I would also very much appreciate some directions to
> where I could get a hand.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list