OpenCL: clCreateImage2D and CLImageFormat

Started by Kai, March 15, 2011, 14:54:47

Previous topic - Next topic

Kai

Hi,

I want to create an image in OpenCL but the API method CL10.clCreateImage2D takes a NIO ByteBuffer where (in the C-API) a cl_image_format pointer is expected.
Now, I found that there is a CLImageFormat class in LWJGL/OpenCL but I don't know how to convert that into a ByteBuffer.
Should I merely create a ByteBuffer holding 2 ints and put "image_channel_order" and "image_channel_data_type" into it?

Thanks in advance.

spasi

You can either use CLMem.createImage2D and pass a CLImageFormat object there, or use the low-level CL10.clCreateImage2D and do what you describe (pass a simple ByteBuffer holding 2 ints), it will work. The high-level method does exactly that internally (see CLMemUtil in InfoUtilFactory).

Kai

Thanks spasi!

I didn't know of the class CLMem. Comes in really handy! :-)