Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texturing problems

Started by wiggyh Dec 29, 2006 at 5:59 PM 1 replies 700+ views
Original Post
wiggyh
wiggyh
My program I am working on will only display one texture. I have a height mapped land; the land is to be textured according to the height of the area being textured. It builds fine, but when it runs it only displays one texture. If anyone could help me out I would be grateful. Here is my code I believe is the problem. I am using C++ and OpenGL. sorry most of the comments are to myself so they may not make sense.
[for(X = 0; X< (MAP_SIZE-STEP_SIZE); X+= STEP_SIZE)
		for(Y = 0; Y<(MAP_SIZE-STEP_SIZE); Y+= STEP_SIZE)
		{
			
			x = X;							//initialize for the quad
			y = Height(pHeightMap, X, Y);	
			z = Y;
			
			if((Height(pHeightMap, x, y) / 256.0f) <= .55)		//assign texture[1] to lower then .55
			{
				glBindTexture(GL_TEXTURE_2D, texture[1]);		//select the final ground texture	
			}
			else
			if((Height(pHeightMap, x, y) / 256.0f) > .55 && (Height(pHeightMap, x, y) / 256.0f) <= .8)		//assign texture[0] between .55 and .8
			{
				glBindTexture(GL_TEXTURE_2D, texture[0]);  //select the final vertical texture will change to allow different textures
			}
			else
			if((Height(pHeightMap, x, y) / 256.0f) > .8)		//will assign a future texture
			{
				glBindTexture(GL_TEXTURE_2D, texture[0]);		//select the final ground texture				
			}

			glBegin(GL_QUADS);		//what we render
			//get the coords for bottom left
			x = X;
			y = Height(pHeightMap, X, Y);	
			z = Y;

			glTexCoord2f(0.0f, 0.0f); glVertex3i(x, y, z);		//Sends this vertex to be rendered
			//get the coords for TOP left
			x = X;
			y = Height(pHeightMap, X, Y + STEP_SIZE);
			z = Y+STEP_SIZE;
			glTexCoord2f(0.0f, 1.0f); glVertex3i(x, y, z);		//Sends this vertex to be rendered
			//get the coords for TOP RIGHT
			x = X+ STEP_SIZE;
			y = Height(pHeightMap, X+ STEP_SIZE, Y+ STEP_SIZE);
			z = Y+ STEP_SIZE;
			glTexCoord2f(1.0f, 1.0f); glVertex3i(x, y, z);		//Sends this vertex to be rendered
			//get the coords for bottom RIGHT
			x = X+ STEP_SIZE;
			y = Height(pHeightMap, X+ STEP_SIZE, Y);
			z = Y;
			glTexCoord2f(1.0f, 0.0f); glVertex3i(x, y, z);		//Sends this vertex to be rendered
		}
		glEnd();]


MARS_999
MARS_999
YOu need to tile your texture coordinates.

like so

const float tileAmount = 10.0f;glTexCoord2f(0.0f, 0.0f);glTexCoord2f(tileAmount, 0.0f);glTexCoord2f(tileAmount, tileAmount);glTexCoord2f(0.0f, tileAmount);
wiggyh
wiggyh
thanks I will try that

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.