Re: Performer with Crystal Eyes on an I2E

New Message Reply Date view Thread view Subject view Author view

Ed Millard (millard++at++hawkeye.newport.sgi.com)
Tue, 15 Nov 1994 11:12:46 -0800 (PST)


>
>
> sfly is set up for stereo in a window. For the old-style 1280x492
> top/bottom stereo, you need to remove the leftbuffer/rightbuffer
> calls and change each channel's viewport to the proper half of
> the 1280x1024 screen.
>
> Perhaps someone can share some code which actually does this.
>
There are two methods. I've attached some code fragments demonstrating
the new method. This new method relies on the X server to draw X and Motif
windows for both eyes. With the old stereo method X and Motif are visible only
to one eye which causes headaches. If you are using a full screen GL window
the old method is OK otherwise its not. The old method also requires
creating and maintaining two GL windows and contexts which is something
of a pain and is hard with a GLX widget. For the new method the X server
creates and maintains the two windows(one for each eye) for you so its
much easier to implement.

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
=============================================================================


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:40 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.