PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

ceating a surface just once

Hello,

I my game I have always the same background image. but I need to display it in every ProcessNextFrame.

As creating this surface takes 40ms on my device, I'd like to create it once on start up and then blitting it to the backbuffer every time I need.

But it doesn't work if I don't create the surface right before blitting it...

the code :

Code:
virtual HRESULT ProcessNextFrame(CGapiSurface& backbuffer, DWORD dwFlags)
{
BackGround.CreateSurface(GDSURFACE_CLEAR, m_config.hInstance, IDB_FOND,NULL);
backbuffer.BltFast(0, 0, &BackGround;, 0, 0, 0);
[...]
}
I can't really see why it does not work. The only thing you should do is create your background image in the CreateSurfaces section of CGapiApplication and do a BltFast in the ProcessNextFrame. One thing, you also want to make sure that the CGapiSurface you created can be seen from both sections.
Make it a global and try it. It sounds like you have a problem with scope.
Transfer this to CreateSurface() function so you dont need to reload the image.

BackGround.CreateSurface // move this line.
You really should check the return codes of all your calls.

Check the return codes! Make a log! ASSERT()!

--Eric