-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Android NDK Game Development Cookbook
By :
Sometimes it is very convenient to be able to treat some arbitrary in-memory runtime generated data as if it were in a file. As an example, let's consider using a JPEG image downloaded from a photo hosting, as an OpenGL texture. We do not need to save it into the internal storage, as it is a waste of CPU time. We also do not want to write separate code for loading images from memory. Since we have our abstract iIStream and iRawFile interfaces, we just implement the latter to support memory blocks as the data source.
In the previous recipes, we already used the Blob class, which is a simple wrapper around a void* buffer.
Our iRawFile interface consists of two methods: GetFileData() and GetFileSize(). We just delegate these calls to an instance of Blob:
class ManagedMemRawFile: public iRawFile
{
public:
ManagedMemRawFile(): FBlob( NULL ) {}
virtual const ubyte* GetFileData() const
{ return ( const ubyte* )FBlob->GetData(); }
...
Change the font size
Change margin width
Change background colour