PocketMatrix forums

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

Clipping !!!!

Quick question. How come there are no support for cliping of lines, Rect, FilledRect, SetPixel(s) and DrawText ?

(Not even considering Blt here)...

Will this be part of the next release ?

Would be nice to be able to use negative coordinates so you can have things slide into from the left side !!!

-Sam
PocketFrog is an alternative to GapiDraw that features clipping on all primitives. If you want to know how it's done, take a look at the source code.

Clipping is easy to implement but can have a performance impact when implemented in a low-level library. This is probably the reason it's not in GapiDraw and is also the reason it can be disabled in PocketFrog.
I know that clipping is easy to implement... Specially on simple primitives...

But lines are more tricky, but not impossible of course.

DrawText is more difficult of course, drawing to a surface and then draw an area from it to the back buffer...

Just think that things like this should be part of GapiDraw.
Hi Sam,

Clipping will not be included in GapiDraw. You will have to manage this by yourself.

As Thierry said, clipping is really simple to implement on all primitives such as rectangles (and blits), pixels and text (in most cases you draw to a separate surface first anyways for performance reasons - this will be especially true with the upcoming hardware surface support). It is however difficult to implement correctly on lines, and credits to Thierry for publishing his source code on how to do this in PocketFrog! There are also several sites on the 'net that illustrates how to do this as well.

The main reason it will not be implemented is:
(1) It is really simple to do
(2) You get an error if you try to draw something off-screen that should not be drawn clipped.
(3) For full DirectDraw compatibility, (unsigned) DWORDs had to be used for all coordinates. This sadly prevents using negative coordinates.

If you browse the forum you will also find lots of clipping code you can use for rectangles.

/Johan
Okay. I get it :) I have implemented various clipping before (also on lines) so here we go again. But might have a look at Thierry's code for line clipping (if there are line support).

I will implement the wrappers for it (as I do anyway), that can take care of clipping.

Actually I miss completly that DWORDs are unsigned :(

Anyway, keep up the good work.