can not create CLGLObject (random)
Posted by
The.Scotsman on
Jun 15, 2012; 10:16pm
URL: https://forum.jogamp.org/can-not-create-CLGLObject-random-tp4025227.html
Standard display() scenario:
if(!sceneInitialized) {
GL2 gl = drawable.getGL().getGL2();
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
long length = buffLen * GLBuffers.SIZEOF_FLOAT;
gl.glGenBuffers(1, VBOidV, 0);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, VBOidV[0]);
gl.glBufferData(GL2.GL_ARRAY_BUFFER, length, vBuff, GL2.GL_STATIC_DRAW);
...repeat for normals...
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
gl.glFinish();
System.out.println("clContext = " + clContext);
clBuffer = clContext.createFromGLBuffer(VBOidV[0], length, CLGLBuffer.Mem.READ_ONLY);
sceneInitialized = true;
}
The graphics for this display
beautifully.
However, the
createFromGLBuffer crashes randomly.
Actually, not completely randomly.
I load a new "model" and call
canvas.display() (i.e. repaint-on-demand)
clContext does not change.
createFromGLBuffer throws an exception about 2/3 the time.
com.jogamp.opencl.CLException$CLInvalidGLObjectException: can not create CLGLObject from #1 [error: CL_INVALID_GL_OBJECT]
This seems like some kind of timing/threading problem.
(
canvas.display() appears to be threaded)
The jogamp use guide isn't much help here - the section under "AWT Multithreading Issues" starts with "Below statements incorrect!"
Any clue as to how to approach this?
Thanks.