PocketMatrix forums

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

About clipping

Well, as I understand, PHAL is going to do somthing with sprite, which goes outside the screen area, until clipping area is set.
I have many sprite (bullets, spells, ect.) which isn't bound to cells, so I can say if there is need to draw sprite until I check it coordinates (which is "rect in rect check" - to many "if", no good).
So what PHAL does, when drawing such sprite (is PHAL realy draws it?), and what would be faster - check sprite or just draw it?
First, PHAL does the final draw to the screen. It's PF that draws all the individual elements to the backbuffer, which is where you'll find the code that checks clipping areas. Having looked at that code, it really depends on just how many Blits you plan on doing. If it's not too many, it's probably faster (and certainly easier) to just tell it to do the Blit, and it'll ignore anything that's outside the clipping rectangle. If you have a large number of objects, however, and you have a way of filtering out several at a time, you probably should have your own code filter them out. For example, if you have a huge tiled background, say 50x50 tiles. That's 2500 if-checks, each of which includes calls to GetWidth() and GetHeight(). Just ignoring the ones that you know for sure won't be onscreen would save a good bit of processing.

-John
Thanks for explanation.