I'm trying to create a class that performs actions in a separate thread, and can report on its progress while doing so. The general threading I've gotten together, but since each thread has a different context it's not letting me load OpenGL resources (images, fonts, etc.), which is the primary intended purpose for this class.
I looked through the docs and a SharedDrawable seems like the logical thing to use, so I attempted the following:
protected void shareContext()
{
try
{
Drawable drawable = Display.getDrawable();
sharedDrawable = new SharedDrawable(drawable);
sharedDrawable.makeCurrent();
}
catch (LWJGLException e)
{
e.printStackTrace();
}
}
However, this causes the following exception:
org.lwjgl.LWJGLException: Could not share contexts
at org.lwjgl.opengl.WindowsContextImplementation.nCreate(Native Method)
at org.lwjgl.opengl.WindowsContextImplementation.create(WindowsContextImplementation.java:50)
at org.lwjgl.opengl.Context.<init>(Context.java:131)
at org.lwjgl.opengl.AbstractDrawable.createSharedContext(AbstractDrawable.java:30)
at org.lwjgl.opengl.SharedDrawable.<init>(SharedDrawable.java:50)
So, I think I don't really understand what I'm supposed to do to load OpenGL resources in another thread. Could someone explain how to do this a little better?
FYI, I'm using the Slick-Util texture loading methods.