7 Interacting with the Window System, Operating System, and Input Devices

7.010 How do I obtain the window width and height or screen max width and height?

To obtain the window size on Win32, use the following code:

RECT rect;
HWND hwnd;
GetClientRect(hwnd, &rect);
/* rect.top and rect.left will always be 0, 0, respectively.
   The width and height are in rect.right and rect.bottom. */

For the screen size in pixels on Win32:

int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);

To obtaining the screen and window width and height using GLUT:

int screenWidth, screenHeight, windowWidth, windowHeight;

screenWidth = glutGet(GLUT_SCREEN_WIDTH);
screenHeight = glutGet(GLUT_SCREEN_HEIGHT);
windowWidth = glutGet(GLUT_WINDOW_WIDTH);
windowHeight = glutGet(GLUT_WINDOW_HEIGHT);

7.020 What user interface system should I use?

Most user interface (UI) systems, such as Motif, are restricted to a subset of operating systems that support OpenGL. GLUT is available on a variety of windowing systems, and it supports hierarchical menus. However, this fills the UI requirements of only simple applications.

The GLUI toolkit implements buttons, checkboxes, radio buttons, and spinners, which are layered on top of GLUT. Therefore, this UI is window system independent. Go to http://www.cs.unc.edu/~rademach/glui/ for more details.

7.030 How can I use multiple monitors?

Many OpenGL implementations support multiple monitor configurations. These come in a variety of different flavors:

Some Macintosh configurations, such as the ATI Rage 128 Mobility, allow dual displays. However, hardware acceleration is disabled if the OpenGL window spans both displays. If the window lies completely on one display or the other, full hardware acceleration is available.

Microsoft operating systems allow two OpenGL devices in a single system, but only the primary device is hardware accelerated. To work around this issue, many vendors have provided their own multiple monitor solutions, so that hardware acceleration is available on both displays.

The NVIDIA Quadro2 MXR and GeForce2 GTS devices both support two displays from a single card. Under Miscrosoft Windows operating systems, the Display Properties dialog features a TwinView tab that allows the user to configure the displays. In Vertical Span mode, a single logical desktop spans both monitors. In this configuration, an application that creates a window the size of the screen will automatically create a window that fills both monitors. No change to the application is required, and both displays are accelerated in hardware.

NVIDIA Linux drivers do not currently support hardware accelerated rendering, according to the NVIDIA Linux FAQ.

HP Visualize Center and Visualize Workgroup allow full hardware acceleration in windows spanning two or more displays under HP-UX. Visualize Center blends multiple projector displays seamlessly on a wall-sized screen. Stereo is supported to produce a completely immersive environment.

3Dlabs supports multi-head on GVX1, GVX210 and GVX420. The latter two cards are a single AGP card with dual monitor output. The GVX1 supports one display per device, and comes in both AGP and PCI versions to support signle-AGP slot systems.

Matrox supports a dual display device. In addition to supporting a single logical display, tTheir Microsoft Windows device drivers also support a dual desktop mode.