Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Salve ragazzi ho un problema con questo sorgente.. si tratta di un esercizio per imparare a gestire le texture di opengl. Voglio disegnare una sfera e con con una texture mapping della terra farla ruotare.. per poi aggiungere gli altri pianeti e simulare il sistema solare:
Questo è il codice
unsignedshortint planes;// number of planes in image (must be 1)
unsignedshortint bpp;// number of bits per pixel (must be 24)
unsignedchar temp;// used to convert bgr to rgb color.
// Make sure the file exists
if((file =fopen(filename, "rb"))==NULL){
printf("File Not Found : %s\n", filename);
return0;
}
// Skip to bmp header
fseek(file, 18, SEEK_CUR);
// read width
if((i =fread(&image->sizeX, 4, 1, file))!= 1){
printf("Error reading width from %s.\n", filename);
fclose(file);
return0;
}
printf("Width of %s: %lu\n", filename, image->sizeX);
//read the height
if((i =fread(&image->sizeY, 4, 1, file))!= 1){
printf("Error reading height from %s.\n", filename);
fclose(file);
return0;
}
printf("Height of %s: %lu\n", filename, image->sizeY);
// calculate the size (assuming 24 bpp)
size = image->sizeX * image->sizeY *3;
// read the planes
if((fread(&planes, 2, 1, file))!= 1){
printf("Error reading planes from %s. \n", filename);
fclose(file);
return0;
}
if(planes != 1){
printf("Planes from %s is not 1: %u\n", filename, planes);
fclose(file);
return0;
}
// read the bpp
if((i =fread(&bpp, 2, 1, file))!= 1){
printf("Error reading bpp from %s. \n", filename);
fclose(file);
return0;
}
if(bpp != 24){
printf("Bpp from %s is not 24: %u\n", filename, bpp);
fclose(file);
return0;
}
// seek past the rest of the bitmap header
fseek(file, 24, SEEK_CUR);
// Read the data
image->data =(unsignedchar*)malloc(size);
if(image->data ==NULL){
printf("Error allocating memory for colour-corrected image data");
fclose(file);
return0;
}
if((i =fread(image->data, size, 1, file))!= 1){
printf("Error reading image data from %s.\n", filename);
fclose(file);
return0;
}
fclose(file);
return1;
}
Non capisco dove sbaglio ... perchè la sfera ruota e la texture non resta attaccata, se qualcuno di voi conosce l'argomento vorrei che mi indicasse dove sbaglio per favore.
Ultima modifica effettuata da Bonny il 14/12/2012 alle 20:42