MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ImageFromFunction

Method ImageFromFunction

neo/renderer/Image_init.cpp:1469–1506  ·  view source on GitHub ↗

================== 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. ================== */

Source from the content-addressed store, hash-verified

1467==================
1468*/
1469idImage *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===============

Callers 1

InitFromMegaFileMethod · 0.80

Calls 8

ReplaceMethod · 0.80
FileNameHashMethod · 0.80
ActuallyLoadImageMethod · 0.80
IcmpMethod · 0.60
FatalErrorMethod · 0.45
DPrintfMethod · 0.45
c_strMethod · 0.45
GetBoolMethod · 0.45

Tested by

no test coverage detected