luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.
MIT License
567 stars 107 forks source link

Steam Overlay fails to hook into Device Context Creation and SwapBuffers #143

Open Vercidium opened 4 years ago

Vercidium commented 4 years ago

I am attempting to integrate the Steam Overlay with my Windows game, however it doesn't render on top of the window.

I created a new blank test project and used another OpenGL C# wrapper, and the Steam Overlay worked successfully. I then switched this test project over to OpenGL.Net, however the Steam Overlay was invisible again.

The Steam Overlay works by hooking into the device creation, as well as hooking into the swap buffers call and doing its rendering there. The Steam documentation specifies that the overlay must be initialised 'prior to initializing the OpenGL/D3D device, otherwise it won't be able to hook the device creation'.

Is there anything happening in the way OpenGL.Net creates the device context that could be confusing the Steam Overlay, or causing it to hook into the wrong context?

luca-piccioni commented 4 years ago

Maybe there is a conflict with the static constructor of Gl. Probably Steam hooking is based on DLL injection, wrapping well known libraries (such as opengl32.dll on Windows). But the Gl static constructor forces the loading of the libraries by creating a temporary GL context. You could try to disable the Initialize call in static constructor by using user environment variables prior to call any OpenGL.Net method.

Or.. are you running with EGL? Maybe EGL device context creation is not supported by Steam (I doubt it)...

Are you getting this problem on a specific platform? (i.e. Linux only)