Hi to everybody.
I have problem with a texture mapping. I want to load a texture on a mesh from a file PCX.
The result is very strange. I have the mesh loaded in a good way but the texture is not correct. I paste here the code what does that.
before the is the code necessary for convert the PCX image, and I am sure it’s correct.
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &texID);
glBindTexture(GL_TEXTURE_2D, texID);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,
GL_UNSIGNED_BYTE,imageData);
gluBuild2DMipmaps(
GL_TEXTURE_2D,
GL_RGB,
width,height,
GL_RGB,
GL_UNSIGNED_BYTE,
imageData
);
glEnable(GL_TEXTURE_GEN_S);
glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
float v0[4]={0,0,1,0};
glTexGenfv(GL_S,GL_EYE_PLANE,v0);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
float v1[4]={1,0,0,0};
glTexGenfv(GL_T,GL_EYE_PLANE,v1);
glEnable(GL_TEXTURE_2D);
}
Then, when I paint the mesh (ANI format)
glBegin(GL_TRIANGLES);
for (int i=0; i nfac; i++){
int indice;
indice = f[i].v0;
glTexCoord2f(s[indice].s0,t[indice].t0);
glVertex3f( v[ indice ].x, v[ indice ].y,v[ indice ].z );
indice = f[i].v1;
glTexCoord2f(s[indice].s1,t[indice].t1);
glVertex3f( v[ indice ].x, v[ indice ].y,v[ indice ].z );
indice = f[i].v2;
glTexCoord2f(s[indice].s2,t[indice].t2);
glVertex3f( v[ indice ].x, v[ indice ].y,v[ indice ].z );
}
glEnd();
The data structure is correct.
That is the result I have
http://putfile.com/pic.php?pic=8/21211505874.jpg&s=x1
Thank a lot!