Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

schnegge

one texture for terrain

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

i wanna use one pic for the whole terrain.but why does it look so weird?? i wanna texture this pic: and it looks like this: why?? here is the code:
      
float xTexture = 0.0f;
float yTexture = 0.0f;

for(y=1; y<heightMapHeight-1; y++)
{
if(renderMode==RENDER_FILLED || renderMode==RENDER_TEXTURED)
	glBegin(GL_TRIANGLE_STRIP);
if(renderMode==RENDER_WIRE)
	glBegin(GL_LINES);

	//Render the row as a triangle strip

	for(x=0; x<heightMapWidth-1; x++)
	{
	glTexCoord2f(xTexture, yTexture);
	glVertex3f(terrain[((y*heightMapHeight)+x)][0],terrain[((y*heightMapHeight)+x)][1],terrain[((y*heightMapHeight)+x)][2]);
				
	glTexCoord2f((xTexture + (1/heightMapWidth)), yTexture);
	glVertex3f(terrain[((y*heightMapHeight)+(x+1))][0],terrain[((y*heightMapHeight)+(x+1))][1],terrain[((y*heightMapHeight)+(x+1))][2]);
				
	glTexCoord2f(xTexture, (yTexture + (1/heightMapHeight)));
	glVertex3f(terrain[(((y+1)*heightMapHeight)+x)][0],terrain[(((y+1)*heightMapHeight)+x)][1],terrain[(((y+1)*heightMapHeight)+x)][2]);
				
	glTexCoord2f((xTexture + (1/heightMapWidth)),( yTexture + (1/heightMapHeight)));
	glVertex3f(terrain[(((y+1)*heightMapHeight)+(x+1))][0],terrain[(((y+1)*heightMapHeight)+(x+1))][1],terrain[(((y+1)*heightMapHeight)+(x+1))][2]);
			
	xTexture += (1.0f/heightMapWidth);
	}
glEnd();

xTexture = 0.0f;
yTexture += (1.0f/heightMapHeight);
}
      

Share this post


Link to post
Share on other sites
Advertisement
Looks like your texture coordinates are screwed up. Haven''t looked at your code, but I''m guessing that''s why it looks funny.

--Buzzy

Share this post


Link to post
Share on other sites
Move your glTexCoord2(...);''s around and keep testing it you will find the correct order remember that you are useing a TRIANGLE_STRIP : ) .

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!