a question about texture mapping

I want to render two neighor planes be joined on one border.Both planes are textured using texture mapping with the same parameter. when the code is excuted,there is a black line on the joined border between the textured planes.

my question is :how to eliminate the black line.

my code is :

glGenTextures(2,texture_objects);

glBindTexture(GL_TEXTURE_2D, texture_objects[0]);
			
glTexImage2D(GL_TEXTURE_2D,0,3,widthleft,heightleft,0,GL_BGR_EXT,GL_UNSIGNED_BYTE,BitmapBitsLeft);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR );
 	//glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE GL_DECAL);
	
glBindTexture(GL_TEXTURE_2D, texture_objects[1] );
glTexImage2D(GL_TEXTURE_2D,0,3,widthback,heightback,0,GL_BGR_EXT,GL_UNSIGNED_BYTE,BitmapBitsBack);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR );

 glBindTexture(GL_TEXTURE_2D, texture_objects[0]); 
glBegin(GL_POLYGON); 
   glTexCoord2f(0,0);
   glVertex3f(m_vertices[5].x,m_vertices[5].y,m_vertices[5].z); 
   glTexCoord2f(0,1);
   glVertex3f(m_vertices[11].x,m_vertices[11].y,m_vertices[11].z);
   glTexCoord2f(1,1);
   glVertex3f(m_vertices[7].x,m_vertices[7].y,m_vertices[7].z); 
   glTexCoord2f(1,0);
   glVertex3i(m_vertices[1].x,m_vertices[1].y,m_vertices[1].z);
glEnd( ); 

	
glBindTexture(GL_TEXTURE_2D, texture_objects[1] );
glBegin(GL_POLYGON); 
    glTexCoord2f(0,0);
    glVertex3f(m_vertices[2].x,m_vertices[2].y,m_vertices[2].z); 
    glTexCoord2f(1,0);
    glVertex3f(m_vertices[1].x,m_vertices[1].y,m_vertices[1].z);
    glTexCoord2f(1,1);
    glVertex3f(m_vertices[7].x,m_vertices[7].y,m_vertices[7].z); 
    glTexCoord2f(0,1);
    glVertex3f(m_vertices[8].x,m_vertices[8].y,m_vertices[8].z);
glEnd( ); 


glDeleteTextures(2,texture_objects);

linear filtering with GL_CLAMP will filter the texture border color in your case. The texture border color is black per default.
If you don’t want the texture border color to be sampled change all GL_CLAMP to GL_CLAMP_TO_EDGE.
If you want perfect blending you need to add real texture borders of the adjacent texture edges around your textures and leave the wrap modes on GL_CLAMP.
Some older hardware doesn’t support texture borders.

when I change ‘GL_CLAMP’ to "GL_CLAMP_TO_EDGE’, a error occurs:

error C2065: ‘GL_CLAMP_TO_EDGE’ : undeclared identifier.

What can i do to make my computer to support textured borders?

Hi,

You could use Intel’s GLsdk to include all OpenGL function entry points not present in the header provided by Microsoft, along with the new defines.

I hope it helps.

Originally posted by qiongyu_wu:
[b]when I change ‘GL_CLAMP’ to "GL_CLAMP_TO_EDGE’, a error occurs:

error C2065: ‘GL_CLAMP_TO_EDGE’ : undeclared identifier.

What can i do to make my computer to support textured borders?[/b]
The error means you don’t have the GLenum in one of your included GL headers, either gl.h or glext.h. You can find the correct enum in those files at the link http://oss.sgi.com/projects/ogl-sample/registry/

Anyway it’s
#define GL_CLAMP_TO_EDGE 0x812F

That doesn’t mean your OpenGL implementation will accept it. Check the glGetError before and after the glTexParameter call using it. If it’s not GL_NO_ERROR your stuck in that. Your could revert to GL_NEAREST filtering which doesn’t leave the texture.

Texture borders are given with the border parameter in the glTexImage call.
You had 0 there, make it a 1 and send textures which are width + 2, height + 2. That is a 6464 texture becomes a 6666 image. Beware of the glPixelStore unpack alignment in case your texture is RGB!
You need to prepare the texture to contain the adjacent data yourself either in a paint program or at runtime in your app. It’s just some memory copying.

To know if your hardware supports texture borders you should first look at what implementation you are using.
Check the strings returned by glGetString(GL_VENDOR) and glGetString(GL_RENDERER).
If it say Microsoft, you’re not running in hardware anyway.
If not, give it a try and if it’s fast it’s running in hardware, or ignored it. :wink:
Print what you got here and you might get an answer.

If you change GL_CLAMP to GL_REPEAT you’ll at least get rid of the black color, the color from the opposite side of the texture will be filtered in.
Without GL_CLAMP_TO_EDGE available you could use just one mesh with either multitexturing or one combined texture instead of two planes, that would give you the cleanest edge.

if “glGetString(GL_VERSION)” returns 1.2 or higher you should have access to GL_CLAMP_TO_EDGE. (up to date hardware should support 1.5)

The right thing to do is to use GL_CLAMP and put the edge texels of the neighboring texel into the texture border of the current texture.

Thanks all of you.

I download GLsdk and use opengl1.3.1.,add a border to the textures,then the black lines disappears!!!