ray casting and calculate depth value

Hi,
now I use ray casting algorithm do volume rendering.And I need draw a object(some lines) in fixed pipeline.I hope the lines can display correct.like the follow image
[ATTACH=CONFIG]1058[/ATTACH]
.It seems I need calculate depth value in fragment shader,any one can tell me how to do it?thanks