Advertisement Jump to content
Sign in to follow this  
Leo_E_49

glCopyTexImage2D Problem SOLVED

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!