PDA

View Full Version : Problems with texture PCX



mangusta
08-01-2005, 07:59 AM
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!

08-01-2005, 08:32 PM
Looks very noisy. You sure your texture is OK? Aware you are generating mipmaps but not using them?

At a glance, I don't see anything wrong with the disjointed snippets you posted, but that doesn't mean much. Could be any number of things. Can you post some testable code?

:confused:

mangusta
08-01-2005, 11:58 PM
Do you want all the code? I use different files for the data structure and I use a function to read the vertex, faces and texture coordinates from the file ANI

ZbuffeR
08-02-2005, 06:43 AM
Can you map a single quad, it would be easier to check.