PocketMatrix forums

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

Surfaces and blitting

How can I blit multiple Surfaces onto a single Surface and then blit that single Surface to the display?

I need to build up a Surface consisting of various resources then rotate that entire surface and blit it to the display.
Can I do this? If so how. If not, any other suggestions as to how I could accomplish the same result?

Thankyou.
yeatd,

You need to attach a rasterizer to your surface, and then you can blit to it.

Code:

// Declarations
Surface *pMyScreen, *pSplash;
Rasterizer *pRaster;
DisplayDevice *pDisplay = GetDisplay();

// Create YOUR Screen and Attach Rasterizer
pMyScreen = pDisplay->CreateSurface(screenWidth, screenHeight);
pRaster = pDisplay->CreateRasterizer(pMyScreen);

// Load Images
pSplash = Frog::LoadImage(pDisplay, IDR_ISPLASH);

// Blit the Images to YOUR Screen
pRaster->Blit(xOffset+0, yOffset+0, pSplash);

// When Ready, Blit YOUR Screen to the Main Display
pDisplay->Blit(0, 0, pMyScreen);
pDisplay->Update();


-John
Great thats exactly what I need! I'll give it a try.
Thanks John :D
Alternatively, call the SetTarget method of the DisplayDevice, passing it your Surface, then reset it to it's default to blit your Surface.

Not sure if there's an advantage to either approach, although in my mind the code is clearer when I'm just changing the render target.
Hehe. I never tried that. Sounds too easy though.
:lol:

-John
2 things...

what does the code look like to restore the displays render target the default?

if you can use BlitTransform or something like that to display images in creative ways - blitting twice (esp if rotating or stretching) can be real slow. i tried it, im working on blitting rotated around a point (just a little trig, just gotta get around to it)
what does the code look like to restore the displays render target the default?

You call SetRenderTarget(0) or SetRenderTarget(NULL) to restore rendering to the backbuffer.

Remember that SetRenderTarget() will return the old rendering target Surface, so this can be used if switching between targets.

if you can use BlitTransform or something like that to display images in creative ways - blitting twice (esp if rotating or stretching) can be real slow.

Yes.. We've had this discussion before and ultimately the combined rotater and blitter should only blit ONCE using BlitTransform with a combined transform matrix. It's just that noone has taken the time to do this.