1d texturing on a flat quad

Didn’t get a respond on the beginner section so I thought I try it here.
When I texture height the 1d texturing it works, but when it does a quad with all four corners are the same height thus the value I give for the texcoord are all the same I first get the topmost color. Anyone know the reason for it.
if(!m_pDS->m_bAutoCr)glEnable(GL_TEXTURE_1D);
glBegin(GL_QUADS);
ColorLevel(m_p3D->m_XYZ.z[jm_p3D->nX+i]);
glVertex3f(m_p3D->m_XYZ.x[i], m_p3D->m_XYZ.y[j], m_p3D->m_XYZ.z[j
m_p3D->nX+i]);

ColorLevel(m_p3D->m_XYZ.z[jm_p3D->nX+i+1]);
glVertex3f(m_p3D->m_XYZ.x[i+1], m_p3D->m_XYZ.y[j], m_p3D->m_XYZ.z[j
m_p3D->nX+i+1]);

ColorLevel(m_p3D->m_XYZ.z[(j+1)*m_p3D->nX+i+1]);
glVertex3f(m_p3D->m_XYZ.x[i+1], m_p3D->m_XYZ.y[j+1], m_p3D->m_XYZ.z[(j+1)*m_p3D->nX+i+1]);

ColorLevel(m_p3D->m_XYZ.z[(j+1)*m_p3D->nX+i]);

glVertex3f(m_p3D->m_XYZ.x[i], m_p3D->m_XYZ.y[j+1], m_p3D->m_XYZ.z[(j+1)*m_p3D->nX+i]);
glEnd();
if(!m_pDS->m_bAutoCr)glDisable(GL_TEXTURE_1D);

Colorlevel just gets a gltexcoord1f value 0 to 1 based upon on height. There are 8 levels of color. It shows the topmost color even though the value is 0 for all points.

Maybe you are using repeat as wrapping mode? Together with linear filtering with would result in averagining the color values of the opposite edges of the texture for texture coordinate 0. The appropriate wrapping mode for your problem seems to be clamp to egde, i.e. in plain OpenGL:
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

-boyd

That seemed to help but it is still blending the colors on flat surfaces. Picture a box on a floor. The side of the box is correct but the top of the box and the floor are still doing color blending. Here is the parameters I am setting.
glBindTexture(GL_TEXTURE_1D,texName);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage1D(GL_TEXTURE_1D, 0, 3,16 , 0, GL_RGB, GL_UNSIGNED_BYTE,
ColorScale);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glDisable(GL_TEXTURE_1D);

I am using 16 colors now.

With linear filtering GL_CLAMP uses border information. You probably want the border values to be the same as the values at the edge.
glTexImage1D(GL_TEXTURE_1D, 0, 3,18 , 1, GL_RGB, GL_UNSIGNED_BYTE,
ColorScale);

with 18 colors repeating the first and the last of your 16 colors should do the job.

Or just use
GL_CLAMP_TO_EDGE
This ignores border information.

-boyd