luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.
MIT License
570 stars 109 forks source link

Examples of rendering to a hidden window... #25

Closed equinox2k closed 7 years ago

equinox2k commented 7 years ago

Hi been trying to work out how to render to a hidden form as wanting to write a console application that renders content saves the back buffer without a form appearing.

Any examples or pointers to how to manually create the context etc would be appreciated...

luca-piccioni commented 7 years ago

Currently I've not introduced any off-screen support, but I'm working on it just right now. What platform are you targeting?

equinox2k commented 7 years ago

Targeting windows console app also ASP.Net controller.

Id also like to say thank you for creating such a great library, I had originally done application using OpenTK and was very easy to port over.

equinox2k commented 7 years ago

Hi, just given it a whirl and seems to work perfectly thanks :)

equinox2k commented 7 years ago

Spoke a bit to soon, console application works perfectly, in a web context the DeviceContext.Create() returns null (Caching made me think it was working), will investigate further...

luca-piccioni commented 7 years ago

If ASP.Net is executed by a service, there are no chance to get any GPU context, since the service is running on OS session 0, which forbid iteraction with the graphics system.

You're best bet is to integrate the GL application running on another session or on another computer, and get ghe information via IPC.

equinox2k commented 7 years ago

Yeah, I thought I had got around that issue in past by doing equivalent of...

var form = new Form(); using (DeviceContext deviceContext = DeviceContext.Create(IntPtr.Zero, form.Handle))

which was enough to give the service a form handle to generate things from, but must admit that was doing DirectX.

I will go the IPC route using the off screen rendering I have already implemented thanks to above.

luca-piccioni commented 7 years ago

If DX are working in that environment, you can try to use GLES2 over ANGLE: in this way you can use DX wrapped on GLES API.

Set at first Egl.IsRequired as true, and see Egl static constructor how to provide ANGLE libs.