================== ImageFromFunction Images that are procedurally generated are allways specified with a callback which must work at any time, allowing the OpenGL system to be completely regenerated if needed. ================== */
| 1467 | ================== |
| 1468 | */ |
| 1469 | idImage *idImageManager::ImageFromFunction( const char *_name, void (*generatorFunction)( idImage *image ) ) { |
| 1470 | idStr name; |
| 1471 | idImage *image; |
| 1472 | int hash; |
| 1473 | |
| 1474 | if ( !name ) { |
| 1475 | common->FatalError( "idImageManager::ImageFromFunction: NULL name" ); |
| 1476 | } |
| 1477 | |
| 1478 | // strip any .tga file extensions from anywhere in the _name |
| 1479 | name = _name; |
| 1480 | name.Replace( ".tga", "" ); |
| 1481 | name.BackSlashesToSlashes(); |
| 1482 | |
| 1483 | // see if the image already exists |
| 1484 | hash = name.FileNameHash(); |
| 1485 | for ( image = imageHashTable[hash] ; image; image = image->hashNext ) { |
| 1486 | if ( name.Icmp( image->imgName ) == 0 ) { |
| 1487 | if ( image->generatorFunction != generatorFunction ) { |
| 1488 | common->DPrintf( "WARNING: reused image %s with mixed generators\n", name.c_str() ); |
| 1489 | } |
| 1490 | return image; |
| 1491 | } |
| 1492 | } |
| 1493 | |
| 1494 | // create the image and issue the callback |
| 1495 | image = AllocImage( name ); |
| 1496 | |
| 1497 | image->generatorFunction = generatorFunction; |
| 1498 | |
| 1499 | if ( image_preload.GetBool() ) { |
| 1500 | // check for precompressed, load is from the front end |
| 1501 | image->referencedOutsideLevelLoad = true; |
| 1502 | image->ActuallyLoadImage( true, false ); |
| 1503 | } |
| 1504 | |
| 1505 | return image; |
| 1506 | } |
| 1507 | |
| 1508 | /* |
| 1509 | =============== |
no test coverage detected