Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Journeyman III

OpenCL - OpenGL trouble to display image

Hi Everybody,

I've developed a small application of the Harris corner detection on a video. At first I was displaying the result using OpenCV (as I use it also to read my video).

Now I want to boost the performance and I want to make the display with OpenGL.

I've read the chapter 15 in "OpenCL in Action" ed. Manning, and I've decided to make first a small application to test my new knowledge. Unfortunately I didn't manage.

So here is what I need:

It's only a test, I mean it doesn't make much sense :

I read one frame at a time with OpenCV, I send it to the GPU to simply transfer its pixels and 2D coordinates to 2 OpenGL buffers. After that I want to use these two buffers to display them with OpenGL. I took the source code from OpenCL in Action available here (called Ch15_sphere). And I transformed it to attempt to make what i describe above (attached with this post).

Everything runs, but nothing is displayed. I'm almost sure that is due to my lake of knowledge in shader programming but it could be also that it is not the way to do it at all, since the example given in the book is about to render something and that i only want to display an already existing image.

So I have 2 questions:

  • What did I do wrong in the code posted here?
  • Is it even possible to make it work with this approach and does it exist a better way to reach my goal?

Also another thing that bothers me is that I read BGR 24 bits video, and that it  seems that i can't have the corresponding OpenGL type. Any though on that would be welcomed too.

I use Win 7 x64 pro and i develop with Visual Studio 2010. I don't thing that info on my system could help but if think so, just ask.

If I am unclear or that I miss to provide useful info, let me know too.

Thank you guys,

3 Replies

i assume that you are using images in OpenCL. be sure that you use approtiate write_image function in kernel. like write_imagef() with values 0.0-1.0 and CL_UNORM_INT8.

also you need manualy convert that BGR 24 it video to 32bit as OpenCL doesn't support 24bit images.


Well as a matter of fact I don't. I use buffers so far cause I didn't solve this problem of 24 bits image yet.

In the code provided in the book I read, they were using buffers also and it seemed fine (but not doing the same thing I want).

also In OpenGL in the glVertexAttribPointer(...) command I set to false the Normalize parameter.

Adept II

There is no support for 24 bit images in OpenCL. You need to convert 24 bit RGB/BGR to 32 bit RGBA/BGRA.

See formats at cl_image_format