PDA

View Full Version : When transferring a framebuffer's texture to the screen, data is periodically lost



Aaron
03-23-2007, 05:06 AM
I am rendering to a offscreen unclamped color texture. I am able to successfully read the data using glReadPixels. The problem I am having occurrs when I want to take that texture and bind it to the on-screen framebuffer. When I do that and use a fragment shader that converts the unclamped color to your normal RGB value, sections of the texture are not mapped to the on-screen buffer periodically when I sweep through different rotations of the object.



cgBindPrograms(0,6);
CGparameter imageParam =
cgGetNamedProgramParameter(cgGetFragmentProgram(6) ,CG_PROGRAM,"texImage");
cgGLSetTextureParameter(imageParam,m_texture[IMAGE_IDX].id);
cgGLEnableTextureParameter(imageParam);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);

glDrawBuffer(GL_BACK); // write texture
glShadeModel(GL_FLAT);
glClearDepth(1E8);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_ONE); // full additive blending

// create a quad to cover the entire view area
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_QUADS);
glTexCoord2f(m_clipBoundary.min.x,m_clipBoundary.m in.y);
glVertex2f(m_clipBoundary.min.x,m_clipBoundary.min .y);
glTexCoord2f(m_clipBoundary.max.x,m_clipBoundary.m in.y);
glVertex2f(m_clipBoundary.max.x,m_clipBoundary.min .y);
glTexCoord2f(m_clipBoundary.max.x,m_clipBoundary.m ax.y);
glVertex2f(m_clipBoundary.max.x,m_clipBoundary.max .y);
glTexCoord2f(m_clipBoundary.min.x,m_clipBoundary.m ax.y);
glVertex2f(m_clipBoundary.min.x,m_clipBoundary.max .y);
glEnd();

glXWaitGL();
glXSwapBuffers(m_pDisplay, m_window);

glDisable(m_texture[IMAGE_IDX].target);
cgGLDisableTextureParameter(imageParam);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,m_fo.id);
}Any help will be greatly appreciated. Thanks,

Aaron

dorbie
04-11-2007, 12:45 AM
Screenshot?

It is difficult to understand what is going on from your description.

Set color mask before your clear.
Set texenv to GL_REPLACE (or equivalent).