[ This chapter does not appear in the book. ]
Although JOGL can create wonderful 3D worlds, we normally only get to see them flattened onto a 2D computer screen.
True 3D (stereo) viewing is available in OpenGL (and JOGL) with the help of fancy quad-buffering hardware (e.g. the NVIDIA Quadro and ATI FireGL ranges), and drivers for LCD shutter glasses. This kind of technology isn't cheap, but stereoscopic viewing is also possible on ordinary PC hardware, provided the user can train their eyes to look at the screen in a certain way.
The StereoGL application shown at the top right of this page displays two views of a 3D scene, each offset slightly to match the different viewpoints of the user's left and right eyes.
When the user looks at the images with his eyes aimed forward (almost in parallel), the two images blend into a single stereoscopic image. If 'parallel' viewing is too hard (it does take some practice to master), then StereoGL can be called in 'cross-eyed' mode: the left and right images are switched, and the stereo effect is achieved by the user crossing his eyes. The diagram on the right illustrates the two viewing techniques.
This stereoscopic mechanism can be added to any 3D application with only minor changes to the code. StereoGL is based on the TourModelsGL example from the previous chapter, with the addition of a new KeyStereoCamera class to navigate through the scene, and EyeCamera to represent the view for each eye.
StereoGL also employs JOGL's Overlay utility class, added to JOGL 1.0, and modified slightly in version 1.1. It's used to draw the thin yellow vertical line between the views, the three yellow circles across the middle of the window, and the camera position and rotation information in the top-left corner.