I use a small ControlP5 gui in a separate window to aid my sketching, and I want to add a "take screenshot" button to it. I thought it would be simple, but I've run into some problem. I keep getting "Invalid memory access" errors and program crashes when calling save() in my ControlP5 button callback.
I've tried to research it, and my best theory is that it has to do with threading (
this topic is somewhat similar), and that opengl calls (such as the save() function) only can be issued on the thread where the opengl context was created.
So my question is, how can I get around it? How can I force my takeScreenshot callback function to run under the main thread, if that indeed is what this is about?
Edit: Just to clariify: the screenshot button works fine when it's added to the main rendering window. The problem arises when I move my gui to a separate control window.
1