This appendix provides a brief overview of library routines that developers may need in order to make applications work on a dual-head system. For more information about the routines mentioned, see the appropriate reference pages.
Note that once you open a window on a given head, the user can't move it to the other head via the window manager; if you want users to be able to move windows from one head to another, your program must explicitly close the old window and open a new one on the other head.
X, mixed-model IRIS GL, and OpenGL all use X calls to choose on which screen to display: just pass the name of the desired display as the argument to XOpenDisplay(3X11). (Pass NULL as the display name if you want to default to the value of the DISPLAY environment variable.) You can then call RootWindow(3X11) with the newly opened display, specifying whichever screen you want; then call XCreateWindow(3X11) to create a window on the specified screen. After that, use the usual OpenGL or X calls, as appropriate, to draw or display in the window.
This is the syntax for XOpenDisplay():
Display *XOpenDisplay(display_name)
char *display_name;
|
For example, to open a window on each head of a dual-head system:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
void main(argc, argv)
int argc;
char **argv;
{
Display *display;
Window root0, root1, win0, win1;
/* Open the display specified in the DISPLAY variable. */
if ( (display = XOpenDisplay("")) == NULL )
fprintf(stderr, "%s: cannot connect to X server.\n",
argv[0]);
/* Set up a root window for each screen. */
root0 = RootWindow(display, 0);
root1 = RootWindow(display, 1);
/* Now create a window on each screen. */
win0 = XCreateSimpleWindow(display, root0, 0, 0, 100,
100, 0, 0, 0);
win1 = XCreateSimpleWindow(display, root1, 0, 0, 100,
100, 0, 0, 0);
/* Display the windows and flush the output buffer. */
XMapWindow(display, win0);
XMapWindow(display, win1);
XFlush(display);
/* Leave them up for ten seconds before exiting. */
sleep(10);
}
|
Note that if you are using the heterogeneous (SI or SE/SI or SE with texture memory option board or SI or SE/MXI or MXE) dual-head configuration, the SI or SE with texture memory option board or MXI or MXE head is always screen zero, while the SI or SE head is always screen one. Be careful about which head you choose if you don't decide to default to the value of DISPLAY. An MXI or MXE board runs 3D graphics and texure mapping much faster than does an SI or SE board.
Under IRIS GL, select a head on which to run a window by using the scrnselect(3G) function. If you don't call scrnselect() before opening a window with winopen(3G), the window opens on whichever screen the user has specified in the DISPLAY environment variable.
This is the syntax for scrnselect():
long scrnselect(gsnr)
long gsnr;
|
gsnr is the screen number relative to the current server—that is, zero for screen :0.0 or one for :1.0.
If you include system configuration files such as /usr/lib/X11/xdm/Xservers with your application, you may want to configure the layout of the heads, specifying which is on the left and which on the right. For information on how to specify adjacency, see the Xsgi reference page, under the –hw option, or Chapter 4 in this guide.