Here is a problem to solve : how can you highlight surfaces where textures didn't load properly (missing file, read error...)?
My first answer was to create a ReadFileCallback, and make readImage() encapsulate "default" call. If call fails, then I return a "dummy" image (1x1 pixel, flashy color, such as magenta).
However this doesn't work, as readers may call readImageFile() multiple times. Ex:
image = readImageFile(path1);
if (!image) readImageFile(path2);
if (!image) etc...
In my case, readImageFile(path1) returns either the normal image, or the dummy one (path2 is never tested).
I propose to add some stuff to allow a ReadFileCallback to know a bit more about where the caller is. I'd like to know if you have any idea... Here are mine :
1. In all readers, call readImageFile("") in the last case (or another method such as "Registry::readImageFileFailed()"), so that ReadFileCallback knows all other calls failed. Just ugly, I think.
2. In all readers, add something in the osgDB::Options structure in their last call, for the same purpose. Ugly too.
3. Change readImageFile() / ReadFileCallback to pass an additional parameter. Very ulgy!
4. In all readers, add a ValueObject (or something else) to record the fact loading failed. This would allow post-load code to detect this info.
As you can see, I got no "clean" idea. Please help !
osg-users mailing list