[Xavier Faure] OpenCL to GL

Hello everybody,

I have a kernel which computes positions and I want to draw this position.

Actually, I lost time by these processes :

1 -> Read the position (cl_mem float4 *) from GPU to CPU
2 -> glBegin(GL_TRIANGLES);
glColor4f(0,1,0,1);
helper::gl::glVertexT(x[a]);
glColor4f(0,0.5,0.5,1);
helper::gl::glVertexT(x[b]);
glColor4f(0,0,1,1);
helper::gl::glVertexT(x[c]);
glEnd();
3 -> And draw (copy CPU to GPU buffer and draw)

Can I draw directly a variable float4 * openCL ?

Thanks for your explanations.

Xavier Faure

You don’t need to read back the data from GPU to CPU. Use Vertex Buffer Objects (VBO) instead so that the data stays in the GPU.

For that you will need to use the OpenGL/OpenCL interoperability extensions described in sections 9.7, 9.8 and 9.9 of the OpenCL 1.1. specification. Here’s a nice tutorial on how that works in practice.