Faces in (VtkViewer or Viewer) OpenGl appear transparent

When using the VtkViewer or Viewer from compas.viewers, you may find that some faces appear transparent when viewing your model, such as in the example below.

Notice how the faces of the cubes are not showing over the two larger faces behind (see below for the correct view). This is an OpenGL technicality that depends on the drivers you are using for your graphics device that is displaying the viewer. In newer graphics drivers, faces that are closer to the camera will automatically be taken as the faces to display. This is called depth testing, and if this is not supported, for example in the above image where a laptop’s CPU graphics hardware is being used, then the faces that were drawn last will be assumed to be the closest to the camera.

Note that for laptops, which often use CPU integrated graphics for many tasks to save battery power, the incorrect result can often occur. If your laptop of desktop uses a discrete graphics card or an integrated CPU graphics device with supported OpenGL driver features. Then the correct view below will be displayed.