View Full Version : questions about stencil buffer

07-25-2002, 01:30 AM
it is said in the redbook that this buffer can be used to have the same effects as a driving simulation ... the first question is why should you restrict drawing to certain portion of the screen and then draw the instruments and not directly draw the picture in the correct buffer ? Secondly, let's say i have made a mask for the stencil buffer, i have a picture of the instruments, where must i put it in ? in the stencil buffer? in the color buffer ?
It does not appear here, but it's a matter of life or dead ...
thanks for your answers.

07-25-2002, 02:35 AM
I have not read the redbook in years but I guess I can still comment. You may want to mask a potion of the viewport with the stencil to then draw the roads and everything you would see out the front windscreen. Using the stencil buffer here may be a waste of time depending on acceleration. Otherwise you can just render the world as seen outside then render overtop of that with no depth testing the cockpit of your car. This means there is no requirement for the stencil buffer.

The time that the stencil buffer may be required is when you want to draw the rear view mirror or the side mirrors. In this case you would draw out the front windshield and then you would introduce the stencil buffer to mask everything except the area visible at the rear view mirror. With this mask you can then move the camera position and render out the back of the car. This mask will ensure that areas that are not on the mirror will not be modified. Once you have rendered the mirror you can continue to draw the cockpit as I mentioned above.

You can look for examples of mirrors in many places and several use the stencil buffer to limit the rendering to the surface of the mirror.

Hope this helps,
Neil Witcomb

07-25-2002, 03:17 AM
OK this gives me some responses and i thanks you.
* So i should draw my instruments after drawing the 3d scene. But which buffer must receive my picture? Can i put it directly in the color buffer ?
* The second problem i have (now !!) is if the screen is reshaped, the picture will appear different ? (i have not tested it) Is there a solution with a mapping ?