View Full Version : draw many objects with a region no shown/drawn

01-30-2007, 05:45 PM
Dear my teachers

I want to draw many objects like rivers and roads with a region no drawn.
For example, some objects or parts of them inside a rectangle region can't be shown, while others outside the rectangle will be showing.

I try do it with glClipPlane(). But it cuts the half-space of model, not a region.

How do I do?


02-01-2007, 09:59 AM
Stencil is what you are looking for.
Basically you mark the stencil buffer with the pixels that you want to draw/not-draw on. This is done by rendering the regions with glColorMask(FALSE,FALSE,FALSE) and approriate combination of glStencilOp/glStencilFunc.
Then you switch to glColorMask(TRUE, TRUE, TRUE),
select the glStencilFunc/glStencilOp to select the pixels you want to render on and render your scene(rivers and roads).

Check the chapter in the red-book for the details.

02-01-2007, 10:59 PM
I would just render some polygons at the near plane so that they occlude everything behind them.