PDA

View Full Version : Texture combiner within an FBO (solved)



renaissanz
07-21-2006, 11:56 AM
Little bit of a a repeat post, but I've cleaned it up, and narrowed down what it is I'm looking for:

I'm trying to use multitexturing/combiners within an FBO. I need to interpolate between a pre-render texture copy and a post-render texture copy. Here's some psuedo code for how I obtain the two textures and multitexture:

loop from 0 to 19
bind fbo 0
bind rbo 0
bind texture 0
if loop is 0
generate blank texture
glTexImage2D
else
glCopyTexImage2D
render geometry
bind texture 1
glCopyTexImage2D
bind fbo 0 to 0
render said geometry
bind fbo 1
bind rbo 1
multitexture/combine onto geometry
readback
loop

Here's the actual code for how I do the multitexturing in FBO 1:


glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_uiBeforeTexture);
//================================================== ========
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_uiAfterTexture);
//================================================== ========
GLfloat constAlpha[] = {0.0f, 0.0f, 0.0f, (19.0f - (GLfloat)i) / 19.0f};
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constAlpha);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);

glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

glTexEnvf(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_CONSTANT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
//================================================== ========

float aspect = (GLfloat)viewportWidth/(GLfloat)viewportHeight;

glBegin(GL_QUADS);

glNormal3f(0., 0., 1.);

glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);
glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f);
glVertex3f(-1*aspect, -1., 0.0);

glMultiTexCoord2f(GL_TEXTURE0, 1.0f, 0.0f);
glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 0.0f);
glVertex3f( 1*aspect, -1., 0.0);

glMultiTexCoord2f(GL_TEXTURE0, 1.0f, 1.0f);
glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 1.0f);
glVertex3f( 1*aspect, 1., 0.0);

glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1.0f);
glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1.0f);
glVertex3f(-1*aspect, 1., 0.0);

glEnd();When I read back and dump it to a file, I get black. I've tested the dump to file function successfully, so I'm sure it's not that. Anybody know if what I'm trying to do is even possible?

Thanks in advance

renaissanz
07-22-2006, 01:23 PM
Well, I guess I answered my own question. NO, it does not appear to be possible to to use texture combiners within an FBO. I had all of my TexEnv stuff set up correctly, but when I render the quad within the FBO, the readback was blank. However, when I rendered the combiner onto a quad within the main frame buffer, the combiner worked, and I got a an interpolated texture a quad. Lesson learned.