Applying textures

Hi, I want to apply a texture to a triangle strip. Don’t know if this is possible, but anyway it doesn’t work. I’d appreciate it if someone could help me. Here’s my drawing code, with the texture loaded in _textureId1:


glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, _textureId1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glColor3f(0.9f, 0.7f, 0.0f);
	for(int z = 0; z < _terrain->length() - 1; z++) {
		//Makes OpenGL draw a triangle at every three consecutive vertices
		glBegin(GL_TRIANGLE_STRIP);
		for(int x = 0; x < _terrain->width(); x++) {
			Vec3f normal = _terrain->getNormal(x, z);
			glTexCoord2f(z/(_terrain->length()-1),x/(_terrain->width()-1));
			glNormal3f(normal[0], normal[1], normal[2]);
			glVertex3f(_terrain->getXPos(x,z),_terrain->getYPos(x,z),_terrain->getZPos(x,z));

			normal = _terrain->getNormal(x, z + 1);
			glTexCoord2f((z+1)/(_terrain->length()-1),x/(_terrain->width()-1));
			glNormal3f(normal[0], normal[1], normal[2]);
			glVertex3f(_terrain->getXPos(x,z+1),_terrain->getYPos(x,z+1),_terrain->getZPos(x,z+1));
		}
		glEnd();
	}
	glDisable(GL_TEXTURE_2D);

Thank you for help :slight_smile:

Ok, forgot to cast the integers to floats…