Changeset 3605 in orxonox.OLD for orxonox/branches/levelloader/src/lib/graphics/importer/texture.cc
- Timestamp:
- Mar 18, 2005, 11:52:15 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/lib/graphics/importer/texture.cc
r3499 r3605 17 17 */ 18 18 19 20 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER 19 21 20 22 #include "texture.h" … … 87 89 if (pName[0] == '\0') 88 90 { 89 PRINTF( 3)("not Adding empty Path to the List.\n");91 PRINTF(2)("not Adding empty Path to the List.\n"); 90 92 return; 91 93 } … … 99 101 if (status.st_mode & S_IFDIR) 100 102 { 101 PRINTF( 2)("Adding Path %s to the PathList.\n", pName);103 PRINTF(4)("Adding Path %s to the PathList.\n", pName); 102 104 PathList* tmpPathList = this; 103 105 while (tmpPathList->next) … … 193 195 bool Texture::loadTexToGL (Image* pImage) 194 196 { 195 PRINTF( 2)("Loading texture to OpenGL-Environment.\n");197 PRINTF(4)("Loading texture to OpenGL-Environment.\n"); 196 198 glGenTextures(1, &this->texture); 197 199 glBindTexture(GL_TEXTURE_2D, this->texture); … … 229 231 pImage->format = GL_RGBA; 230 232 231 PRINTF(0)("Bits Per Pixel: %d\n", pImage->bpp);232 233 if( !IMG_isPNG(SDL_RWFromFile(imgNameWithPath, "rb")) && !IMG_isJPG(SDL_RWFromFile(imgNameWithPath, "rb"))) 233 234 for (int i=0;i<map->h * map->w *3;i+=3) … … 249 250 else 250 251 { 251 PRINTF( 1)("Image not Found: %s\n", imgNameWithPath);252 PRINTF(2)("Image not Found: %s\n", imgNameWithPath); 252 253 return false; 253 254 } … … 268 269 if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".bmp", 4)) 269 270 { 270 PRINTF( 3)("Requested bmp-image. Trying to Import.\n");271 PRINTF(4)("Requested bmp-image. Trying to Import.\n"); 271 272 return this->loadBMP(imgNameWithPath); 272 273 } … … 274 275 else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".jpg", 4) || !strncmp(imgNameWithPath+strlen(imgNameWithPath)-5, ".jpg", 5)) 275 276 { 276 PRINTF( 3)("Requested jpeg-image. Trying to Import\n");277 PRINTF(4)("Requested jpeg-image. Trying to Import\n"); 277 278 return this->loadJPG(imgNameWithPath); 278 279 } 279 280 else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".tga", 4)) 280 281 { 281 PRINTF( 3)("Requested tga-image. Trying to Import\n");282 PRINTF(4)("Requested tga-image. Trying to Import\n"); 282 283 return this->loadTGA(imgNameWithPath); 283 284 } 284 285 else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".png", 4)) 285 286 { 286 PRINTF( 3)("Requested png-image. Trying to Import\n");287 PRINTF(4)("Requested png-image. Trying to Import\n"); 287 288 return this->loadPNG(imgNameWithPath); 288 289 } 289 290 else 290 291 { 291 PRINTF( 1)("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imgNameWithPath);292 PRINTF(2)("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imgNameWithPath); 292 293 return false; 293 294 } … … 295 296 else 296 297 { 297 PRINTF( 1)("Image not Found: %s\n", imgNameWithPath);298 PRINTF(2)("Image not Found: %s\n", imgNameWithPath); 298 299 return false; 299 300 } … … 316 317 if ((file = fopen(bmpName, "rb"))==NULL) 317 318 { 318 PRINTF( 1)("File Not Found : %s\n",bmpName);319 PRINTF(2)("File Not Found : %s\n",bmpName); 319 320 return false; 320 321 } … … 325 326 if ((i = fread(&pImage->width, 4, 1, file)) != 1) 326 327 { 327 PRINTF( 1)("Error reading width from %s.\n", bmpName);328 PRINTF(2)("Error reading width from %s.\n", bmpName); 328 329 return false; 329 330 } … … 331 332 if ((i = fread(&pImage->height, 4, 1, file)) != 1) 332 333 { 333 PRINTF( 1)("Error reading height from %s.\n", bmpName);334 PRINTF(2)("Error reading height from %s.\n", bmpName); 334 335 return false; 335 336 } … … 341 342 if ((fread(&planes, 2, 1, file)) != 1) 342 343 { 343 PRINTF( 1)("Error reading planes from %s.\n", bmpName);344 PRINTF(2)("Error reading planes from %s.\n", bmpName); 344 345 return false; 345 346 } … … 353 354 if ((i = fread(&bpp, 2, 1, file)) != 1) 354 355 { 355 PRINTF( 1)("Error reading bpp from %s.\n", bmpName);356 PRINTF(2)("Error reading bpp from %s.\n", bmpName); 356 357 return false; 357 358 } 358 359 if (bpp != 24) 359 360 { 360 PRINTF( 1)("Bpp from %s is not 24: %u\n", bmpName, bpp);361 PRINTF(2)("Bpp from %s is not 24: %u\n", bmpName, bpp); 361 362 return false; 362 363 } … … 369 370 if (pImage->data == NULL) 370 371 { 371 PRINTF( 1)("Error allocating memory for color-corrected image data");372 PRINTF(2)("Error allocating memory for color-corrected image data"); 372 373 return false; 373 374 } … … 375 376 if ((i = fread(pImage->data, size, 1, file)) != 1) 376 377 { 377 PRINTF( 1)("Error reading image data from %s.\n", bmpName);378 PRINTF(2)("Error reading image data from %s.\n", bmpName); 378 379 return false; 379 380 } … … 418 419 { 419 420 // Display an error message saying the file was not found, then return NULL 420 PRINTF( 1)("Unable to load JPG File %s.\n", jpgName);421 PRINTF(2)("Unable to load JPG File %s.\n", jpgName); 421 422 return false; 422 423 } … … 521 522 if(fTGA == NULL) 522 523 { 523 PRINTF( 1)("Error could not open texture file: %s\n", tgaName);524 PRINTF(2)("Error could not open texture file: %s\n", tgaName); 524 525 return false; 525 526 } … … 527 528 if(fread(&tgaHeader, sizeof(TGAHeader), 1, fTGA) == 0) 528 529 { 529 PRINTF( 1)("Error could not read file header of %s\n", tgaName);530 PRINTF(2)("Error could not read file header of %s\n", tgaName); 530 531 if(fTGA != NULL) 531 532 { … … 549 550 else 550 551 { 551 PRINTF( 1)("Error TGA file be type 2 or type 10\n");552 PRINTF(2)("Error TGA file be type 2 or type 10\n"); 552 553 if (fTGA) 553 554 fclose(fTGA); … … 576 577 if(fread(header, sizeof(header), 1, fTGA) == 0) 577 578 { 578 PRINTF( 1)("Error could not read info header\n");579 PRINTF(2)("Error could not read info header\n"); 579 580 return false; 580 581 } … … 586 587 if((pImage->width <= 0) || (pImage->height <= 0) || ((pImage->bpp != 24) && (pImage->bpp !=32))) 587 588 { 588 PRINTF( 1)("Error invalid texture information\n");589 PRINTF(2)("Error invalid texture information\n"); 589 590 return false; 590 591 } … … 605 606 if(pImage->data == NULL) 606 607 { 607 PRINTF( 1)("Error could not allocate memory for image\n");608 PRINTF(2)("Error could not allocate memory for image\n"); 608 609 return false; 609 610 } … … 611 612 if(fread(pImage->data, 1, imageSize, fTGA) != imageSize) 612 613 { 613 PRINTF( 1)("Error could not read image data\n");614 PRINTF(2)("Error could not read image data\n"); 614 615 if(pImage->data != NULL) 615 616 { … … 648 649 if(fread(header, sizeof(header), 1, fTGA) == 0) 649 650 { 650 PRINTF( 1)("Error could not read info header\n");651 PRINTF(2)("Error could not read info header\n"); 651 652 return false; 652 653 } … … 664 665 if((pImage->width <= 0) || (pImage->height <= 0) || ((pImage->bpp != 24) && (pImage->bpp !=32))) 665 666 { 666 PRINTF( 1)("Error Invalid pImage information\n");667 PRINTF(2)("Error Invalid pImage information\n"); 667 668 return false; 668 669 } … … 674 675 if(pImage->data == NULL) 675 676 { 676 PRINTF( 1)("Error could not allocate memory for image\n");677 PRINTF(2)("Error could not allocate memory for image\n"); 677 678 return false; 678 679 } … … 684 685 if(fread(&chunkheader, sizeof(GLubyte), 1, fTGA) == 0) 685 686 { 686 PRINTF( 1)("Error could not read RLE header\n");687 PRINTF(2)("Error could not read RLE header\n"); 687 688 if(pImage->data != NULL) 688 689 { … … 702 703 if(fread(colorbuffer, 1, bytesPerPixel, fTGA) != bytesPerPixel) 703 704 { 704 PRINTF( 1)("Error could not read image data\n");705 PRINTF(2)("Error could not read image data\n"); 705 706 if(colorbuffer != NULL) 706 707 { … … 732 733 if(currentpixel > pixelcount) 733 734 { 734 PRINTF( 1)("Error too many pixels read\n");735 PRINTF(2)("Error too many pixels read\n"); 735 736 if(colorbuffer != NULL) 736 737 { … … 754 755 if(fread(colorbuffer, 1, bytesPerPixel, fTGA) != bytesPerPixel) // Attempt to read following color values 755 756 { 756 PRINTF( 1)("Error could not read from file");757 PRINTF(2)("Error could not read from file"); 757 758 if(colorbuffer != NULL) 758 759 { … … 785 786 if(currentpixel > pixelcount) 786 787 { 787 PRINTF( 1)("Error too many pixels read\n");788 PRINTF(2)("Error too many pixels read\n"); 788 789 if(colorbuffer != NULL) 789 790 {
Note: See TracChangeset
for help on using the changeset viewer.