Game Development Reference
In-Depth Information
2.
Image dimensions and raw pixel data are set as follows:
int FWidth;
int FHeight;
3.
Here we use a C-style array:
ubyte* FBitmapData;
};
The
read_bmp_mem()
function from
Chapter 2
,
Porting Common Libraries,
is used
once again, but this time the memory buffer comes from an
iIStream
object.
In
Chapter 6
,
Unifying OpenGL ES 3 and OpenGL 3
we add the
Texture
class to
handle all of the OpenGL complexities, but right now we simply render the instance
of a
Bitmap
class.
4.
Next, we implement the asynchronous loading operation:
class LoadOp_Image: public iTask
{
public:
LoadOp_Image( clPtr<Bitmap> Bmp, clPtr<iIStream> IStream ):
FBmp( Bmp ), FStream( IStream ) {}
virtual void Run()
{
FBmp->Load2DImage( FStream );
g_Events->EnqueueCapsule(
new LoadCompleteCapsule(FBmp) );
}
private:
clPtr<Bitmap> FBmp;
clPtr<iIStream> FStream;
};
5.
The
LoadCompleteCapsule
class is a
iAsyncCapsule
-derived class that has the
overriden
Run()
method:
class LoadCompleteCapsule: public iAsyncCapsule
{
public:
LoadCompleteCapsule(clPtr<Bitmap> Bmp): FBmp(Bmp) {}
virtual void Invoke()
{
// … copy FBmp to g_FrameBuffer …
}