| Home
| Previous
| Next
| Up

MGL_createStereoDisplayDC

Create a new display device context for stereo LC shutter glasses

Declaration

MGLDC * MGLAPI MGL_createStereoDisplayDC(
int mode,
int numBuffers,
int refreshRate)

Prototype In

mgraph.h

Parameters

mode | Graphics mode to initialise
numBuffers | Number of buffers to allocate for double/multi-buffering.
refreshRate | Requested refresh rate for the graphics mode

Return Value

Pointer to the newly created display device context, NULL on failure.

Description

Creates a new display device context for drawing information directly to the hardware display device in fullscreen graphics modes. Essentially this function is identical to MGL_createDisplayDC, however support for LC shutter glasses is provided and the MGL will take care of automatically flipping between the left and right images to create the stereo display. In some cases we may not be able to initialise support for LC shutter glasses, so this function will fail.

When the device context is created, the MGL will start the graphics mode specified in the mode parameter and initialize the specific device driver. If any prior display device contexts exist, they will all be destroyed before switching to the new display mode.

When running in stereo mode, the MGL actually allocates twice the number of buffers that you request for drawing images, since we need one buffer for the left eye image and another buffer for the right eye image (ie: if you request two stereo buffers for double buffering, the MGL will actually allocate room for four). The reason for this is that when displaying one of the stereo buffers, the MGL will automatically swap between the left and right eye images at every vertical retrace. It also sends a signal to the LC shutter glasses to tell them to block out the image for the eye that should not be seeing the image on the screen (ie: when the left image is being displayed, the shutter over the right eye will be blacked out). Hence by drawing images with slightly different viewing parameters (ie: as viewed from the left or right eye when doing 3D rendering), the user sees a single image with complete with visual depth cues!

When running in stereo mode, you have to tell the MGL which buffer you want to draw to when drawing the left or right eye images. Just like you normally do in double and multi-buffering, you use the MGL_setActivePage function to tell the MGL the active display page you wish to draw to. However in stereo modes you must also pass in the MGL_LEFT_BUFFER or MGL_RIGHT_BUFFER values to tell the MGL which eye you are drawing for. For instance to draw to stereo page 1, left eye you would use MGL_setActivePage(1 | MGL_LEFT_BUFFER), and for the right eye you would use MGL_setActivePage(1 | MGL_RIGHT_BUFFER).

Note: In OpenGL rendering modes, changing the draw buffer is done with the OpenGL glDrawBuffer(GL_BACK_LEFT) and glDrawBuffer(GL_BACK_RIGHT) functions instead of using MGL_setActivePage.

One of the biggest drawbacks to viewing stereo images using LC shutter glasses is that the refresh rate viewed in each eye is exactly half that of the refresh rate of the display mode. Hence if running in a display mode with a 60Hz refresh rate, the user will experience an overall refresh rate of 30Hz per eye! As you can image this can be extremely tiresome for extended viewing periods, so to get around this the MGL allows you to pass in a value to request a higher refresh rate for the mode. Ideally you want to try and use a refresh rate that is twice the desired refresh rate per eye, such as 120Hz for viewing images at 60Hz, however you must allow the user to override or suggest a desired refresh rate as many older monitors may not be capable of displaying an image at a high refresh rate like 120Hz.

The refresh rate value that you pass in is a suggested value in that the MGL will attempt to set the refresh rate to this value, however if the hardware does not support that refresh rate the next lowest available refresh rate will be used instead. In some situations where no refresh rate control is available, the value will be ignored and the adapter default refresh rate will be used. If you dont care about the refresh rate and want to use the adapter default setting, pass in a value of MGL_DEFAULT_REFRESH.

Note: In the USA and Canada, the main power frequency runs at 60Hz, and all fluorescent lights will be illuminating your room at frequency of 60Hz. If you use a refresh rate that is not a multiple of the mains frequency and you are viewing the image in a room with fluorescent lights, you may experience severe beating at a frequency that is the difference between the monitor refresh rate and the fluorescent light frequency (ie: at 100Hz you will experience a 20Hz annoying beat frequency). In order to get around this problem, always try to use a frequency that is double the mains frequency such as 120Hz to avoid the beating, or have the user turn off their fluorescent lights!

When you create a stereo display device context, the MGL does not automatically start stereo page flipping, and you must start this with a call to MGL_startStereo. You can also turn stereo mode on an off at any time (ie: you can turn it off when you go to your menu system) using the MGL_stopStereo and MGL_startStereo functions. Note that when stereo mode is disabled, the MGL always displays from the left eye buffer.

See Also

MGL_createDisplayDC, MGL_destroyDC, MGL_startStereo, MGL_stopStereo, MGL_setBlueCodeIndex

Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com