Question about setClipRect

I'm reading through the C API documentation and I see that there exists a command for setting a clipping rectangle:


"Sets the current clip rect, using world coordinates—​that is, the given rectangle will be translated by the current drawing offset. The clip rect is cleared at the beginning of each update."

However, I can't seem to get it to work. I have been tinkering with the Hello World example program, with my main goal being only updating the parts of the screen strictly necessary for drawing the moving text. I can accomplish this with a filled rectangle:

int clearRectPadding = 2;
pd->graphics->fillRect(x - clearRectPadding, y - clearRectPadding, TEXT_WIDTH + clearRectPadding * 2, TEXT_HEIGHT + clearRectPadding * 2, kColorWhite);

However, I have not been able to get this to work with the setClippingRect function. Can someone point me to a C example where someone has gotten this to work for them?

The function seems to behave properly for me.

This is how I used it in the Hello World example

pd->graphics->setClipRect(20, 20, 360, 200)
pd->graphics->drawText(Hello World!, strlen(Hello World!), kASCIIEncoding, x, y);

But I am not sure I understand what you try to achieve. Do you want to avoid redrawing the fullscreen for every update? if that the case I would encourage you to look into the sprite system in the SDK which handle already all that part.