luca-piccioni / OpenGL.Net

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

How to create a debug context #9

Closed MichaelEwe closed 8 years ago

MichaelEwe commented 8 years ago

Big thanks for this alternative to OpenTK

Currently I am rendering OpenGL content within a WPF application. I cannot host your GlControl in a WindowsFormsHost, because the entire HAL namespace is not part of the nuget package, and I want to stick to that.

So my way is to create a Window and a OpenGL context on my own and host it in a HwndHost.This works out fine. But I cannot figure out, how to set the callback function for a debug context.

object userParam = someObjectOfInterest;
IntPtr callback = ???;
OpenGL.Gl.DebugMessageCallback(callback, userParam);

How do I obtain an Intptr to my callback function? A delegate for the callback itself does not seem to exist.

luca-piccioni commented 8 years ago

The GlControl is included in OpenGL.Net (and an older version is included in NuGet package also). However, that's fine also to manage your hosting handle yourself since you have all the API available.

Actually I typed the debug callback as IntPtr; this is correct but requires you to manage the delegate definition and the use of GetFunctionPointerForDelegate.

I'm working right now to include the required definitions (lazy mode is on).

luca-piccioni commented 8 years ago

This commit will solve your issue.

MichaelEwe commented 8 years ago

Very nice, thank you very much!