How to back-Culling in wireframe mode between meshes?

I have a problem with back-culling in wireframe between meshes. This is I can do in opengl:

But I want to like below:

Any suggestion?
Thanks for help!

Do a depth-only render with the objects being solid. You might need to add some depth-bias to the wireframe pass afterwards.

Or draw your geometry with special shader that emulates wireframe mode.

see this:

NVIDIA provided DirectX source code. Porting to OpenGL is trivial. Work pretty well for me.
The paper looks quite complicated but in the end it is just a few lines of code in geometry and fragment shader.