Fast clipping without clearing stencil buffer I'm writing an OpenGL application that runs on a Raspberry Pi, i.e., a quite resource-limited system. Essentially, a few quads with RGBA textures are overlayed/alpha blended on top of each other with individual translation/rotation applied. They are clipped against an unrotated rectangle.

For this purpose, I currently use the stencil buffer. I.e., when drawing a texture which requires clipping, I clear the stencil buffer, render the clipping quad to the stencil buffer and enable the stencil testing before rendering the translated/rotated object.

On a Pi, clearing the stencil buffer is a painfully slow process in the order of 20ms, completely ruining performace. I thought about pre-rending the clipping rects to different bits of the stencil buffer, but that would lead to a maximum of 8 clipping regions (I need more).

Therefore, is there a different way of achieving clipping against a simple rectangle that does not require an expensive operation such as flushing the stencil buffer?
It sounds like what you need is a scissor test. It's specifically designed for clipping against an unrotated rectangle, and should be faster than messing about with the stencil buffer.