Making the scissor test a matrix transform

Toasty

Newcomer
In OpenGL architectures scissor testing is typically performed on a per-fragment basis. That's great if you have hardware that explicitly includes this functionality at no cost but sadly this is not the case for me.

What I'd like to do is support glScissor at the transform+clipping level. I figure that I can come up with a mechanism to generate a 4x4 transform matrix that is tacked on after the modelview and projection matrix transforms. This matrix will translate, zoom, and adjust the aspect ratio for the scene such that it fits precisely in the scissor box thus allowing the frustum clipper to effectively be my scissor test.

I'm going to sit down now and try and work out the math to do this, but I figured I should ask here first if: 1) is it actually possible? and 2) can you think of any scenarios where this would not be identical to a per-fragment scissor box test? I would like my implementation to be GL-conformant and I only need to support one scissor box.

Thanks,
-Toasty
 
Let's see .... the frustum clipping in OpenGL is specified to work by clipping the XYZ coordinates to the W coordinate after all matrix transforms have been completed. Given that the same W coordinate is then used to perform viewport transform (perspective division) afterwards, I don't see how playing tricks with the projection matrix vill affect frustum clipping.

If you want the frustum clipping to limit you to a region smaller than the whole screen, try fiddling around with glViewport() (which on its own will frustum clip polygons to a screen region correctly, but won't quite scissor points, wide lines, screen clears etc). BTW, what hardware are you using that doesn't support glScissor() natively??
 
Back
Top