Hey, I want to compile shaders on a separate thread so that the whole program doesn't freeze while it's processing. To do this I've read that you need to create another thread with a new context, then share that context with the original. You can then compile the shader asynchronously, then swap it out with the current shader when compilation has finished.
I've experiemented with shared contexts in Juce.
I set up the first context like this:
openGLContext.setRenderer(this); openGLContext.attachTo(*this); openGLContext.setContinuousRepainting(true);
Then, when that context has initialised (i.e. newOpenGLContextCreated called) I do this to initialise the compiler context:
shaderCompilerContext.setNativeSharedContext(openGLContext.getRawContext()); shaderCompilerContext.extensions.initialise(); compileThread = new CompileThread(this); compileThread->startThread();
However, when I compile the shader, it fails but the error message is empty. I know the shader code is correct. So it must be something to do with the shared context stuff, or the multithreading.