Archived

This topic is now archived and is closed to further replies.

Prozak

Stencial Buffer - See it

Recommended Posts

wow... im also getting some strange results.
i implemented some stencil buffering, trying to get some
reflections working, and it worked on my desktop,
but not on my laptop.

I draw a pixel (pixel size =300) in the center of the
screen, and set the stencil buffer, then i draw the rest
of the scene, and the rest of the scene should be "stenciled"
only into the area the pixel occupied... on my laptop though,
the scene gets completely rendered...

[Hugo Ferreira][Positronic Dreams]
Need [3D Artist] & [Sound Designer]
for small project. Contact me plz...
[-NO TO WAR ON IRAQ-]

Share this post


Link to post
Share on other sites
ah! buggers!! the error on the laptop was mine
(it allways ends up being our mistake, right?)
the fact is that the 400 sized pixel i draw in my
desktop is not the same size in the laptop.
on the desktop the pixel ocupies a 10th of the width
of the window, while on the laptop it ocuppies half!
diferent pixel sizes? how do i fix this?

also, no one has answered my question on how to see
the stencil buffer....

as a side question, how do i capture the data in the
frame buffer, so that i can send it to a screenshot
for example...?

[Hugo Ferreira][Positronic Dreams]
Need [3D Artist] & [Sound Designer]
for small project. Contact me plz...
[-NO TO WAR ON IRAQ-]

Share this post


Link to post
Share on other sites
I think you need to use glFrustrum instead of gluPerspective. gluPerspective calculates left/right and top/bottom based upon your field of view, znear and viewport. The result is that things stay the same size as the viewport changes. So when the viewport gets smaller a given object takes up more of the viewport because it didn''t get smaller.

Share this post


Link to post
Share on other sites
How to make stencil buffer visible:

if you''ve got an NVIDIA card, you can use the NV_copy_depth_to_color extension, which lets you do

glCopyPixels( 0, 0, width, height, DEPTH_STENCIL_TO_RGBA_NV )

which will copy your depth and stencil buffers into the color buffer. You might need to mess around with pixel transfer operations to mask off the depth and put the stencil bits in the color you want.

A more portable way would be to do a glReadPixels( ..., GL_STENCIL_INDEX ) then draw the data you grabbed back into the color buffer with glDrawPixels( ..., GL_LUMINANCE )

A third way would be to clear the color buffer and depth buffer (but not stencil) then draw a quad over the whole screen using glStencilFunc( GL_GREATER, 0, 0 );
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );

Then you''d see the color of your quad wherever the stencil was non-zero. That method is only binary tho, where the previous method would show an 8-bit range...

Share this post


Link to post
Share on other sites