Ed Millard (millard++at++hawkeye.newport.sgi.com)
Tue, 15 Nov 1994 11:12:46 -0800 (PST)
The new method is available only in IRIX 5.2 and later. It doesn't work
on GT, GTX or some old PI's. It wont work on VGX, VGXT, VTX or RE until
IRIX 5.3.
This method splits the framebuffer in to two halfs. One on the top half and
the other on the bottom half. In this example the bottom half is the
primary so thats the part of your X display you will see. Since vertical
resolution is halved in this method the transformation matrix has to be
adjusted by rescaling Y. If you are using X or Motif fonts you have to
play games with the fonts to reduce their vertical size or they appear
stretched.
With stereo-in-a-window on the RE the aspect ratio doesn't change. The
vertical and horizontal resolution are both decreased by the same amount.
Here are the code fragments. It will probably take a little work on the
part of the user to make this fully functional. This just enters
stereo mode and then exits. The calls to set the left and right eye
windows for drawing are included but not used.
Compile with:
cc -o softstereo softstereo.c -lX11 -lXext -lgl
====================================================================
#include <X11/Xlib.h>
#include <X11/extensions/SGIStereo.h>
#include <gl.h>
#include <gl/get.h>
#include <stdio.h>
Display *dpy;
Window root,xwindow;
main()
{
int first_event;
int first_error;
int major_version;
int minor_version;
int old_monitor_mode;
if((dpy=XOpenDisplay(0)) == NULL)
{
fprintf(stderr,"\ncannot connect to X server\n");
exit(-1);
}
/*
* You need a GL context to make setmonitor and getmonitor work
* You really need to open a GLX window here for your app
*/
winopen("dummy");
/*
* Check for SGI stereo extension in the X server
*/
root = RootWindow(dpy, DefaultScreen(dpy));
if( XSGIStereoQueryExtension(dpy, &first_event, &first_error))
{
XSGIStereoQueryVersion(dpy, &major_version, &minor_version);
if (XSGIQueryStereoMode(dpy, root) != X_STEREO_UNSUPPORTED)
printf("SoftStereo supported\n");
else{
fprintf(stderr,"The following code wont work on this machine\n");
exit(-1);
}
}
if (!getgdesc(GD_STEREO))
{
fprintf(stderr,"Monitor or graphics can't do stereo\n");
exit(-1);
}
/*
* Put X server in stereo mode
*/
XSGISetStereoMode (dpy, root, 492, 532, STEREO_BOTTOM);
XSync(dpy, False);
/*
* Put monitor in stereo mode
*/
old_monitor_mode = getmonitor();
setmonitor(STR_BOT);
sleep(10);
setmonitor(old_monitor_mode);
}
righteye()
{
/*
* Set the right eye for drawing
*/
XSGISetStereoBuffer(dpy, xwindow, STEREO_BUFFER_RIGHT);
XSync(dpy, False);
}
lefteye()
{
/*
* Set the left eye for drawing
*/
XSGISetStereoBuffer(dpy, xwindow, STEREO_BUFFER_LEFT);
XSync(dpy, False);
}
=============================================================================
Ed Millard
Silicon Graphics Inc.
Developer's Support Group
millard++at++sgi.com
=============================================================================
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:40 PDT