   Height map on quad
  I'm having a ton of trouble applying a height map to a rectangle (basically a 'grid' of quads) and have spent hours trying to get it working.I can get texture mapping to work quite nicely and would think that apply displacement using a height map would work similarly. I'm aiming to move on to applying it onto a sphere, but if I can't get it working on a quad, I have little chance of success on a sphere (not to say I haven't tried).Here is the code:glBindTexture(GL_TEXTURE_2D, texture);for (float y = yMin; y <= yMax; y+= yInc){   glBegin(GL_QUAD_STRIP);   for (float x = xMin; x <= xMax; x+= xInc)   { u = calculateU(x, xMin, xMax); //This is very simple here, just clamping the uv between 0 and 1 v = calculateV(y, yMin, yMax); glTexCoord2f(u, v); glVertex3f(x, y, hMap[(int)(u * (h - 1) * (w)) + (int)((w - 1) * (v)] * 0.001f);  v = calculateV(y + yInc, yMix, yMax); glTexCoord2f(u, v); glVertex3f(x, y+iInc, hMap[(int)(u * (h - 1) * (w)) + (int)((w - 1) * (v)] * 0.001f);}That's basically it. I've tried swapping some values around (i.e. v & u) but nothing seems to work. The texture seems to get mapped correctly, so that's telling my UV components seem to be okay.In terms of the map array, the values are stored rows-first, however the formula above is printing them down the columns (which seems to be the correct way to do it).Any ideas what I'm doing wrong? Pitfalls I'm falling into?
  What's wrong with it? flipped/totally_screwed/whatever.And you could tell a bit about your variable names:hMap[(int)(u * (h - 1) * (w)) + (int)((w - 1) * (v)] * 0.001fWe only know what u and v mean.I guess "w" is the horizontal resolution of the heightmap, and "h" is the vertical.   ;  Yeah, pretty much completely screwed. It may be the code I use to get the index but I'm not sure. U/V are the X/Y texture coordinates.   ;  I suggest you to use integer indexing. The common "i++", "j++" stuff. Calculate the "(U,V)", and "(x,y)" coordinates from "i", "j".   