LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Kai on March 15, 2011, 14:54:47

Title: OpenCL: clCreateImage2D and CLImageFormat
Post by: Kai on March 15, 2011, 14:54:47
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.
Title: Re: OpenCL: clCreateImage2D and CLImageFormat
Post by: spasi on March 15, 2011, 17:23:43
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).
Title: Re: OpenCL: clCreateImage2D and CLImageFormat
Post by: Kai on March 15, 2011, 17:38:57
Thanks spasi!

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