Open Darxoon opened 3 years ago
I also think this would be a good thing to provide in some capacity. It would not be too hard to implement.
Maybe add this as an override
on the 'OpenGlControlBase' control so users can choose to use it or not? I think it would be nice for the incoming parameters to have the error code and message be returned as a string
already without having to marshal the string.
In general, our GlInterface class is intended to be used internally for Avalonia needs, while it might not provide all APIs needed for consumers. Instead, we do recommend using OpenGlControlBase together with libraries like Silk.NET or manual bindings to opengl.
Maybe add this as an override on the 'OpenGlControlBase' control
But extending OpenGlControlBase with some debug information can be useful, right. If you have a specific API proposal.
In general, our GlInterface class is intended to be used internally for Avalonia needs, while it might not provide all APIs needed for consumers. Instead, we do recommend using OpenGlControlBase together with libraries like Silk.NET or manual bindings to opengl.
Maybe add this as an override on the 'OpenGlControlBase' control
But extending OpenGlControlBase with some debug information can be useful, right. If you have a specific API proposal.
I agree with the control. I think it is pretty much already what anybody would need to do anything they need with OpenGL. I myself have already rendered textures by "hooking" in my project Velaptor.
I am indeed using Silk.NET by doing:
this.gl = GL.GetAPI(gl.GetProcAddress);
As for the API proposal, I was thinking somewhere along the lines of this below:
// The severity of the error
public enum GLErrorSeverity
{
Low,
Medium,
High,
Notification
}
// Invoked every time there is an opengl error
public virtual void OnOpenGLError(string errorMessage, int errorCode, GLErrorSeverity errorSeverity)
{
}
Is your feature request related to a problem? Please describe. I'm making a program where I embed an OpenGL Canvas using OpenGlControlBase. Debugging in OpenGL is pretty frustrating because you have to check for errors after every GL call and only get an error code back. An alternative to this is the function glDebugMessageCallback that got introduced in OpenGL 4.3. When an error occurs, it calls the callback given to the function with an error message, which is a lot easier to debug. However, Avalonia doesn't support this function at all.
Describe the solution you'd like Add the method
GlInterface.DebugMessageCallback(DebugProc callback, object or IntPtr userParam)
for OpenGL versions 4.3 and above, which is an alias for the OpenGL functionglDebugMessageCallback
. The typeDebugProc
should be a delegate with the parametersint source, int type, int id, int severity, IntPtr length, string message, object or IntPtr userParam
. Where I wroteobject or IntPtr
, I'm not sure which option would be better.Describe alternatives you've considered Using
GlInterface.GetError
is an alternative but not comparable in usability againstglDebugMessageCallback
.Additional context https://docs.gl/gl4/glDebugMessageCallback