Jump to content
  • Advertisement
Sign in to follow this  
run_g

Problems with Textures

This topic is 3976 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

Hello, I am trying to texture map 2 images to seperate sets of polygons (triangles) using the code below. But instead of having a continous smooth output on the triangles, there are gaps and unexplained patterns on the output, eventhough there are no gaps in the triangle-mesh and no patterns on either of the original texture-images used to map the triangles. please does anyone know how I can fix this problem? X Thanks unfortuantely I can't insert links to the images yet, but i hope u understand the question.
void SimplePolyMesh::TexMapDraw(  int textureID,  point3D *triangleVerts  ){

	GLuint  atexture[1];
	color.ambient_diffuse_specular( .9,  .9,  .9, .9,  .9,  .9,     .9,   .9,  .9  );

	if( textureID == 0 )
		atexture[0] = *Display::tryObj.hTexture;         
	if( textureID == 1 )
		atexture[0] = *Display::tryObj.nTexture;         


	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);		  
	glEnable(GL_BLEND);		                                  
	glBindTexture(GL_TEXTURE_2D, atexture[0]);
	glEnable(GL_TEXTURE_2D);
//===================================================


	triangleNormal  =  ( triangleVerts[1] - triangleVerts[0] ).normalised_cross_prod( triangleVerts[2] - triangleVerts[0] );


	glBegin( GL_TRIANGLES );
	for( int j=0; j < 3; j++ ){

		if (j==0) glTexCoord2f(  1,  1   );// supply texture coordinates
		if (j==2) glTexCoord2f(  0,  0   );
		if (j==3) glTexCoord2f(  0,  1   );  

		glVertex3f( triangleVerts[j].getX(), triangleVerts[j].getY(), triangleVerts[j].getZ() );
		glNormal3f( triangleNormal.getX(), triangleNormal.getY(), triangleNormal.getZ() );
	}
		
	glEnd( );
	glFlush( );  

	glDisable(GL_BLEND);
	glDisable(GL_TEXTURE_2D);
}



[Edited by - run_g on January 29, 2008 8:46:14 AM]

Share this post


Link to post
Share on other sites
Advertisement
Just render 1 triangle


glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 0.0);
glVertex3f(0.0, 0.0, 0.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, 0.0, 0.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(0.0, 1.0, 0.0);
glEnd();



and if it looks ok, ...

Share this post


Link to post
Share on other sites

if (j==0) glTexCoord2f( 1, 1 );// supply texture coordinates
if (j==2) glTexCoord2f( 0, 0 );
if (j==3) glTexCoord2f( 0, 1 );


Why are you checking if j == 3? it can't be 3, because you're increasing it only when it's less than 3! (so just numers 1, 2 and 0) - It'd look like this:


if (j==0) glTexCoord2f( 1, 1 );// supply texture coordinates
if (j==1) glTexCoord2f( 0, 0 );
if (j==2) glTexCoord2f( 0, 1 );

Share this post


Link to post
Share on other sites
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!