ortho+perspective : depth problems

i have a scene where my terrain is being generated and being displayed as a 2d textue of the framebuffer, which i display in a ortho mode. then sometimes i need to draw a 3d grid in perspective. everythin works fine. the 2d image is at the back and my 3d grid comes up, but now the problem is that the 3d grid is appearing over the 2dimage. i want a part of the grid over the image and the remaining at the back(hidden), but this is not possible with what i have right now. is there anyway i can do it?


If you also generate a depth buffer for your terrain you could try writing it into video memory with glDrawPixels, but it’ll be very slow.

A better idea could be drawing the grid in software too as it’s propably pretty fast and then you could maybe get it occluded by the terrain.

But in the end… Is it really worth it to draw the terrain the way you’re drawing? It’ll propably keep causing unnecessary problems. Voxels were impressive back in the 90’s, but today you can get at least as good quality with polygons, without the limitations and problems. The classic voxel algorithm (if that’s even what you’re doing) can be mapped to hardware which would solve your problem too, but it’ll still be limited.


does this statement write the data into the depthbuffer?
glDrawPixels intWidth, intHeight, pfDepthComponent, pxlFloat, sngDepthBuffer(0)