New WindowsGL bindings cause PInvokeStackImbalance

I just tried to run my game with the latest version of Monogame, with the custom bindings, but I ran into a serious problem pretty quickly. On the first GL call in GraphicsDevice.PlatformSetup() (GetInteger) calling GL corrupts the stack.

Changing all calling conventions to StdCall/Winapi instead of Cdecl actually makes this call and GL.GetString(StringName.Extensions)… Enough to run through PlatformInitialize, but quickly fails at a call to GL.DepthRange():

I looked into it a bit further and glDepthRange actually seems to accept (double, double) instead of (float, float)… and now the bindings work perfectly. What I’m worried about is the fact that I had to do this, and that my configuration may be incorrect.

I’m on Windows 10 x64. I’ve tried building the game for x86 and x64, and both bundled SDL dlls. I’m using a laptop with switchable graphics: Intel HD Graphics and NVIDIA GTX 870M.

I got that last night when trying to use an older project with the latest MonoGame as well. I tried to update the project but kept getting those exceptions. Ended up creating a new project from the latest template to get it working properly.

I was getting same or similar issue while moving from 3.5 to latest 3.6 dev build but sorted it out by creating new project and adding additional 32 bit DLLs that I used to x86 and its 64bit versions to x64 folders.

But I want my game to be just 32bit and no bother with 64.
In Program.cs befor Run() I added:
MonoGame.Utilities.PlatformParameters.DetectWindowsArchitecture = false;
Moved 32 bit DLLs from x86 folder to the root
and set Platform target in Build to be x86. When I run it I get the same error that can be seen in first picture.

What should I do to make my game 32bit only?

@RHY3756547- This was fixed just today…

Give the latest develop code a try.

1 Like

Tested, 32 bit only works now. Great job.