Hi,
I have some problems with the render to texture. But first, let me explain a bit the context.
In my project, I have an input image which is a CIImage (Core Image = Apple) that I want to modify in OpenCL.
However, it seems that it is not possible to convert directly a CIImage into a OpenCL image2d.
The only way to do it (as far as i know) is the following:
CIImage -> OpenGL texture attached to a FBO -> OpenCL image2d
I think I understand now the concept of FBO, but I'm clearly not an expert in OpenGL.
In this context, OpenGL is just a gateway between Core Image and OpenCL...
I paste some code bellow.
Code :// Create the FBO object glGenFramebuffersEXT(1, &FBOid); // Create the texture glGenTextures(1, &FBOTextureId); // Bind to FBO glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOid); // Initialize FBO Texture glBindTexture( GL_TEXTURE_RECTANGLE_ARB, FBOTextureId); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); // Attach texture to the FBO glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, FBOTextureId, 0); // Make sure the FBO was created succesfully. if (GL_FRAMEBUFFER_COMPLETE_EXT != glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)) { printf("ERROR\n"); } // Unbind FBO glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
Then I render my CIImage in the FBO which should fill the OpenGL texture.
When I render the FBO, I see my image correctly.
But when I read my OpenGL texture in OpenCL, the values are random.
One may say that I haven't transferred correctly the OpenGL texture to the OpenCL image2d.
But if I specify a buffer containing the image pixels in glTexImage2D (last parameter), then everything works perfectly.
So how can the rendering be good and the texture empty?
My guess: I read the texture before it has actually been filled.
How to be sure that my texture has been filled at some point?
Thank you for your help,
Vincent



