-
Notifications
You must be signed in to change notification settings - Fork 19
SharingDataWithOpenGL
Olivier Chafik edited this page Nov 10, 2022
·
3 revisions
When rendering OpenGL scenes which data comes from OpenCL computations (vertices, colors, norms and/or textures), it is important to make sure that as little data is copied as possible.
OpenCL supports an optional OpenGL interoperability, which starts to be implemented by some graphic card vendors.
Setting up an OpenGL-compatible OpenCL context with JavaCL is easy, but as of this writing the resulting context can very instable, depending on the version of your driver. Only experience will tell you if you really want to enable the interoperability.
CLContext context = JavaCL.createContextFromCurrentGL();
Yup, that's it.
They'll be visible to OpenCL as CLBuffer<Byte>
instances (see CLContext.createBufferFromGLBuffer(...))
int vbo = ... ;
CLBuffer<Byte> buffer = context.createBufferFromGLBuffer(usage, vbo);
See CLContext.createImage2DFromGLRenderBuffer