Sign in to follow this  
Leo_E_49

glCopyTexImage2D Problem SOLVED

Recommended Posts

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this