Game Development Reference
In-Depth Information
sImageDescriptor():
FState(L_NOTSTARTED),
FSize(L_PHOTO_SIZE_256)
{
FTexture = new clGLTexture();
}
void StartDownload( bool AsFullSize );
void ImageDownloaded( clPtr<Blob> Blob );
void UpdateTexture();
};
4.
The image state can be one of the following:
enum LImageState
{
L_NOTSTARTED, // not started downloading
L_LOADING, // download is in progress
L_LOADED, // loading is finished
L_ERROR // error occured
};
5.
After the download has completed, we asynchronously load the image from the data
blob using the FreeImage library:
void sImageDescriptor::ImageDownloaded( clPtr<clBlob> B )
{
if ( !B )
{
FState = L_ERROR;
return;
}
clPtr<clImageLoadingCompleteCallback> CB =
new clImageLoadingComplete( this );
clPtr<clImageLoadTask> LoadTask =
new clImageLoadTask( B, 0, CB,
g_Events.GetInternalPtr() );
g_Loader->AddTask( LoadTask );
}
6.
Asynchronous loading is important, since the image decoding can be quite slow,
and can interfere with the user experience of the game. After an image has been
loaded and converted into a clBitmap , we should update the texture. Texture
updates are done synchronously on the OpenGL rendering thread:
void sImageDescriptor::UpdateTexture()
{
this->FState = L_LOADED;
FTexture->LoadFromBitmap( FNewBitmap );
}
 
Search WWH ::




Custom Search