Game Development Reference
In-Depth Information
14. Once the image loading is complete, the task dispatches a
clBitmap::Load2DImage() call to the main thread, so that the OpenGL texture
can be updated:
class clImageLoadTask: public iTask
{
public:
virtual void Run()
{
clPtr<ImageLoadTask> Guard( this );
clPtr<iIStream> In = (FSourceStream == NULL) ?
g_FS->ReaderFromBlob( FSource ) : FSourceStream;
FResult = new clBitmap();
FResult->Load2DImage(In, true);
if ( FCallback )
{
FCallback->FTaskID = GetTaskID();
FCallback->FResult = FResult;
FCallback->FTask = this;
FCallbackQueue->EnqueueCapsule( FCallback );
FCallback = NULL;
}
}
};
The complete source code can be found in the 5_Puzzle project.
How it works…
The downloading is performed in the global g_Downloader object, and the actual decoding
of the downloaded data is done using the FreeImage library.
See also
F Chapter 3 , Networking
Implementing the complete picture-puzzle
game
Finally, we have all the parts at hand, and can combine them together into a puzzle
game application.
 
Search WWH ::




Custom Search