The problem: glFramebufferTexture2DEXT seems to be taking an unreasonably long time.
I am creating a framebuffer object initialially (once):
GLuint fbo;
glGenFramebuffersEXT(1, &fbo);
if(fbo==0)
throw(“Invalid frame buffer object”);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glViewport(0,0,width, height);
then creating a new texture to render to for each frame:
GLuint texHandle;
glGenTextures(1, &texHandle);
glEnable(GL_TEXTURE_RECTANGLE_NV);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, texHandle);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_R_NV, width, height, 0, GL_RED, GL_FLOAT, 0);
//Where data is a float array of size width * height.
glTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, width, height, ret.second, GL_FLOAT, data);
I am then attaching the output texture to the same FBO each time:
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, texHandle, 0);
if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
throw(“error- frame buffer to texture binding incomplete”);
The program is running correctly, but running very slowly. When profiling I found it was
the glFramebufferTexture2DEXT function (that which attaches the output texture to the FBO each time)
which is taking the time, 0.15 seconds for a 1000x1000 image.
Is this what we be expected or am I doing something wrong?