Added initial loading progress dialog.

This commit is contained in:
David Williams 2009-06-18 21:56:21 +00:00
parent b4d9351f1b
commit 5e2b8156c9
2 changed files with 15 additions and 3 deletions

View File

@ -33,7 +33,7 @@ namespace PolyVox
POLYVOXUTIL_API Volume<uint8_t>* loadVolumeRaw(std::istream& stream);
POLYVOXUTIL_API void saveVolumeRaw(std::ostream& stream, Volume<uint8_t>& volume);
POLYVOXUTIL_API Volume<uint8_t>* loadVolumeRle(std::istream& stream);
POLYVOXUTIL_API Volume<uint8_t>* loadVolumeRle(std::istream& stream, void (*pCallback)(float) = 0);
POLYVOXUTIL_API void saveVolumeRle(std::ostream& stream, Volume<uint8_t>& volume);
}

View File

@ -78,7 +78,7 @@ namespace PolyVox
//Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller.
//FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow
Volume<uint8_t>* loadVolumeRle(istream& stream)
Volume<uint8_t>* loadVolumeRle(istream& stream, void (*pCallback)(float))
{
//Read volume dimensions
uint8_t volumeWidthPower = 0;
@ -103,6 +103,13 @@ namespace PolyVox
stream.read(reinterpret_cast<char*>(&runLength), sizeof(runLength));
for(uint16_t z = 0; z < volumeDepth; ++z)
{
//Update progress once per slice.
if(pCallback)
{
float fProgress = static_cast<float>(z) / static_cast<float>(volumeDepth);
pCallback(fProgress);
}
for(uint16_t y = 0; y < volumeHeight; ++y)
{
for(uint16_t x = 0; x < volumeWidth; ++x)
@ -121,9 +128,14 @@ namespace PolyVox
runLength--;
}
}
}
}
}
//Finished
if(pCallback)
{
pCallback(1.0f);
}
return volume;
}