   Lesson 34 adding textures to the terrain
  Greetings all, I'm quite new to open gl (I've done some OSG, delta 3d coding), so i was wondering how to add a texture to the terrain so it looks more realistic. I've gone through the texturing tutorial on NeHe but had no success so far. I understand that i need to setup the texture similar to the seting up on the faces of poligons, (top/bottom- left/right), but am not sure how exactly to do so? Any help would be appreciated   
  the easiest way to do so would be to stretch a single texture across the whole thing.the simplest way to do that would be to in the function RenderHeightMapand before eachglVertex3i(x, y, z);call this lineglTexCoord2f((float)x*(1/MAP_SIZE),(float)y*(1/MAP_SIZE);This will give the proper texture coordinatesNow all you need is to bind the proper texture and enable texturing, but i leave that to you.   ;  Thank you for your reply, however Im wondering if the height of the heigthmaped terrain does not influence the texturing? I've added the functions from the texturing tutorial,and enabled texturing in glinit I've modified the renderheightmap function like so void RenderHeightMap(BYTE pHeightMap[])// This Renders The Height Map As Quads{glBindTexture(GL_TEXTURE_2D, texture[0]);// Select Our Texture NEWint X = 0, Y = 0;// Create Some Variables To Walk The Array With.int x, y, z;// Create Some Variables For Readabilityif(!pHeightMap) return;// Make Sure Our Height Data Is Validif(bRender)// What We Want To RenderglBegin( GL_QUADS );// Render Polygonselse glBegin( GL_LINES );// Render Lines Insteadfor ( X = 0; X < (MAP_SIZE-STEP_SIZE); X += STEP_SIZE )for ( Y = 0; Y < (MAP_SIZE-STEP_SIZE); Y += STEP_SIZE ){// Get The (X, Y, Z) Value For The Bottom Left Vertexx = X;y = Height(pHeightMap, X, Y );z = Y;  // Set The Color Value Of The Current VertexSetVertexColor(pHeightMap, x, z);glTexCoord2f((float)x*(1/MAP_SIZE),(float)y*(1/MAP_SIZE));glVertex3i(x, y, z);// Send This Vertex To OpenGL To Be Rendered (Integer Points Are Faster)// Get The (X, Y, Z) Value For The Top Left Vertexx = X;y = Height(pHeightMap, X, Y + STEP_SIZE );  z = Y + STEP_SIZE ; // Set The Color Value Of The Current VertexSetVertexColor(pHeightMap, x, z);glTexCoord2f((float)x*(1/MAP_SIZE),(float)y*(1/MAP_SIZE));glVertex3i(x, y, z);// Send This Vertex To OpenGL To Be Rendered// Get The (X, Y, Z) Value For The Top Right Vertexx = X + STEP_SIZE; y = Height(pHeightMap, X + STEP_SIZE, Y + STEP_SIZE ); z = Y + STEP_SIZE ;// Set The Color Value Of The Current VertexSetVertexColor(pHeightMap, x, z);glTexCoord2f((float)x*(1/MAP_SIZE),(float)y*(1/MAP_SIZE));glVertex3i(x, y, z);// Send This Vertex To OpenGL To Be Rendered// Get The (X, Y, Z) Value For The Bottom Right Vertexx = X + STEP_SIZE; y = Height(pHeightMap, X + STEP_SIZE, Y ); z = Y;// Set The Color Value Of The Current VertexSetVertexColor(pHeightMap, x, z);glTexCoord2f((float)x*(1/MAP_SIZE),(float)y*(1/MAP_SIZE));glVertex3i(x, y, z);// Send This Vertex To OpenGL To Be Rendered}glEnd();glColor4f(1.0f, 1.0f, 1.0f, 1.0f);// Reset The Color}It all compiles normaly but no texture is shown :/Here is my solution folder if it helps show you where am i Blunderinghttp://rapidshare.com/files/372982652/NEHE_Lesson34_heightmap_loading.7z.htmlbest regards   ;  well it turns out that you do have texturing, i have two changed you might want to make though1. this line will work much better than the one i gave you beforeglTexCoord2f((float)x/MAP_SIZE,(float)z/MAP_SIZE);2. remove SetVertexColor(pHeightMap, x, z); , you won't need that anymore since it makes the texture a lot darker   ;  Works fine, thank you very much. Totaly forgot bout the setvertex functionBest regards, Daniel   