PocketMatrix forums

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

Render into surface

is it possible to render into surface using PF? I want to do some postprocess on frame before blitting it into Display.
you need SetRenderTarget :-
Code:
// Create a new surface to hold our stretched image
Surface* stretch_surface = display->CreateSurface(stretch_xsize, stretch_ysize);

// Change rendering target from screen to our surface
Surface* screen = display->SetRenderTarget(stretch_surface);
Thanks!!! :D
Actually, you have another option as well...

Rasterizer * ir = display->CreateRasterizer(scaledimg);

The thing I found was that using the other method will mess with the settings you've done to the display (like clipping). Not a problem if you do all the blitting to the surface before you start blitting to the screen, but the way I'm using it, they happen at the same time.
I can use setrendertarget to render the content of an existing surface to another one...
I would like to make a fade effect to mix the content of the current BACKBUFFER, but using PHAL I can't copy the backbuffer's content to a fading surface...

It worked in PF7. Should I query for the frontbuffer instead? :roll:

Code:

sURFACE* m_Fade=display->CreateSurface(AppW,AppH);
display->SetRenderTarget(m_Fade);
display->Blit(0,0,display->GetBackBuffer(),&Rect;( 0, 0, AppW,AppH));
display->SetRenderTarget(0);
That reminded me to ask a related question...

In PF0.7, I used
Surface * fbt = display->GetFrontBuffer();

to grab the entire screen before the app drew anything - in order to make a splashscreen effect.

In PF0.8, this doesn't work. Is there any way to get the current image of the PPC. It's not really needed, but allows some neat tricks to be done...
KempoKing wrote:I would like to make a fade effect to mix the content of the current BACKBUFFER, but using PHAL I can't copy the backbuffer's content to a fading surface...


You sure can. Specify SWAP_COPY when initializing the display and the backbuffer content will be kept between calls to Swap(). You will then be able to apply any effect you want to the backbuffer.
fast_rx wrote:That reminded me to ask a related question...

In PF0.7, I used
Surface * fbt = display->GetFrontBuffer();

to grab the entire screen before the app drew anything - in order to make a splashscreen effect.

In PF0.8, this doesn't work. Is there any way to get the current image of the PPC. It's not really needed, but allows some neat tricks to be done...


It's unfortunately not possible to access the front buffer with PocketHAL. But here is a nifty trick you can use that should work:

1) Create a PocketHAL GDISurface with the same dimensions as the display.
2) Grab the screen's DC and blit the desktop to your GDISurface. (That's using Win32's BitBlt).
3) Initialize PocketHAL.

You now have the content of the desktop in your GDISurface and you can use it for any effect you want.
Thanks Thierry... that worked.

In case anyone else is wondering exactly how:

Code:

screen = display->CreateSurface(display->GetWidth(), display->GetHeight());


HWND hwnd = GetDesktopWindow();
HDC hdc = ::GetWindowDC(hwnd); //or GetDC() ...

HDC screenHDC = screen->GetDC();

//fix for height of menubar
RECT r;
GetWindowRect(hwnd, &r);

int mbheight = (r.bottom - r.top) - display->GetHeight();

BitBlt(screenHDC, 0,0, display->GetWidth(), display->GetHeight(), hdc, 0, mbheight, SRCCOPY);

screen->ReleaseDC(screenHDC);

::ReleaseDC(hwnd, hdc);


That gets a copy of your desktop into the surface 'screen'

I had never noticed that GetDC() function in PF before.