How can I draw a wirecube without showing the lines not visible?

Draw a solid cube with glPolygonMode set to GL_LINE. This will draw the edges if the primitives only, resulting in a wire cube. And since a cube is a convex object, you can enable backface culling to remove hidden lines.