Hi nutty, thanks for responding.
I’m using an nVidia GeForce 4ti um, 4600? the faster one.
Here’s what I do:
glPushAttrib(GL_ALL_ATTRIB_BITS);
//I read in a ppm file into “GLubyte * pixels;” as follows:
//read header, 255 is the length,
//read in one byte for each: red, green, blue.
//order these pixels together in pixels array: RGBRGBRGB… ect
//Oh, and width and height is in the header.
//Then:
glGenTextures(1,&texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,cols,rows,GL_RGB,GL_UNSIGNED_BYTE,pixels);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_NORMALIZE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, texture_id);
//Enable lighting materials
//Then here’s my hack that seems to fix it:
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glScalef(.5,-.5,0);
glTranslatef(1,1,0);
//switch back to matrix mode:
glMatrixMode(GL_MODELVIEW);
//translate
//rotate
glBindTexture(GL_TEXTURE_2D, texture_id);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
then draw some geometry, I’ve been doing a sqaure for debugging
at the end I pop the matrix’s.
I do have a problem when I try and map the texture to a more complex object. (I’m using a .ply file with texture coordinates) and it doesn’t work is the simplest explanation. It looks incorrect, things are in the wrong place, but with this hack when I map it to a square with the corners the corners of the texture then it appears okay.
thanks,
Sandy