How to connect OpenGL and OpenCL ?

Started by toki78, December 10, 2013, 23:43:42

Previous topic - Next topic

toki78

Hi,
I think I must put the OpenGL contect into the properties buffer, when creating the OpenCL context.
Is there something like : "propsbuffer.put(Display.getPointer)......" ?

I want my OpenCL application to put the rendered image directly into the ColorBuffer.
But I get an INVALID_CONTEXT error.

Sincerely
Thorsten

spasi

The create methods in CLContext accept a Drawable that will be used to setup the (platform-specific) CL/GL interop properties. The Drawable interface also has the setCLSharingProperties(PointerBuffer) method if you'd like to do it manually. The test package has two interop demos that might help you out: org.lwjgl.test.opencl.gl.DemoFractal and org.lwjgl.test.opengl.sprites.SpriteShootoutCL.

toki78

Thanks ! The fractal example helped me a real lot !!
In the meantime I coded my own example.

https://github.com/toki78/RayCL

This is the heaviest example, I ever wrote :
A ray tracer applet with an Octree and OpenGL7OpenCL interop.

You can see it live here :

http://toki.burn3r.de/raycl.html