Full window stereo.

R. Rodriguez, G. Chinea, N. Lopez,
Centre for Genetic Engineering and Biotechnology, Havana, Cuba.
G. Vriend.
BIOcomputing, EMBL, Heidelberg, Germany


Visualisation is the bioinformaticist's most important tool for the study of macro molecules, and the possibility to see molecules in stereo is a very crucial aspect. Stereo vision is based on the principle that each eye gets presented as good as possible what it would have seen if the object was really there in 3D. The simplest approach to stereo vision is to put the right eye picture at the right half of the screen and the left eye picture at the left half while using a mirror system to ensure that each eye sees what it is supposed to see. More expensive workstations use hardware to alternately display the left and right eye picture while synchronously blocking the right and left lens' transparency of special glasses.

We present here some simple software that uses cheap hardware, originally designed for the game computer industry, to make full screen stereo available on Linux based PCs. The quality of the stereo vision is similar to the top of the line graphics workstations that are capable of quad-buffering. This stereo option has been incorporated in the X11 based version of WHAT IF [1], but the stereo source code is freely available and can easily be incorporated in other visualisation packages.


The human brain can study the invisible and untouchable by making mental, physical or pictorial models. This is true for almost every field of science and a series of Nobel prizes has been awarded for studies that converted a complicated, seemingly intangible object or idea into a visible model. Hundreds of software packages for the in silico study of macromolecules are available, and each of these packages has its own special features aiming to reduce nature's complexity by mapping it on one visible model or another. Some of these visualisation modes seem to be very well suited for the human brain and became extremely successful. Examples are the chicken wire representation of electron density, the electrostatic surfaces in GRASP [2] , and the ribbon and spiral diagrams introduced by Richardson [3] .

The most successful visualisation trick is undoubtedly stereo viewing. Not only does stereo vision give us an extra dimension so that more information can be represented (and understood!) in one picture, a stereo model of a molecule is also one dimension closer to reality than a 2D picture.

Figure 1. Principle of stereo vision.

The two eyes, represented by circles, see the boldface pyramid from a different location. The two small pyramids represent what the two eyes see. For stereo vision, the graphics system should present each of the two small pyramids to the corresponding eye.

The principle of stereo viewing is trivial (see figure 1 ). The left and right eye see an object from positions about six centimetres apart, and the brain combines these two pictures to create a stereo impression. In silico stereo vision is based on presenting each eye a slightly different picture, and each of these two pictures should represent as precisely as possible what the eye would have seen if the 3D model would really have been there. Much text has been written about how to project a 3D object as two mono pictures that can be viewed with special lenses or mirror boxes (see figure 2 ) to create a stereo impression. At first one would think that two projections, one before and one after a small rotation of the object around a vertical axis, is all that is needed, but it can easily be shown that this is not optimal [4,5,6] . A further discussion of this topic is beyond the scope of this article.


Figure 2 shows a simple mirror box that can be used to fool the human visual system. Although it has been shown that this system needs some minor corrections [7] , it works well for most practical applications. Most molecular graphics software packages provide a display mode, called side-by-side stereo, in which the picture for the right eye is displayed using the right half of the screen and the left eye picture using the left half. Side-by-side stereo can be viewed either using a device as shown in figure 2 , or without special devices by totally relaxing the eyes (each eye looks only at 'its own' picture; alternatively one can look cross eyed whereby each eye looks only at the picture projected in front of the other eye; in this latter case the left and right picture need to be swapped at the screen). Side-by-side stereo was till now called the poor man's solution to stereo viewing because a device as shown in figure 2 costs less than $100,- .

Figure 2. Principle of stereo vision from 2D images.

A. If the two pyramids from figure 1 are placed in front of the corresponding eyes, the pictures overlap which makes stereo vision difficult and messy.
B. A stereo device with 4 mirrors allows the two pyramids to be drawn separately. The mirror system ensures that each picture is cleanly presented to the corresponding eye.

The more expensive solution for stereo viewing is to use a system where the whole screen alternately shows the picture for the left and the right eye, while spectacles are worn that alternately make the right or left lens non-transparent. If the screen refresh rate and the transparent/non-transparent swapping of the lenses are properly synchronised, the user will see stereo.

The most common spectacles use Liquid Crystals (LC) that can swap between transparent and non-transparent at a high frequency. These glasses "shut off" visibility for the one eye at the time that the screen is displaying the other eye's image and vice versa, hence they are called LC shutter glasses.

Because of the need to separate in time the images for each of the two eyes, a perfect synchronisation of the glasses to the graphics hardware is needed. This is handled in hardware by most modern graphic cards but the appropriate software drivers to use it, for example in Linux, are still missing.


In order to be able to use cheap stereo glasses in the X11 version of WHAT IF was to write the appropriate software to display the picture for one of the eyes in the odd lines of the screen having at the same time the picture for the other eye in the even lines. We tested three different hardware approaches to synchronise the shutter glasses with the two pictures, and implemented all three methods in WHAT IF. This stereo source code is, however, totally general and publicly available.

The first and simplest of the methods is used in the less expensive devices like Tetratel's Eye-FX or VR Standard VR-Joy, and is done entirely by the device that scans the video signal alternatingly switching off the odd and the even lines. This is called "line blanking" or "synthetic interlace" and its main advantage is that works with every video card-monitor configuration without any need to modify the hardware setup.

The other two methods require the use of interlace modes that can easily be programmed for most of the current operating systems, by simple changes in their operating system setup. In the case of XFree 86 , the X11 server most used on Linux based PCs, some changes should be made in the configuration file (XF86Config ). In interlace mode the Cathode Ray Tube (CRT) controller of the graphics card, first draws the odd lines (i.e. 1,3,5 ....1023 ) and then returns to the top and draws the even lines (i.e. 2,4,6 ...1024 ). Each of this "draws" is called a field and the entire display is drawn in two separate fields (odd and even).

Using two different vertical sync signals the hardware can recognise which is the even and which the odd field. Systems like the NuVision 60GX NSR , Tetratel E ye FX or VR J oy can synchronise the shuttering of the lenses in the stereo glasses to these alternating fields.

StereoGraphics Corporation uses another trick to synchronise their CrystalEyes glasses. They use in the PC version (EPC-2) a procedure called White Line (WL) code. This implies that the transparency of the lenses is triggered using the last line of the display. StereoGraphics Corporation uses the convention that a line composed for about 4/5-th of pure white and further pure black pixels indicates the right eye picture, and a line composed for about 1/5-th of pure white and the rest black pixels indicates the left eye picture. To use the EPC-2 , our software draws the white lines in the last two lines of the root window. The major drawback of this method is that the last two lines of the display have to stay clear of overlap with other windows or desktop gadgets.

Silicon Graphics has a large line of graphics workstations (SGI stations). Their intermediately expensive workstations combined special hardware with a variety of visualisation techniques to create a good stereo perception. Basically by dividing the complete screen into top and bottom halves and doubling the monitor refresh rate SGI was able to drive the LC glasses in a way that the left eye sees only the top half of the framebuffer and the right only the bottom half. This same procedure can also be applied on PC s by using an external device that doubles the refresh rate, StereoGraphics and NuVision controllers provide this facility which is called above/below stereo or sync-doubling. The major disadvantage of this techniques is that the stereo pictures always cover the full screen. If one wants to see stereo in just one window while maintaining normal mono for the rest of the screen (stereo-in-a-window, which we call 'full-window-stereo') an SGI station is needed that can do quad-buffering. These quad-buffer capable SGI stations, unfortunately, are rather expensive.

For the WHAT IF implementation of stereo vision on the PC, we initially started evaluating the old full-screen (above/below or sync doubling) method. However, this method was discarded later in favour of the full-window interlaced method, because above/below showed no other advantages than the simplicity of the implementation [8].


To generate the stereo pictures we have used the parallel camera model [5,6,9] rather than rotations around any axis. The stereo perception is further improved by Z-buffering and colour depth cueing.

Figure 3. The key fragments of the source code used for stereo vision in a window.

Figure 3 lists the most important parts of the X11 code used in WHAT IF to create full-window-stereo. The WHAT IF graphics code was modified to introduce the stereo multi-buffering scheme, the parallel camera model for the calculation of the viewing matrices, and the code that checks for eye reversal (see below).

The multi-buffering scheme consists of one buffer per eye, a combination buffer, and a screen buffer. When a change is needed at the screen, the pictures for the two eyes are drawn in the two separate eye-buffers, they are copied one after the other (the first in full, the second using a clipmask) to the combination buffer. The graphic context (GC) is updated using the XSetClipMask operation (figure 3 c) [10] . The clipmask (figure 3 a) is a pixmap of depth one, with the same root as the GC , and should for our application be of the same geometry as the drawable pixmap. The clipmask will make the X11C opyArea function (figure 3 c) work such that only the non masked lines will be copied.

When an eye reversal situation occurs, for example by moving the full-window-stereo window by an odd number of pixels in the vertical direction, the clipmask for the right eye is simply inverted (figure 3b) to avoid that the depth perceptions flips back to front.

After merging the two images the combination buffer is copied into the screen buffer and thus to the CRT (figure 3 d). Of course this quad-buffering mode is a bit slower than non stereo or double-buffer modes, but this is absolutely not a problem given the speed of current CPU s, graphics hardware and CRT s.


There are no special hardware limitations, other than that this type of stereo vision will work only if you have a real CRT monitor and not an LCD display. It is advisable to use a monitor that supports a very high refresh rate. In stereo the eye refresh rate will be half of the monitor refresh rate. If the eye refresh rate gets too low the picture will be flickering. Although this is a matter of taste (and money) we suggest to use CRT s with a monitor refresh rate of at least 120 H z.

We looked at a series of stereo devices ranging in price from $200,- up to $1200,- (see table 1) . All gadgets were easy to install and require no major modifications to the computer setup. Table 1 lists these devices and some of their characteristics, as well as some subjective remarks.

Table 1.

 Company/device name(1)            Price   Principle(2)   Quality    Remarks
Tetratel/EyeFX NA LB, INT ++ (3) VRStandard/VR Joy $160.0 LB, INT + (4) StereoGraphics/EPC-2+CrystalEyes $1190.0 WLC +++ (5) NuVision 60GX NSR $399 .0 INT +++ (6) 1) WWW addresses of vendors: Tetratel : http://www.tetratel.com/ VR Standard: http://www.vrstandard.com/ StereoGraphics: http://www.stereographics.com/ NuVision: http://www.nuvision3d.com/ 2) LB = line blanking, INT = Interlace, WLC = White line code, (this table only shows those modes used by WHAT IF) 3) This system is discontinued, at present is being replaced by the EyeFX Pro, an infrared wireless system. 4) Wired system, two glasses per controller, small LCs. 5) Wireless glasses, large LCs, WLC makes software control possible. 6) Wireless glasses, large LCs, very good controller with eye reversal.


We have created a procedure to use the X11 Window system library to create stereo vision in a single w indow aided by LC shutter glasses. We have tried to keep this procedure simple and hardware independent.

From the times when it was introduced to the PCs by IBM, interlaced modes gained a bad reputation. We have seen in the computer community a trend to believe that one should avoid the use of interlace modes at all costs, because they introduce flicker. Today's display technology, however, is much better than a decade ago, easily allowing for the flicker-free use of interlace modes.

The main advantage of the interlace stereo modes compared with the above/below method is that multiple stereo windows can be displayed at the same time, this is not very important for the computer game industry, but it is certainly crucial for science (see figure 4). A detailed comparison of these two methods is beyond the scope of this paper and has been described elsewhere [8].

The hardware discussed in this article represents the state of the art for stereo devices in summer 1999 . By the time you read this article some of the companies perhaps no longer exist, others might have designed different or better devices. We only tested a series of radically different hardware stereo devices to ensure that our software can cope with all possible stereo vision techniques.

Figure 4. Example of full-window-stereo.

In this screen dump one sees the two interlaced halves of a stereo picture in the left WHAT IF window, while the right WHAT IF window and all text windows are mono.


We are grateful to Christoph Brungert for his WWW page [11] that actually made us to think about the possibility of doing this work. We thank Mike Ingram of Tetratel for his support and for sending one EyeFX unit for free, to Vince Power of NuVision for his technical support, and to the people of StereoGraphics for making extensive stereo literature freely available via their WWW pages.


1. - Vriend, G. WHAT IF: A molecular modelling and drug design program. J. Mol. Graph. 1990, 8, 52-56

2.- Nicholls, A., Sharp, K.A., Honig, B. Protein folding and association: Insight from the interfacial and thermodynamic properties of hydrocarbons. Proteins. 1991, 11, 281-296

3.- Richardson, J.S. Schematics drawings of protein structures. Methods Enzymol. 1985, 115, 359-380

4.- Hodges, L.F., McAllister, D.F. Rotation algorithm artefacts in stereoscopic images. Optical Eng. 1990, 29, 973-976

5.- CrystalEyes Software Development Kit. StereoGraphics Corp. 1998.

6.- Akka, R. Converting existing applications to support high quality stereoscopy. StereoGraphics Corp. 1998.

7.- Thomas, D.J. Towards more reliable printed stereo. J. Mol. Graph. 1993, 11, 15-22

8.- Rodriguez, R. and Vriend, G. http://swift.embl-heidelberg.de/whatif/chap59.html

9.- Woo, M., Neider, J., Davis, T. OpenGL Programming Guide. Adison Wesley, 1997.

10.- Scheifler, R. and Gettys, J. X window System: Core Library and Standards, X version 11, releases 6 and 6.1, Digital Press, 1996.

11.- Brungert, C. http://www.stereo3d.com