When I copy a texture onto itself, it causes the texture to go white. I'm wondering whether anyone can help me solve this problem. I'm attempting to modify the texture using a shader and use the texture as feedback into the shader but I can't even get it to copy correctly.
// Clear the screen
glClear( GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT );
glBindTexture( GL_TEXTURE_2D, g_Texture[FLUID_2D_VELOCITY] );
glPushMatrix();
glTranslatef( -ex_nHalfScreenWidth + g_arrnTextureResolution[0],
-ex_nHalfScreenHeight + g_arrnTextureResolution[1],
0.0f );
RenderQuad( g_arrnTextureResolution[0], g_arrnTextureResolution[1] );
glPopMatrix();
// Copy the image to the required texture
glBindTexture( GL_TEXTURE_2D, g_Texture[FLUID_2D_VELOCITY] );
glCopyTexImage2D( GL_TEXTURE_2D,
0,
GL_RGBA,
0,
0,
g_arrnTextureResolution[0],
g_arrnTextureResolution[1],
0 );
RenderQuad is
int RenderQuad( int nWidth, int nHeight )
{
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
glBegin( GL_TRIANGLE_STRIP );
glTexCoord2f( 1.0f, 0.0f );
glVertex3f( -nWidth, -nHeight, 100.0f );
glTexCoord2f( 0.0f, 0.0f );
glVertex3f( nWidth, -nHeight, 100.0f );
glTexCoord2f( 1.0f, 1.0f );
glVertex3f( -nWidth, nHeight, 100.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex3f( nWidth, nHeight, 100.0f );
glEnd();
return 0;
}
Thanks for your help.
Edit: Silly me, I forgot to enable GL_TEXTURE_2D. Doh!