PDA

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



helenw
01-30-2007, 06: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?

thanks

jacky_romano
02-01-2007, 10: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.
Thanks,
Jacky

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