PocketMatrix forums

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

SetRenderTarget help

Hi,

I am trying to create a new surface, paint stuff to it but other than the Clear(), all rasterizer functions don't work.

Code:
Frog::Surface *b = m_display->CreateSurface(w, h);
Frog::Rasterizer *r = m_display->CreateRasterizer(b);

//Frog::Surface* olddisplay = m_rast->SetRenderTarget(b);

r->Clear(Frog::Color(255, 0, 255));
f->Write(b, r, 0, 0, text);
r->FillRect(10, 10, 120, 20, 0);

//m_rast->SetRenderTarget(olddisplay);


I've tried both ways, SetRenderTarget() and by creating a new rasterizer.

The new surface is cleared with fuschia color correctly, but FillRect() doesn't work.

What am I doing wrong?
What is

f->Write(b, r, 0, 0, text);

Is that doing something that would mess up the rasterizer or is it a typo?


BTW, you need to delete the rasterizer after you're done.
Hi,

f->Write could be commented out it is calling a font drawing routine.

Only the Clear() works, other than that DrawRect, FillRect, nothing works.

I get a surface in fuschia but nothing else can be done to it.
'could' be? Have you tried it?

Just thinking that accessing b while you're trying to render to it may be doing something.

I assume that you're checking that m_display is valid when you called getDisplay?
Yes I did comment out that line.

I can get it to clear with any color properly using Clear() however anything else I try to do to the surface after is not rendered. m_display is valid.
Any idea why only the Clear would work but not the other functions?
What happens if you clear twice? Just wondering if the problem is with all functions except clear - or all funtions besides the first...
Hi,

I got it. I saved the surface to disk to check and everything is drawn to the surface. It looks like it is when I assign the surface to my sprite.

So it was my fault all the way. Of course! ;)

Thanks for your time.