I'm not quite sure if "backface-culling" even makes much sense for edges, so I guess Pixel_Outlaw doesn't want backface-culling but
hidden line removal which is quite expensive for complex meshes.
The most gpu-oriented way is drawing solid polygons first (which means filling the zbuffer) and, in a second pass, drawing the lines with
z-testing set to "less or equal".
To sort out z-fighting (eg if you're using
bigger and/or
anti-aliased lines) you'd use a small amount of
polygon offset.
Alternatively, and if you want to have a look into shaders, you can store the normal-vectors of your geometry in the framebuffer (
example) and apply a
sobel filter.
If you're using lines make sure you're drawing each edge only once: If you're simply drawing every edge of every triangle you're effectively drawing every edge twice because each (non-boundary) edge is shared by two neighbouring triangles.
Edit:
Ok, for a cube it's all a bit simpler but requires some thoughts about data-structures to work efficiently.
You could store the normals of the two adjacent faces for each edge,
manually transform the z-value of both normals with the 3x3-part of the modelview- (aka
normal-) matrix (or get the camera-position into object space),
the transformed z-component of the face-normal tells if the face is pointing to (>0) or away (<0) of the viewer,
if one (or both) z are positive, the edge is visible (otherwise hidden).
This is ideally done by a vertex shader.
Then again you probably want many cubes occluding each other (where you're back at the zbuffer approach)...