Désolé de remettre ce sujet, mais le suicide est proche....
Si quelqu'un y comprend qq chose....
Je suis revenu a quelque chose de basique :
un pointeur simple sur unsigned char pour la variable texture qui contient les pixels de mon image.
Je n'ai pas d'erreur de desallocation, mais la fonction gluBuild2DMipmaps ne mappe pas... pourtant des données lui sont transmises et elles me semblent contigues.
Je vous livre le code. J'espere que qq un aura la synthese qu'il m'a manque.
Merci....
///////////////////// MAIN ////////////////////////
int main(int argc, char **argv)
{
unsigned char *text;
....
....
/* Chargement de la texture */
text=loadJpegImage(chemin, &width, &height);
....
....
gluBuild2DMipmaps(GL_TEXTURE_2D,3,width,height,GL_RGB,GL_UNSIGNED_BYTE,text);
....
....
}
///////////////////// IMAGE ////////////////////////
unsigned char *loadJpegImage(char *fichier, int *Pt_width, int *Pt_height)
{
....
....
unsigned char *ligne;
FILE *file;
int t_width = cinfo.image_width;
int t_height = cinfo.image_height;
Pt_width = &(t_width);
Pt_height = &(t_height);
if (cinfo.jpeg_color_space==JCS_GRAYSCALE)
{
int dim_gris = (t_width * t_height);
unsigned char *image_gris = (unsigned char
*)malloc(dim_gris*sizeof(unsigned char));
if (image_gris == NULL){cout<<endl<<"Erreur d'allocation
image_gris"<<endl;exit(0);}
unsigned char *texture = (unsigned char
*)malloc(dim_gris*3*sizeof(unsigned char));
if (texture == NULL){cout<<endl<<"Erreur d'allocation
texture"<<endl;exit(0);}
#ifdef PERFORM_MEMORY_CHEKS
MEMCHEK_reportLeak();
#endif
jpeg_start_decompress(&cinfo);
ligne=image_gris;
while (cinfo.output_scanline<cinfo.output_height)
{
ligne=image_gris+t_width*cinfo.output_scanline;
jpeg_read_scanlines(&cinfo,&ligne,1);
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
// rearrangement de l'image scannee dans le tableau de texture 3D
// ici nous sommes en niveau de gris, donc on copie le meme octet dans
// chacune des 3 cases RGB
for (i=0;i<t_height;i++)
for (j=0;j<t_width;j++)
{
texture[i*t_width*3+j*3 ] = image_gris[i*t_width+j];
texture[i*t_width*3+j*3+1] = image_gris[i*t_width+j];
texture[i*t_width*3+j*3+2] = image_gris[i*t_width+j];
}
free(image_gris);
return texture;
}
}