Hi,
As I wrote in another thread, I am porting my OpenGL application from Mac to Windows. I am experiencing the following problem:
I have a PPM image, which I am loading into the following variable:
GLubyte texels[512][512][3];
In my init function, I am setting up a texture, using automatic generation of texture coordinates:
// texture image
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB,GL_UNSIGNED_BYTE, texels);
// set drawing mode to GL_DECAL so that the textured polygons are
//drawn using the colors from the texture map, and not polygon colors
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
// enable automatic texture coords generation
// (in two dimensions as the texture map is 2D)
glEnable( GL_TEXTURE_GEN_S);
glEnable( GL_TEXTURE_GEN_T);
// generate texture coords automatically, s is in the x-direction...
GLfloat x_dir[] = { 1, 0, 0 };
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, x_dir);
// .. t is in the z-direction
GLfloat z_dir[] = { 0, 0, 1 };
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_T, GL_OBJECT_PLANE, z_dir);
// repeat the texture in both directions
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// filtering (not totally sure what this is for)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
Then, when I draw the polygons that I want to texture on, I specify
glEnable( GL_TEXTURE_2D);
before drawing the polygon and
glDisable( GL_TEXTURE_2D);
afterwards. On Mac this worked perfectly but now (on Windows) the textures are not used - instead, my polygons are just green. If I print out the values of the texels variable, they seem alright (they are values from 0 to 255) so I don’t think it’s the loading of the file that’s gone wrong. What can I do?