picoe / Eto.OpenTK

Eto OpenGL viewport (C#)
MIT License
24 stars 41 forks source link

Specify calling convention of Gtk PInvoke call #5

Closed ItEndsWithTens closed 7 years ago

ItEndsWithTens commented 7 years ago

I've been working on a small Eto project recently, using this GL control as a way of learning OpenGL, and I've run into a small issue: the Gtk2 version, when run under a Gtk# installation on my Windows 10 machine, crashes in Visual Studio with a PInvokeStackImbalance error. Whether using the control in my own code, or just running the Gtk2 version of TestEtoGl from this repository, the program crashes a few moments after starting.

Some googling led me to an enlightening bug report for another Gtk#/OpenGL project: https://sourceforge.net/p/glwidget/bugs/3/ Turns out it's a simple fix, just specify the calling convention for the PInvoke call. The default in Windows is Stdcall, where Gtk uses Cdecl. Without setting this, using Eto.Gl.Gtk2 in Windows will prevent the stack from being cleaned up.

I've tested this commit on the aforementioned Windows 10 machine, as well as my usual Ubuntu 14.04 Virtualbox VM, and everything seems to be in order, my project and your test project alike.