Problems using OpenGL-Framebuffer

I’d like to access the OpenGL Framebuffer and don’t understand how to cope with that. I need the renderbuffer for writing to it and then display it.
I was thinking about doing it like this:

  1. Create OpenGL Context(e.g. glutInit)
  2. initialize OpenCL with OpenGL Share Group for accessing OpenGL Context
  3. Get the renderbuffer to manipulate it.
  4. Display the renderbuffer.

Is it possible to use double-buffering and always manipulate the back-buffer and switch the buffers after that with glutSwapBuffers?

Getting the OpenGL-Context is not the big problem for me; I don’t understand the function to get the renderbuffer:

cl_mem clCreateFromGLRenderbuffer (
cl_context context, cl_mem_flags flags,
GLuint renderbuffer, int *errcode_ret)

What do I insert for GLuint renderbuffer?

One last question(if the answer is no, I didn’t understand anything ;)). Is the Renderbuffer the same as the Framebuffer?

Thanks for help,


I’m not sure if you can access the framebuffer directly. I’ve mostly seen people write to an image that is shared between CL and GL and then use GL to draw that image. You can take a look at some of Apple’s sample code that does CL/GL interaction to get some hints.

Hi dbs2,

Thats what I saw too (for example in the NVIDIA OpenCL SDK). But it is a detour as they do it!

GL Renderbuffers are different from Framebuffers.
I also noticed that Renderbuffers are mentioned in the OpenCL 3.x Specification, but NOT in the 2.1 Specification.
So GL Renderbuffer Sharing is only possible with OpenGL 3.x I think.