you may be on to something here. i included
if (!glIsTexture(sh_tex.texture_object[0]))
exit(-1);
before trying to bind the texture (2nd time), and the program exited, so i assume the tex isn’t registering properly. but i’ve used this code b4 for textures, so it must be something to do with the operation/structure of the code…mustn’t it?
the shape (multi-triangled sphere) has attribute sh_tex, which is of type texture. each object of class texture has a texture_object attribute, containing one texture (i may need to expand, so i’m using tex objs). the Texture constructor has the following code to initialise the texture, i’m pretty sure it’s ok.
(64X64 .PPM file)
GLubyte *tex_ptr;
int i;
FILE *tex_file_ptr;
char line[256];
glGenTextures(1, texture_object);
// load the image (.PPM file)
tex_ptr = (GLubyte )malloc(6464*3);
tex_file_ptr = fopen(“image01.ppm”, “rb”);
if(tex_file_ptr == (FILE *)0)
{
fprintf(stderr, "Error opening texture file
");
exit(-1);
}
fgets(line, 256, tex_file_ptr);
for(i=0;i<64643;i++)
tex_ptr[i]=(GLubyte)getc(tex_file_ptr);
fclose(tex_file_ptr);
// install the texture into texture_object
glBindTexture(GL_TEXTURE_2D, texture_object[0]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, tex_ptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
the basic structure is
class shape{
texture obj_tex;
…
…
}
.
.
class texture{
GLuint texture_object[1];
texture();
.
.
texture::texture(){
// initialise texture code as above
…
…
}
i’m also sure that the texture coords have been calulated properly to texture a multiple-triangle sphere.
i’m sure you’re sufficiently confused now,
cheers
I