How to modify z-values in depths buffer using OpenGL function

How to modify z-values in z buffer using OpenGL function? I want to modify the values in depths buffer to change the hiding relationships, such as rendering polygons object and volume objects

u can write into the depth buffer by using
glDepthFunc( GL_ALWAYS );
this will replace whatever depth values are already there with the new ones.
use glColorMask(0,0,0,0); + draw the new polygons into the scene, they wont show up but there depth values will. another method is using glDrawPixels( … , GL_DEPTH_COMPONENT )

I had written codes before as follows:
glRasterPos2i(0,0);
glDrawPixels(m_DibWidth,m_DibHeight,GL_DEPTH_COMPONENT,GL_FLOAT,m_pDepths);
glFinish();
glCallList(1000);
glFinish();
But,it seems to have no effects. Can you give me more detailed infomation about this codes?thanks!

BTW take a look at this sample ( works on windows) http://www.delphi3d.net/download/bufferregion.zip

this sample writes to depth buffer …
and performs its update while objects move over backgroud.

though it is on delphi but opengl calls
read quite well…

there are quite a bit of other approaches I might think of for ex using

depth texture and shadow texture extension
(the last allows depth comparisons)

or using shaders ( the same way as directx has texm3x2depth or texdepth instructions… though there are no direct analogues in opengl but there are other means ask others …) for ex
as far as I know upcoming GeforceFx will directly support depth amanipulation instructions in OpenGl
(NV_fragment_program extension).

Originally posted by yfn:
I had written codes before as follows:
glRasterPos2i(0,0);

Most likely your raster position fell out of the view volume und got marked invalid.

Raster positions go through the same transformations as vertices. So you need the coordinate of a vertex that lies exactly at the bottom left corner of your screen and supply that to glRasterPos3f.

Another problem is that raster positions are ‘marked invalid’ when they’re outside of the view volume - even a tiny bit. If you call DrawPixels with an invalid raster pos, nothing is drawn, no clipping or anything, just nothing.

That’s lined out in the ‘Avoiding 16 common pitfalls’ document somewhere on the main site btw

Two ways to do better:
1)Use the ARB_window_pos extension whenever available. It lets you specify coords in window space, so it’s much easier and more intuitive to use. In your example you could simply replace with glWindowPos2iARB(0,0) and it would already work.

2)Load the identity matrix to both modelview and projection. Then you can use glRasterPos2f(-0.5f,-0.5f) (or something really close to that …) and glDrawPixels.

[This message has been edited by zeckensack (edited 11-21-2002).]

Thanks zed,SergeVrt,zeckensack for heartily replying my question.

I just have solved the problem.I use this techniques to reseach on virtual endoscopy in which there are volume objects and traditional geometry polygon objects. If some of you are now or past engaged in reseach on VE, I want to discuss with these people.
thanks!