if(platform == null) {
out.println("test aborted");
return;
}
CLDevice theChosenOne = platform.getMaxFlopsDevice(CLDeviceFilters.glSharing());
out.println(theChosenOne);
CLGLContext context = CLGLContext.create(glcontext, theChosenOne);
try{
out.println(context);
GL2 gl = glcontext.getGL().getGL2();
int[] id = new int[1];
gl.glGenBuffers(id.length, id, 0);
IntBuffer glData = Buffers.newDirectIntBuffer(new int[] {0,1,2,3,4,5,6,7,8});
glData.rewind();
// create and write GL buffer
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, id[0]);
gl.glBufferData(GL2.GL_ARRAY_BUFFER, glData.capacity()*4, glData, GL2.GL_STATIC_DRAW);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
gl.glFinish();
// create CLGL buffer
IntBuffer clData = Buffers.newDirectIntBuffer(9);
CLGLBuffer<IntBuffer> clBuffer = context.createFromGLBuffer(clData, id[0], glData.capacity()*4, Mem.READ_ONLY);
assertEquals(glData.capacity(), clBuffer.getCLCapacity());
assertEquals(glData.capacity()*4, clBuffer.getCLSize());
CLCommandQueue queue = theChosenOne.createCommandQueue();
// read gl buffer into cl nio buffer
queue.putAcquireGLObject(clBuffer)
.putReadBuffer(clBuffer, true)
.putReleaseGLObject(clBuffer);