dwmkerr / sharpgl

Use OpenGL in .NET applications. SharpGL wraps all modern OpenGL features and offers a powerful scene graph to aid development.
MIT License
753 stars 300 forks source link

Debugging SharpGL #131

Closed dom767 closed 7 years ago

dom767 commented 7 years ago

Hi folks,

I've been using SharpGL to build a raytracing engine and have got a couple of odd behaviours that I'd like to get a better handle on.

1) Every frame SharpGL throws this warning... "OpenGL Error: "Invalid operation.", when calling function SharpGL.ReadBuffer" Which I think is related to me changing the framebuffer. I always call gl.BindFramebufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, 0); at the end of my GLSL code, but this error seems to be related to using framebuffer rendering.

2) When I resize the window or change my shader fragment I reinitialise all of the framebuffers and textures at the new size (sometimes the same size). One out of ten times this doesn't seem to work and my application just produces a black screen. There are no gl.geterror()'s when I poll for them during initialisation or rendering. What's the best way to get more information about what's going on here? I've tried hooking up AMD's PerfStudio 3, but that doesn't want to attach to the OpenGL instance in the app for some reason. Has anyone had any luck with this previously?

Anyway, appreciate any feedback you could give me on either of the above issues (perhaps they're related?)

Ta, Dom

dom767 commented 7 years ago

Ok, so I've got to the bottom of the rendering issue I was getting, although not through debugging it to my satisfaction. :) Instead I noticed quite a few issues with different threads rendering OpenGL on this site and others.

The app I'm building has two main windows. The second window is triggered from the first window and OpenGlControl's exist in both windows. When the second window is initialised I now remove the OpenGlControl from the first window... MainCanvas.Children.Remove(openGlCtrl); ...and put it back after I've closed the second window... MainCanvas.Children.Add(openGlCtrl);

This solved all the black screen issues I was getting.

I'm still seeing the "OpenGL Error: "Invalid operation.", when calling function SharpGL.ReadBuffer" each frame, but there's no big deal with that one.

I'd still be interested in working out how to attach a debugger to my app. I've tried AMD's PerfStudio, glDebugger, GLIntercept. No luck with any of them...