The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers


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); /* 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 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:

  • One display is hardware accelerated, the rest are not.
  • All heads are accelerated as long as OpenGL windows do not span display boundaries.
  • As above, with support for OpenGL windows that span multiple displays.
  • All of the above, with support for stereo.
  • All of the above, with support for heterogeneous graphics cards vendors.

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.

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.

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.

Matrox under Linux and Microsoft operating systems supports DualHead, digital flat panel, and TV out for the G400, DualHead for the G450, and multiple monitors for the G200 series. . In addition to supporting a single logical display, their Microsoft Windows device drivers also support a dual desktop mode.

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.

All versions of Sun OpenGL for Solaris on SPARC support accelerated multihead configurations provided the display is OpenGL accelerated. With Solaris 8 and Sun OpenGL 1.2.1 an accelerated OpenGL window can span multiple heads provided the display devices are the same and the device is OpenGL accelerated. Sun OpenGL is available from:

Column Header
Column Footer