News & Views / November 1994

WinG Addresses Windows' Weakness in Games

Tom R. Halfhill

Sales of DOS-based applications continue to decline, but one area where DOS still rules is in entertainment and games, thanks to performance advantages over Windows' GDI (Graphical Device Interface). The trade group Software Publishers Association says overall DOS applications sales in the U.S. and Canada declined 47.5 percent to $235 million for second quarter 1994 compared to the same period in 1993. However, in entertainment software, DOS programs accounted for about 50 percent of retail sales ($41.6 million), compared to 33 percent ($27.4 million) for Windows, with the Mac commanding the remaining 21 percent ($18 million). As long as game developers stick with DOS for superior performance, they will impede Microsoft's efforts to move the industry to Chicago, Windows NT, and Win32. But many games developers see DOS's games domination ending thanks to WinG (pronounced "Win Gee").

WinG is a new library of graphics routines from Microsoft that lets developers significantly boost the performance of graphics-intensive Windows applications. Distributed free with new Windows software and built into Chicago and NT 3.5, WinG accelerates screen updates and delivers almost as much speed as custom graphics routines in MS-DOS programs do. Although it won't make existing Windows applications run faster, new software (and updates of current software) designed to take advantage of WinG should begin appearing late this year.

Microsoft unveiled WinG at the Computer Game Developers Conference in Silicon Valley last April. To show off the library's capabilities, Microsoft demonstrated a prototype Windows version of Doom, a popular DOS-based game from Id Software. Soon afterward, Microsoft posted beta versions of WinG in a developer's forum on CompuServe.

Any Windows program that needs fast screen updates or smooth panning can benefit from WinG. But Microsoft's primary target is the game market. Most game developers have been forced to write for DOS, because the Windows GDI is notoriously slow. DOS programmers can write optimized routines that directly access the computer's graphics hardware.

Unfortunately, the higher performance of DOS comes at a price. Without a DOS extender, DOS programs are limited to conventional memory (the addresses below 1 MB). They also lack the device independence of well-behaved Windows programs and often require users to modify their CONFIG.SYS and AUTOEXEC.BAT files during installation, which results in more customer-support calls. Game developers are weary of these headaches but were unwilling to sacrifice performance.

For the most part, WinG works by circumventing some limitations of the GDI, which was designed for static displays rather than animation. To achieve device independence, the GDI shields Windows programmers from hardware-specific details of output devices (including graphics cards and printers) by interposing a logical drawing surface known as a DC (device context). In other words, instead of drawing directly into the physical frame buffer (screen memory) of the graphics card, Windows programmers use the device-independent display DC. The GDI and Windows device drivers handle the details of translating those logical graphics into physical graphics in the frame buffer.

Drawing graphics on the fly with GDI routines is not practical for animation, so many Windows programs use a technique called double buffering. But this technique is too slow for smooth animation.

WinG introduces a streamlined approach. First, it lets programmers create a new type of DC, called a WinGDC, that accepts DIBs (Device Independent Bitmaps) directly. That eliminates the time-consuming steps of shuttling the DIBs through a memory DC and converting them into Device Dependent Bitmaps, which developers had to do prior to WinG. Also, programmers can draw graphics directly onto the WinGDC bit map with GDI routines or their own custom routines. When the screen is ready to be displayed, WinG provides two new calls (WinGBitBlt and WinGStretchBlt) that can copy the WinGDC into the display DC much faster than the GDI's BitBlt and StretchBlt can.

As a final bonus, WinG also tests the system it's installed on to determine which combination of GDI and WinG calls yields the fastest performance, because there is some variation among graphics cards from different vendors. It then saves this profile for future reference. There can even be different profiles for each screen mode. For example, a 640- by 480-pixel resolution screen with 16-bit RGB color may require different techniques than a 320- by 200-pixel resolution screen with 8-bit indexed color. WinG handles this automatically.

Nels Bruckner, a software engineer at Dynamix (Eugene, OR), says he's using WinG for future projects. He says WinG isn't quite as fast as full-screen page flipping in the frame buffer via DOS, but it's definitely faster than the GDI at updating smaller windows and is particularly useful for simulating sprites. "Microsoft's claim is that WinG will be as fast as writing directly to the video hardware in DOS, and from what I've seen, they're coming pretty close, especially if you've got a machine with local-bus video."

Illustration: Game developers like Humongous Entertainment ((206) 485-1212) plan on releasing WinG-based entertainment programs for Windows in time for the holiday season. Freddi Fish and the Case of the Missing Kelp Seeds, a story adventure game capable of full-screen animation at 10 to 12 fps (frames per second) in 640- by 480-pixel resolution with 256 colors.

Copyright 1994-1998 BYTE

Return to Tom's BYTE index page