|
Hi!
I have a bit of a problem with glLists in JOGL2. If someone could give me some advice i would be very grateful!
I have a project where I have to load a single model and then be able to load a different model replacing the first one.
Here's the function i use to load a model:
public void loadModel(final GeometricModel geometricModel) {
if (Threading.isOpenGLThread())
glLoadModel(geometricModel);
else
Threading.invokeOnOpenGLThread(new Runnable() {
@Override
public void run() {
glLoadModel(geometricModel);
}
});
}
Here's the function i use to load a model into a glList:
private void glLoadModel(GeometricModel geometricModel) {
if (gl.glIsList(GL_DRAW_WIRED))
gl.glDeleteLists(GL_DRAW_WIRED, 2);
GL_DRAW_WIRED = gl.glGenLists(2);
GL_DRAW_FACED = GL_DRAW_WIRED + 1;
geometricModel.drawWired(gl, colorRedE, colorGreenE, colorBlueE);
gl.glEndList();
gl.glNewList(GL_DRAW_FACED, GL2.GL_COMPILE);
geometricModel.drawFaces(gl, colorRedF, colorGreenF, colorBlueF);
gl.glEndList();
}
In the first function, i check if I'm in OpenGL thread because i only load the model from the openGL thread the first time. Every next model is loaded from a different thread.
Anyway... Here's the problem... When running from OpenGL thread directly, everything works normal, but when I try to load a second model from Runnable, gl.glIsList(GL_DRAW_WIRED) returns false and gl.glGenLists(2) returns 0 which indicates some sort of a problem. But i cought no glErrors after that command.
So basically, my question is: what's the difference between running directly from OpenGL thread and trough Runnable? I guess this has more to do with AWT events then anything but i can't seem to figure it out. Please help :(
|