I moved my OpenGL rendering to a thread, as sort of suggested.
It seems like I did all the right overrides, it works, and really eases up my main thread. But there’s edge cases where contexts are being changed and it falls down, hard.
Part of this was my issue, but part seems related to the fact that threads can access the context while it’s being deleted. Here’s a potential fix for that in the InternalGLContext::release:
[code] if (context != 0)
{
// Need to clear the context so threads can’t get it, then delete it
void* oldContext = context;
context = 0;
juce_deleteOpenGLContext (oldContext);
}
[/code]
I suspect the real solution is to add a Critical section, perhaps an optional one and lock all context access? That won’t help with speed, but if it’s off the main thread may not hurt. I’ll keep testing the threaded version.
Thoughts?
Bruce