June/July 1995

GAME DEVELOPER MAGAZINE GAME PLAN GGAMEAEM

Brain Editor Larry O’Brien [email protected] Goes Whoosh! Senior Editor Nicole Freeman [email protected] Managing Editor Nicole Claro [email protected] oing to the Computer Game popular graphics. Editorial Assistant Deborah Sommers Developer’s Conference is like But why fight it? The truly amazing [email protected] having your brain ripped from thing is that all of this—the sound work, Contributing Editors Alex Dunne your skull, spun up to 90% of the three-dimensional graphics with [email protected] the speed of light, and fired into incredible frame rates, the hottest con- Chris Hecker a reaction chamber filled with tent—was running under a single platform. [email protected] 2,000 other brains moving at Windows. You heard me right, bunkies. David Sieks [email protected] relativistic speeds. It’s just as Microsoft has decided it wants the home Wayne Sikes Ghard recreating the CGDC from business market and will do what it takes to make [email protected] cards, press releases, and scrawled notes as the successor to Windows 95 (Windows Editor-at-Large Alexander Antoniades it is seeing the signature of a Top quark in 95++?) the number one game platform. [email protected] the spirals and parabolas of a reaction Like anyone in the press, I’m used to Cover Photography Charles Ingram Photography chamber photograph. getting a lot of opinions about major Above any other impression, the Microsoft initiatives. You expect some overwhelming support for Game Developer people to love it on technical merit, some Publisher Veronica Costanza from the community was both gratifying people to hate it on technical merit, and a Group Director Regina Starr Ridley and humbling. To have so many people lot of people to hate it on the general prin- known to us only from their credits on ciple that Microsoft’s a big, successful Advertising Sales Staff shrinkwrap games come up and tell us that company and therefore is evil. But no mat- West/Southwest they read the magazine was amazing ter who I talked to about the Microsoft Yvonne Labat (415) 905-2353 enough, but when they continued with Game SDK, with its four APIs for graph- [email protected] specific comments about this column or ics, input, network connection, and sound, New England/Midwest that feature, I realized that our magazine’s it was a love story. Kristin Morgan (212) 626-2498 editorial staff isn’t what’s on the masthead, Not one to be swayed by public sen- [email protected] it’s 20,000 strong. timent, I put on my sunglasses with the Despite the overload of informa- special Anti-Hypnosis coating and met Marketing Manager Susan McDonald tion that makes it impossible to say with Microsoft’s Game SDK advance Advertising Production Coordinator Denise Temple what the story of the show was, I think team. What can I say? They ripped off the Director of Production Andrew A. Mickus there were three candidates: sound, 3D, glasses and made me stare at a screen with Vice President/Circulation Jerry M. Okabe and Windows. three objects composed of approximately Group Circulation Director Gina Oh The sound story was a howl of rage 8,000 Gouraud-shaded polygons rotating Group Circulation Manager Kathy Henry against FM synthesis and its gaming syn- at dozens of frames per second. Then they Circulation Manager Mike Poplardo onym “SoundBlaster compatible.” To made me watch other displays with alpha Newsstand Manager Pam Santoro many at the CGDC, the chirpy voice of an channels, specular highlights, and smooth Reprints Stella Valdez (415) 655-4269 FM card through the molded plastic panning. They overlayed three-dimen- speakers bundled with a $60 card repre- sional sounds. They did it all, okay? And Chairman of the Board Graham J.S. Wilson sents the jackboot of tyranny on the throat all of this in well-behaved Windows President/CEO Marshall W. Freeman of the gaming public. applications. Executive Vice President/COO Thomas L. Kemp Although “rendered on the fly” Maybe it is hypnosis, though. I need Senior Vice Presidents Warren (Andy) Ambrose, H. sounds like what happens when an acceler- perspective and some feedback from you, Verne Packer, Donald A. Pazour, Wini D. Ragus ated brain hits a screen door, it’s also our 20,000 editors. E-mail us at Vice President/Production Andrew A. Mickus where the action is in terms of software. [email protected] and tell us what to do. Vice President/Circulation Jerry Okabe Although demos that don’t have to bother More graphics, more Windows, more AI, Vice President/Software Development Division Regina with little things like gameplay always more design, more channel issues? It’s your Starr Ridley achieve higher frame rates, vendor after magazine—tell us what to do. ■ vendor was showing convincing evidence Larry O’Brien Miller Freeman that the bar’s been raised (or extruded) for Editor A United News & Media publication

4 GAME DEVELOPER • JUNE/JULY 1995 SEZ U!

Delphi Why?

by Our Readers Dear Editor: fine job on the article topics and writing in hanks for a magazine for developers of general, I am concerned about your blatant games. I just finished reading the pro-DOS and Windows bias. (Why not just This column is for your TApril/May issue and have to question change the name to Windows Game Develop- your editorial. What does Delphi have to do er and avoid confusion?) with game development? The magazine is I’ve developed on both PCs and Macin- thin enough without extra noise being put in. toshes and greatly prefer the latter. The fact feedback. Send us I also hope the magazine stays away from that there is a much larger market for DOS articles that compare games unless it’s and Windows software than for Macintosh going to help me or someone else develop a software is a tribute to Microsoft’s market- game. Comparing Tetris on the SNES to Tetris ing abilities. However, Macintosh developers on Sega doesn’t do me any good, and I can do exist, and we would like to read some queries, suggestions, read that in the hundreds of magazines articles pertinent to us...Mode 13 and Sound devoted to games. Blaster programming techniques are all well Other than these few complaints, I really and good, but how about an article on pro- like the magazine. I hope it grows and gramming .mods using Sound Manager? How complaints, and praise becomes very successful. I feel that this about “Getting the Most Out of CopyMask?” magazine will be a valuable resource for my Also, it would be a welcome addition if library. you’d state the platform on which a review or article is based. And please, try to get (especially praise). Brien King Alexander Antoniades to ease up—his com- via e-mail ments in the April/May issue(“It’s a Sim, Sim, Sim, Sim World,” By Design) suggested Editor Larry O’Brien responds: that Maxis was losing scads of money by You want code? We‘ve Close your eyes and visualize this: “Games. developing on Macintoshes first. Maxis’s Windows.” What do you see? A virtually empty success was probably due to the fact that it universe, with Solitaire the brightest star. did write for the Macintosh, thereby avoiding Now close your eyes and visualize this: “Win- the glut of games already available for the got code. (Really. dows. Home market.” What do you see? The PC and distinguishing itself in a smaller fastest growing sector in the computer market. Many other superior games (most industry. Vast clouds of money being sucked notably, Myst) were developed on the Macin- faster and faster into the pockets of those tosh, and this platform should be given who create digital entertainment. Delphi is a some consideration by your otherwise excel- Check the end of this tool for those who want to become little neu- lent publication. tron stars of dense money. Geoffrey Reiss via e-mail section for a special DON’T FORGET THE MACINTOSH Dear Editor: Larry O’Brien responds: charter subscriber, I’ve been reading How about the best of both worlds, Macintosh Game Developer since your premiere and Windows? Jon Blossom shows how, starting clip-and-save piece.) Aissue, and while you generally do a on page 28.

GAME DEVELOPER • JUNE/JULY 1995 7

SEZ U!

ddddddddecddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddcedddddddd

ddddddddecddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddcedddddddd

ddhc dd

ddhc dd

ddhc dd

ddhc dd

ddhc dd

ddhc dd

dd dd

dd dd

dd

IF I HAD MY OWN MAGAZINE... Editor Larry O’Brien responds: dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

Dear Editor: Chris Hecker has a lot more to say on the sub- dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

our magazine needs more mass to be ject. See page 18 of this issue and look for dd

dd dd

dd dd dd

dd (clip-n-save)

dd dd

dd dd

dd dd

dd dd

dd dd

dd

worth buying. There are many things I’d more in the future. dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd like to see in future issues: dd

dd dd

dd

Y dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd • Two or three long interviews per issue (8- dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

10 pages each). There are hundreds of SOMEONE ELSE LIKES US, TOO! dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

people with much to say—designers, Dear Editor: dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd ❁❁❁❁

businesspeople, and the like. I’d like to just wanted to say I like the direction in

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

read about Carl Stone’s, Yoshihide which Game Developer is going. In the dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

Otomo’s, Kim Cascone’s, Mason Jones’s, April/May issue, you had not one, not two, dd dd dd

dd dd

dd dd

dd dd

dd dd

dd

I dd

dd dd

dd dd

dd

and Fumio Kosakai’s electronic music but three great, informative articles—Chris dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

recording methods. Hecker’s Under the Hood column, the first of dd dd dd

dd dd

dd dd

dd

dd IS THIS dd dd

dd dd

dd dd

dd dd

dd

• I’d like a big report—interviews on Ultima 9 two parts on texture mapping (“Perspective dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

Development, the Japanese game scene, Texture Mapping Part I: Foundations”); “Pro- dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

Psygnosis’s staff, and New World’s staff. gramming Digitized Sound on the Sound dd

dd dd

dd dd

dd dd

dd dd

dd dd PROMINENT

dd dd

dd dd

dd dd

dd

• I’d like to know what happened to Bill Blaster” by Keith Weiner and Erik Lorenzen; dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

Hogue, Reflections, and Wizardry. and “Supercharge Your Sprites” by Matt dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

• I’d like six to ten reviews and dissections of Pritchard. Congratulations. dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

games new and old, game structure, archi- The only thing I didn’t like were Dean Ois- dd ENOUGH???

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

tecture, and the like. I’ve noticed that any- boid’s opinions of Andre LaMothe’s books dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd thing over two years old is being thrown off Tricks of the Game Programming Gurus (SAMS dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd the shelves or deleted. Maybe you could Publishing, 1994) and Teach Yourself Game dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

dd ❁❁❁❁ dd dd

dd dd

dd print code architecture from these discon- Programming in 21 Days (SAMS Publishing, dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd tinued games. 1994). In contradiction to what the cover dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd • I’d like 30 to 40 pages of articles on port- says, I think these books “do suck.” But that dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

ing PC code to game systems, how it’s is just a difference of opinion, not the fault of dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

done, and the troubles and costs of hard- your magazine. dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

ware. I’d like four to five pages per issue of Robert Zawarski dd dd dd

dd dd

dd

dd ftp://ftp.

dd dd

dd dd

dd dd

dd dd

dd dd

dd

screen shots from upcoming games, works via e-mail dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

in progress, and info on CD-ROM pressing dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

and costs. dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

Add in this junk and your mag will improve WE GOT YOUR CODE RIGHT HERE dd

dd WE GOT YOUR CODE RIGHT HERE dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

greatly. Dear Editor: dd

dd dd

dd

dd mfi.com

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

normally do not offer unsolicited opinions, dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

D. Godat but in this case, I will. I used to be a game dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

Fort Wayne, In. developer (I programmed The Last Files of dd

dd dd

dd dd

dd dd dd

I dd

dd dd

dd dd

dd dd

dd dd

dd Editor Larry O’Brien responds: Sherlock Holmes for 3DO). dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

dd /gdmag/ dd dd

dd Okay...we’ll get right on that junk. You should have it prominently displayed dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd somewhere in your magazine that source is dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd available via ftp. I learned this from your let- dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

WELL, SOMEONE LIKES US ters section. This could be my fault; I might dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

Dear Editor: have missed it somewhere. But it’s a very dd

dd dd

dd dd

dd dd

dd dd

dd

dd src dd dd

dd dd dd

hanks for such a great magazine. It is handy piece of information. dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

great to have articles from people who This last thing is a compliment. Your arti- dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

take the “theory” and put it into real cles were excellent—they all covered subjects dd dd dd

dd dd

dd dd

dd dd

dd dd

dd

T dd

dd dd

dd dd

dd

world practice. In the April/May issue, I really that were interesting, up to date, and relevant dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd ❁❁❁❁

dd dd

dd dd

dd

liked Matt Pritchard’s article, “Supercharging to game programming today. There’s no dd dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

your Sprites” and Chris Hecker’s column on “Faster drawing in Mode X” stuff that was dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

perspective texture mapping. I also appreci- covered in Dr. Dobb’s Journal three years ago. dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

ate the business articles that talk about the Texture mapping, ripping apart Tie Fighter, dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd

game industry itself. push-button game design...Yes! But, as I dd

dd dd

dd dd

dd

dd (clip-n-save) dd dd

dd dd

dd dd

dd dd

dd dd

dd

said before, give us more. dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd

dd dd dd

Bruce Burkhalter Jeff Miller dd

ddg cdd

ddg cdd

ddg cdd

ddg cdd

ddg cdd

ddg cdd

dddddddd cddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddcedddddddd cdddddddd

dddddddd cddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddceddddddddecddddddddcedddddddd Berkeley, Calif. via e-mail cdddddddd

8 GAME DEVELOPER • JUNE/JULY 1995 CROSSFIRE

3D Graphics Goliaths Square Off

Alex Dunne esterday, as I was cleaning out a Snow White and the Seven Dwarves) into bookshelf in our office, I came digitized EGA display. Yeeeesshhh, the upon an issue of Byte magazine final result looked horrible. So, maybe the Microsoft‘s Softimage from Aug., 1987. Although I time wasn’t right back then for creating was throwing everything away, digital media from live footage. But, like a I had an urge to flip through its rolling snowball picking up size and pages—there’s something com- speed, the graphics industry is maturing pelling about a computer mag- to the point where there’s not too much Yazine that’s over seven years anyone can’t do at an affordable is suddenly chal- old. Volume 12, number 9 price. Microsoft and Silicon of Byte may only have been Graphics (SGI), thanks to 49 in dog-years, but it was recent acquisitions and merg- much older in computer-years. ers, are helping to fuel this I couldn’t believe it—ads for momentum. lenged by Silicon 386 16Mhz computers sell- ing for $4,400, 9600-baud Competitive Partners modems for $1,000, and The relationship between articles about EGA graphics. It’s Microsoft and Silicon amazing we got through those rough Graphics has changed enormously over Graphics‘s merger times. (Some know-it-all will read this in the past 12 months. Silicon Graphics is 2002 and say the same thing about 1995, the dominant player in the graphics no doubt.) workstation market, and Microsoft is the One article that caught my eye giant in the PC software market. Howev- focused on the technique of transferring er, when Microsoft acquired Softimage with Alias and Wave- cartoon-quality film (a clip from Disney’s last summer, Microsoft gained a powerful

front. What can game

developers expect

Man in the boat overboard! Softimage Toonz, which was used to create this animation cel, is one product in a suite that Microsoft acquired last year. The software currently runs on the from these two? SGI platform, but Microsoft has stated its plans to port Softimage tools to Windows NT.

GAME DEVELOPER • JUNE/JULY 1995 11 CROSSFIRE

suite of IRIX-based animation, editing, played up the positive aspects of their Microsoft looks at its partner/com- compositing, and cel animation tools. It new product lines. Wright stressed the petitor relationship with SGI in the same instantly became a key partner of SGI. fact that many of SGI’s partners, not just light as its association with Apple. “We’ll Eight months later—last February—SGI Microsoft, were now competitors, but continue to invest in SGI,” Wright stated. merged with Alias and Wavefront, two that it wouldn’t make sense for SGI to “It’s very similar to our situation on the companies that compete against Softim- consider them as such: “Yes, we are a Macintosh. Microsoft makes a lot of age on the SGI platform. How have these competitor to [Silicon Graphics], but money on the Macintosh and it’s a very developments changed the relationship they’re also a competitor to a number of vital platform for us at the application between Silicon Graphics and Microsoft? their other ISVs [independent software , even though we don’t own the oper- More importantly, how does it affect their vendors]. Companies like Side Effects, ating system. The fact that we’ve got customers? Discreet Logic, Avid... One thing I can applications on Windows 95 as well does I spoke with Andrew Wright, group say absolutely outright is that if SGI loses not in any way affect our investment in product manager of advanced authoring their third-party applications as a result the Macintosh platform.” tools for Microsoft/Softimage, and Dave of this merger, they’re dead in the water. Wright sees Silicon Graphics Larson, director of marketing for Silicon I think they’ve almost got to overcom- remaining the superior platform for high- Studios, a wholly owned subsidiary of Sili- pensate to make sure that their third end digital video and three-dimensional con Graphics, about the actions their party ISVs are treated fairly,” Wright animation over Windows NT, just as the companies have taken recently in the digi- commented. Macintosh held its position as the superior tal entertainment industry. Dave Larson adamantly agreed. platform for graphic design when Win- The most recent event, Silicon “We’re going to treat [Microsoft] as we do dows 3.0 was introduced. Graphics’ merger with Alias and Wave- a whole category of partners who will get “Macintosh had a very strong posi- front, achieved two objectives for early access information, and it’s tion in graphic design. Windows came in SGI, according to Larson. based on business parame- and everybody thought that it was going “We felt that by merging ters. These guys, as well as to completely take over the market. As a with Alias and Wavefront,” Larson other 3D vendors, are still result, companies like Aldus and Adobe explained, “we could get two of the selling SGI software and developed their applications first on Win- most important groups of engineers we’re going to do whatever we can to dows and second on Macintosh. But they together with our engineers and accom- make sure they continue to do so. That’s realized over time that the Mac wasn’t plish two things. [The first objective] is to our business.” going to go away... We think a simi- drive the development of our 3D software lar thing is going to hap- environment... [Second,] we don’t have Softimage off pen in the SGI world,” expertise in entertainment and industrial the SGI Platform? Wright said. [software] markets at the customer level Upon acquiring Softimage last year, like we do with hardware. We’re getting a Microsoft stated its intention to port the Porting Softimage sales force that knows the customers really Softimage tools over to Windows NT. I Products to Windows NT well at the application level, a sales force asked Wright whether Microsoft had Upon acquiring Softimage, Microsoft that has a much greater depth of knowl- plans to pull Softimage products off the announced that it would port the compa- edge.” SGI platform at a later date and focus ny’s toolset to Windows NT. Wright What was Wright’s reaction to the exclusively on its own operating system indicated that Softimage products would SGI merger? implementation. be available on Windows NT this year, “Surprise,” he said. “From “No. One of the key reasons but he declined to be more specific, fear- [Microsoft’s] perspective, it actually puts Microsoft bought Softimage is that Soft- ing that divulging an estimated date could us in a stronger position because we feel image had a tremendous presence in the raise false hopes. that for our customers a cross-platform community that was producing the I wanted to know what strengths solution is important. Where they want world’s best content. ILM [Industrial Windows NT could offer over the SGI the performance of SGI, we provide it, Light and Magic]. Greenberg. Rocket platform to game developers. After all, where they want the price-to-performance Science. For those companies, the SGI SGI has been targeting this market for ratio and openness of a Windows NT sys- platform is absolutely critical because they years and has optimized its hardware for tem we’ll provide that to them. We’ll be need that level of performance... We think high-end graphics and animation. Wright the only high-end 3D animation vendor Windows NT and the associated hard- responded: “We think that the Windows that’s effectively able to execute a cross- ware developments are going to provide a NT platform will offer very attractive platform strategy.” very price-attractive alternative. But in no price-to-performance ratio in the range of I sensed no edginess from either way is that going to put SGI out of busi- performance that it delivers. We also feel Wright or Larson about the relationship ness. They are going to continue to do that for people who have PC-based net- between Microsoft and SGI, and both very well and we need to be there.” works, for example developers who are

12 GAME DEVELOPER • JUNE/JULY 1995 CROSSFIRE

using [Autodesk’s] 3D Studio, it will be active media, it’s important to have more of people [developing digital entertain- important for them to run a high-quality aggressive price points and maintain that ment] for a living. It’s all about how much 3D product in the same environment that leadership position.” time you have to get your work done. For they’re running their other tools. I think A large number of graphics instance, a friend of mine just that’s going to be key to the games devel- and animation products have came up who’s been doing a lot opment area.” been launched for the Windows, of audio work on the Mac, DOS, and Macintosh platforms and he just started using a Downward recently by companies like Caligari new audio application on Pressure on Prices and Strata. Although these products our platform. He says it’s In addition to announcing the porting of aren’t in the same class of function or dramatically affected his work just after a Softimage tools over to Windows NT, performance as either the Microsoft or few days of working with it. What he used Microsoft announced in January that it SGI tools on IRIX, they seem to be exert- to think ahead to do he now does in real was slashing the price of all Softimage ing pressure on software prices for the time. He can test his decisions as he goes. software by up to 50%. What was behind entire market, regardless of platform. I That’s the metaphor for performance this aggressive move? Wright explained: asked Dave Larson how Silicon Graphics change. Everything happens so much “Over the last couple of years, inter- viewed these lower-priced products, and more quickly [on the SGI platform], and active developers [have how his company would respond. your creativity can increase.” begun to] require [high- “We’re moving down in end] tools as games have terms of markets,” declared Lar- Sega and become more sophisticated. We looked at son. “As our price points come down, Nintendo Choose Sides our pricing structure and said, ‘Well, those we’re cutting deeper into various mar- There’s an interesting sidebar concerning prices make sense if we continue to main- kets... Historically, SGI has been per- SGI and Microsoft. The two archrivals in tain our high-end feature set for our tradi- ceived as vastly more expensive and out of the game cartridge market, Nintendo and tional market.’ But if [Microsoft] really reach, a boutique kind of machine. We Sega, have gone to separate corners for wants to penetrate the market for game think we’re rapidly expanding beyond their respective development tools, and you developers as well as other emerging inter- that, and that we’re within reach for a lot can probably guess whom each has enlist- ed. In 1994, Nintendo selected Alias (whose software was used to create the Super NES blockbuster Donkey Kong Country) as the authorized graphics devel- opment system for both current games and next-generation 64-bit games. Last Janu- ary, Sega chose Softimage 3D as the offi- cial three-dimensional development tool for the new SegaSaturn game platform. I’m not saying that this is an instance of “any enemy of my enemy is my friend,” but it is predictable political maneuvering. As long as the Softimage tools on IRIX don’t take a distant second priority to their Windows NT version, users stand to gain from a price war between two resource-rich companies like Silicon Graphics and Microsoft. Feature sets and performance should evolve more rapidly, and it undoubtedly will spur other SGI platform competitors to keep up. You’d better get used to seeing more companies merging or acquired as the dig- ital entertainment market expands—it’s a natural consolidation that should continue for the next couple of years. ■

Alex Dunne is contributing editor for Game Developer magazine.

14 GAME DEVELOPER • JUNE/JULY 1995 BIT BLASTS

Live from the CGDC Show Floor!

Game or those souls lucky enough to entertainment pie, hoping that Microsoft Developer Staff get in, the CGDC usually has might stumble in the rocky transition enough information to make it from DOS to Win32. Apple showed It was some show! the best show for both the sea- Doom and Dark Forces running native soned and prospective game on Power Macintoshes, and IBM developer, and 1995 was no announced an OS/2 Warp game devel- exception. Mushrooming up to oper’s kit and help from Argonaut and Alexander Antoniades 2,500 attendees, the CGDC Macromedia. Dave Taylor of Id put the Firked prospective conference goers by whole platform thing in perspective when severely underestimating demand for the he said the fastest version of Doom is the second year in a row, so anyone who version, so maybe there are didn’t buy tickets (or register as press) untapped opportunities after all. kept an eye on the well in advance of the show has to read In an industry with its share of egos about it here and hope they didn’t miss and superegos, the Freudian slip still out on too much. crossing most developers lips remains Id. The main buzz was about the The folks from Mesquite, who received a tenor of the show. CGDC show itself and revolved around standing ovation from awestruck devel- founding member Chris Crawford’s talk opers last year, were out in force this year on the second day. Crawford railed offering private showings of their next against show management and admitted project, Quake, to developers deemed Larry O‘Brien and that he had been kicked off the board of worthy. For an industry that uses Doom directors. It was a sad note to this show, as benchmark, Quake becoming a hit is which started nine years ago in someone’s probably the only prediction that anyone living room and has grown larger than can make for sure. Barbara Hanscome anyone would have thought possible. While last year’s “unofficial” theme Low-Cost Wavetable Sound was the invasion of Hollywood money MD, the fourth-largest supplier of and fear of ratings, the definite themes ICs in the U.S., was showing its checked out new prod- this year would have to be three-dimen- new AM78C201 InterWave audio sional development and the move to Aprocessor, a kick-butt, single-chip Windows. Most of the exhibitors were audio system. At its hospitality suite, hawking three-dimensional tools (both AMD demonstrated prototype sound sight and sound), offering to turn you boards with component costs as low as ucts. And Nicole Claro into the next industry superstar if you’d $40 (implying a sub-$100 street price) just buy their tool (and the box—usually running under popular games such as Tie a RISC one—it runs on). On the Win- Fighter and recreating beautiful sym- dows side, Microsoft explained its new phonic arrangements. AMD is enthusi- ran into her costar from write-to-the-device-drivers interface and astic about the Microsoft Game SDK, as showcased its recent acquisitions Render- was Origin’s Zachary Simpson, who said Morphics and Softimage. “The InterWave chip and the Microsoft Lurking in the shadows, other plat- DirectSound API will allow...unprece- the high school play. form vendors vied for a piece of the home dented levels of audio quality and realism

16 GAME DEVELOPER • JUNE/JULY 1995 at consumer price points.” Hoo doggie, VIOLENCE IS FINE—BUT WHAT ELSE IS THERE? this is one nice chip with its 16-bit, 32- voice wavetable synthesis and on-chip f you were at the right place at the right time at the CGDC this year (the lobby of the support for vibrato, tremolo, chorus, Westin Hotel at 5:30 on Sunday), you might have been asked to join an informal round- echo, phase shifting, and reverb. Look for table discussing game strategies that appeal to a broader audience—namely women and nontraditional game players. Just what kind of games appeal to game players who boards with this chip to be available and aren’t 18-to-35-year-old men? And what can game designers do to reach them? flying off the shelves for Christmas. I For more information contact: Jessica Miller, game designer and president of Spirit Games in Salem, N.H., and myself were AMD Inc. lucky enough to be so well positioned in the lobby, and for the next two hours we chatted 1 AMD Pl. with three game designers interested in bursting out of the “shoot-and-kill,” model: Alex P.O. Box 3453 Uttermann, game designer and author of several game strategy books (including Dragon Sunnyvale, Calif. 94088-3453 Lore: the Official Strategy Guide), Rusel DeMaria, game industry journalist and president of Tel: (408) 732-2400 DeMaria Studio, and Dennis Hescox, vice president of Lightside Inc. The O.J. Files Hescox organized the roundtable in hopes to build a network, share information, and discuss ioVision, of San Francisco, is a marketing development and research strategies for alternative games. He came armed with psychological and academic theories and studies relating to differences between male and turnkey motion capture service female game playing styles, neurophysiology, and perceptual physiology. “By understanding provider. Inverse kinematics isn’t these differences, “ Hescox explained, “we can attempt to design entertainment based on Btime-effective for complex human some solid ideas rather than vague and cosmetic guesses”—like pink interfaces and ponies motion, but with BioVision’s low-cost on a box. service, you can have rotoscoped actors that can be disturbingly realistic (you The conversation quickly jumped from theories to games that are simply fun to play. Utter- might have seen BioVision’s work in the mann, who is working on a game with DeMaria that she hopes will have an internal logic frightening recreation of the murder of that appeals to both genders, summed it up nicely in saying, “Violence is fine in games, but Nicole Simpson and Ronald Goldman what else is there?” that’s making the rounds on the Internet) or thrilling (as in a certain wildly popular Puzzles that are fun to solve on their own but connect to help solve a larger puzzle; interac- tive games that require good communication skills and diplomacy to “win,” rich plots that football game). For every day of shooting, unfold like a novel, role-playing games, “safe environments” that allow the player to con- BioVision estimates two days of post- quer the task at hand comfortably before moving on to the next challenge, and networked processing to massage the data into for- play were all mentioned as games and elements that would appeal to female as well as mats for popular animation packages such male game players. as Alias, Softimage, Wavefront, and Nichimen Graphics. BioVision will even By the time we got around to how to convince the big companies in the industry to take supply the actors! If you don’t need cus- some risks with these types of games, the hospitality suites were calling our names. But I tom work, BioVision has partnered with think we could have talked all night. And I also think more people in the lobby would have Viewpoint DataLabs to provide over 200 joined us if they could. Perhaps we needed to hold up a big sign—if only we had a name for standard motion sets. just what it was we were discussing. It was obvious by the end of our chat that “games for For more information contact: women” wasn’t exactly it. BioVision If you have thoughts and comments pertaining to women’s games and alternative gaming 1580 California St. strategies, contact Barbara Hanscome at [email protected]. San Francisco, Calif. 94109 Tel: (800) 866-3463

GAME DEVELOPER • JUNE/JULY 1995 17 BEHIND THE SCREEN

Perspective Texture Mapping, Part II: Rasterization

Figure 1. The Fill Convention you might have trouble seeing how this information fits in perspective (cough). 0 1 2 3 4 5 6 7 8 9 10 This time around we’re going to 0 focus on the triangle rasterization stage, and we’ll expand on the math for the 1 fill convention we derived last issue. 2 As I did last time, I encourage you to get out a piece of graph paper and 3 join in the fun. Speaking for myself, I 4 find it impossible to learn math with- out scribbling all over the place. 5 If you don’t like math, well, com- 6 puter graphics is math for the most part, so I’m not sure what to tell you. 7 My goal is to describe the math in an accessible way, but I’m not going to 8 hide the fact that math underlies every- thing about computer graphics, espe- id I say I’d be doing two cially three dimensional computer columns? Silly me—I meant graphics. If you like programming you four or five columns. Our will definitely like math...heck, math’s topic, perspective texture even better than computer program- mapping, is so huge I don’t ming because there are no compiler or know what I was thinking operating system bugs! (Of course, when I said we could cover it there’s no compiler or operating system completely in two columns. to tell you when you’ve done something DLuckily, the topic has enough variety wrong, either.) that it should keep everyone glued to these pages for the duration. Raster Blaster In Part 1, we covered most of the When I say rasterization, I mean taking math behind the perspective projection the continuous geometric triangle— and triangle gradients (those neat num- defined by its vertices—and displaying bers that let us interpolate without it on the monitor’s discrete display grid, recalculating at each scanline), and we or “raster.” The rule we defined for quickly went over fill conven- doing this is called a top-left fill con- tions and stepping on pixel centers. vention, where we light all pixels that That’s a lot of information for a single are strictly inside the polygon bound- article. In fact, there’s so much material aries and any pixels that are exactly on still to cover I’m not even going to the polygon boundary if they’re on the summarize my last article beyond say- top or left edges (remember, pixels are ing, “Read it.” If you haven’t read Part boxes with a center, not just points). I, you’ll still get a lot out of Part II, but Figure 1 shows this fill convention in

18 GAME DEVELOPER • JUNE/JULY 1995 Chris Hecker action. Pixel (5,2) is lit, but pixel (9,4) function comes in. is not, even though our polygon edge The ceiling function is defined as intersects both (within the limits of the bumping a real value up to the next magazine’s printing accuracy, at least). highest integer if the value has a frac- Perspective texture This is because (5,2) is on a left edge tional part, or leaving it alone if it is and (9,4) is on a right edge. A fill con- already an integer. For example: vention lets abutting polygons share an edge without either polygon overwrit- 4 È˘4 = 1 mapping is a huge ing any pixels of its neighbor, or leav- ing any unlit holes—called dropouts— 3 = 1 between the two. È˘4 A top-left fill convention for a left edge from x0,y0 to x1,y1 is defined subject—much too 5 = 3 mathematically by the ceiling function: È˘2

ÈÊ xx- ˆ ˘ -4 x = ÍÁ 10˜()yy-+ x˙ =-1 big to cover in one or int 00 È˘4 ÍË yy10- ¯ ˙ In my last column, I presented this and: equation without much explanation, so -4 =-1 this time we’ll go into it in more detail. È˘3 even two articles. In First, we can derive the equation for the line in Figure 2 by setting the slope Notice how the ceiling behaves with of the entire line equal to the slope of negative numbers—it bumps the value any line segment on that line (the seg- to the next highest value, not to the Part II of his series on ment from x,y to x0,y0 is on the line, so next highest absolute value. its slope is equal to the line’s) and solv- The ceiling is the perfect function ing for x: to realize a top-left fill convention for yy- yy- left edges (and top edges if you solve 10= 0 the subject, Chris xx12- xx- 0 for y instead of x in Equation 2). If ()2 we’re exactly on an integer pixel center Ê xx10- ˆ x = ()yy-+00 x we will light the pixel, but if our x is at Ë yy10- ¯ all greater than the integer—to the left We can use Equation 2 to give us the x of the pixel center—the ceiling will Hecker tackles value for any y value on the line. You bump us up to the next pixel that’s can see that if y = y0, then x = x0 as strictly inside the edge. It should be you’d expect, and likewise for the other pretty obvious that the equations for endpoint. This equation generates real right and bottom edges are the same as rasterization, an (as opposed to integer) values for x, so for top and left edges with the addition we need to use our fill convention to of a minus one outside the ceiling. tell us how the real x maps to an inte- That is, if the edge is on the integer ger pixel. This is where the ceiling pixel, the ceiling won’t affect it, but the essential concept.

GAME DEVELOPER • JUNE/JULY 1995 19 BEHIND THE SCREEN

minus one will knock us back one pixel bly not the best choice for a produc- value is negative. following our fill convention. If the tion rasterizer. First, even though We can convert from ceiling to edge is greater than the pixel, the ceil- floating point coprocessors are com- floor easily if a and b are integers: ing will bump it up one (to the first monplace on today’s machines and are a = a - 1 +=1 pixel outside the edge) and the minus even faster than the integer processor È˘b Î˚b ()3 one will bump it right back inside the for some operations, converting from a - 1 ab-+1 polygon. Another way of looking at it floating point to integer is still slow. Î˚b + 1 = Î˚b is if we have two polygons with an Because a rasterizer is where the real abutting edge, the edge will be the left three-dimensional coordinates get Equation 3 also shows that we can edge of one and the right edge of the mapped to the integer hardware move integers in and out of the floor other (or the top and the bottom), and bitmap, we end up converting a lot. (or ceiling). We obviously can’t move they’ll draw the same set of pixels, Also, functions like ceil() are actual fractional values in and out, though, function calls in floating point, but fall because they can affect the result. Run out of the math almost for free with through a few examples on your own to Figure 2. A 2D Line integer coordinates. see why Equation 3 works. In addition, it’s hard to get the Now that we have a working math just right for floating point num- knowledge of floors and ceilings, let’s bers; there’s a whole field in mathemat- convert the rasterizer to use integer ics dedicated to figuring out how float- coordinates. Because we are defining x0,y0 ing point numbers accumulate error. x0,y0 and x1,y1 in Equation 1 to be Finally, we’ll see there are some bene- integers, we can manipulate the equa-

fits to using integer digital differential tion to our advantage. We can bring x0 analyzers (DDAs) when we discuss outside the ceiling function, for x,y pixel centers. starters. This means any x generated by our fill convention will be the integer

Integers from x0 plus the integer result of the ceiling Floor to Ceiling function for a given y. Now, let’s use Before we convert our rasterizer to use Equation 3 to turn the ceiling function integers, let’s learn a couple of neat into a floor. tricks for manipulating the ceiling Let: x1,y1 function and its companion, the floor. dx=- x x The floor of a value is—you guessed 10 it—the next-lowest integer if the value has a fractional part, or the value if it’s and: already an integer. You could also think dy=- y y of this as truncating the fractional part 10 except offset by a single pixel for one for positive values. Following are some polygon. floor examples: so: The code to implement this was 4 dx() y-- y 1 pretty straightforward in our floating 4 = 1 Í 0 ˙ Î˚ xint = Í dy ˙ ++14x0 () point rasterizer (shown in last month’s Î ˚ listing): 3 = 0 Î˚4 If our initial y value is y0, it’s easy to see int XStart = ceil(pLeft->X); the initial value in the floor is -1/dy. The floor of this is -1, and -1 + 1 + x = 5 0 We call the ANSI standard = 2 x , as we expect. We’ll be doing for- Î˚2 0 math.h function, ceil(), and use the ward differences to step our edges, so integer returned for our starting x coor- after we generate the initial value for x, -4 dinate. As we step from one scanline to Î˚4 =-1 we’re going to want to step y by 1 to the next our real x value steps by the the next scanline and generate the next inverse slope, as Equation 2 shows and x from our previous x value, without when you set y = y + 1. recalculating it from scratch. I will -4 While floating-point math cer- Î˚3 =-2 assume you are already familiar with tainly is convenient when you’re trying forward differences, which are covered to get code up and running, it’s proba- Again, notice the behavior when the in any decent computer graphics book,

20 GAME DEVELOPER • JUNE/JULY 1995 so I’m just going to point out the inter- floor of a negative number goes to the Ï Í()-a ˙ esting parts of this algorithm. next lowest number, so the mod term -Í b ˙, m = 0 a Ô Î ˚ Perhaps the most interesting thing must be positive to bring it back up to = Ì ()6 Î˚b ()-a about this particular equation is how the the real value of a/b. Figure 3 shows a Ô-Í ˙ -π10, m Ô ÎÍ b ˚˙ floor interacts with the forward differ- graph of x mod 3. Here’s Equation 5a Ó ences, especially when dx is less than 0. rearranged to make that more clear: Ï 00, m = abmod = Ì ()7 Mod Squad a a abmod Óba--(( ) mod bm ), π0 b = b + b (5b) To thoroughly analyze Equation 4’s Î˚ behavior, we need another trick for In other words, Equations 6 and 7 say manipulating floors: Equation 5b shows a fraction as we that if m = 0 (there is no remainder), sometimes think of it with an integer then we do the flooring divide and mod a =-a abmod (5a) part and a fractional part, since a mod b differently than if there is a remainder. Î˚b b b is always smaller than b. This probably seems really complicat- Even if we want to ignore the ed, but if you sit down with a piece of You’re probably familiar with the modu- ANSI standard and hope our platform paper and refer to the equations and lus operator, mod, from programming in calculates mod correctly, we’re out of Figure 3 you’ll see how this works in no C or other languages (in C, % is the luck on most machines, including Intel time (okay, maybe five or ten min- mod operator). As long as two numbers, x86 processors. The x86 signed divide utes...it took me a while, too). Our a and b, are positive, a mod b is the instruction, idiv, truncates towards 0 C++ function to correctly compute integer remainder after dividing the when dividing negative numerators, flooring divides and mods looks like numerator a by the denominator b. which is exactly the opposite of the real this: Equation 5a says we take the real num- floor function. It appears we need to ber a/b and subtract its remainder over b develop a flooring divide and mod inline void FloorDivMod( long Numerator, and to get the floored value, an integer. function that works on any standard long Denominator, The mathematically defined mod platform, that is, any platform that long &Floor, long &Mod ) { usually behaves differently, in subtle computes positive mods and divides assert(Denominator > 0); ways, than the mod in your program- correctly. // we assume it’s positive ming language of choice, and because If a ≥ 0, then we’ll just do the nor- if(Numerator >= 0) { we’re using the “math-mod” in the defi- mal divide and mod. On the other // positive case, C is okay nition of our fill convention we need to hand, if a < 0, let m = (-a) mod b: Floor = Numerator / Denominator; make sure we don’t let an ill defined Mod = Numerator % Denominator; programming language muck up the } else { works. For example, ANSI C (and // Numerator is negative, C++) defines the mod operator to be the same as the math-mod operator Figure 3. x mod 3 when both operands are positive, but when either operand is negative the result is implementation dependent— x mod 3 the standard only defines the relation- ship of a/b and a%b, not their values, in this case. Fortunately our denominator, dy, is always positive because we step down the polygon from top to bottom, so we only have to deal with the case x where the numerator, dx, is negative. We saw how the floor function behaved with negative values, so if Equation 5a is true (it is, trust me), that dictates how the math-mod behaves as well. Assuming b is positive (our dy), a little thought and some scratch paper will show you that a mod b is always positive regardless of whether a is posi- tive or negative. This is because the

GAME DEVELOPER • JUNE/JULY 1995 21 BEHIND THE SCREEN

do the right when the error term rolls over. Even ndymod thing x = Í n ˙ + Í ˙ ++1 x though the jump is in the scanline int ÎÍdy˚˙ ÎÍ dy ˚˙ 0 Floor = -((-Numerator) / Denomina- loop, not the pixel loop, jumps are get- tor); ting more and more expensive as Mod = (-Numerator) % Denominator; (We can take the floor of n/dy out of processors get deeper and deeper if(Mod) { the enclosing floor because it’s an inte- pipelines. In fact, on more recent Intel // there is a remainder ger; see Equation 3.) architectures the jump prediction logic Floor—; Mod = Denominator - Mod; This is our initial state. We calcu- makes mispredicted jumps that fall } late n from our starting y value, do the through even more expensive than } flooring divide and mod (with our cor- jumps that are taken on earlier proces- } rect algorithm if n is negative), and use sors. Fear not, there is a good reason to the n mod dy term’s numerator as our use an error-term DDA instead of Why? initial error term for our forward differ- fixed-point to scan our edges. Let’s take a step back and ask ourselves ence. (We don’t actually do the divide. Remember the following lines (as you’re probably already asking your- It’s implicit in the way the DDA func- from our floating-point texture mapper self), “Why do we care?” People have tions.) Since n mod dy is positive and been rasterizing polygons since shortly less than dy, we know that the floor of after the beginning of time, and they the n mod dy term is 0 and doesn’t On recent Intel never went through all this, you say. affect the initial x. As y steps by 1, our Well, if their polygons don’t have floor term steps by dx/dy (calculated by dropouts and consistently light the cor- substituting y = y + 1 in our original rect pixels, then they went through all equation). Our new x (call it x'), is cal- this or its equivalent for another fill culated from: architectures, convention. ndymod The vast majority of rasterizers xx¢ =+Í +dx ˙ int int ÎÍ dy dy˚˙ don’t work properly, and that’s why the vast majority of games have dropouts jump prediction and overwrites at abutting polygon We use Equation 5b on the dx/dy step edges. We’re taking the time up front to get: to get the math exactly right, so we can Ídx ˙ implement our rasterizer with total xxint¢ =+ int + ÎÍdy˚˙ ()8 logic makes mis- confidence that it will light exactly the ndymoddx mod dy right pixels; no more, no less. Í ˙ Í dy + dy ˙ This is my personal crusade to Î ˚ eliminate dropouts and poor quality Equation 8 says that as y steps by 1, x predicted jumps rasterizers everywhere, and I’m hoping steps by the floor of dx/dy, and our you’ll help me accomplish it. The best error term steps by dx mod dy. Note part about doing it right is it looks bet- that mod is always positive, so when ter and isn’t any slower at run time our error term numerator exceeds our that fall through than doing it incorrectly, there’s just denominator, dy, we add 1 to the more to understand beforehand. resulting x regardless if we’re stepping left or right. This probably differs from Vive La Différence other DDAs you’ve used before—the more expensive Now that we’ve got an algorithm for the mathematically defined floor and mod correct divide and mod on any platform, terms work out so that you’re always we can go back to our original goal, adding 1 when your error term rolls which was to implement our fill conven- over, not just when you’re stepping in tion with integer forward differences. the positive direction. than jumps on We can use Equation 5b to manipulate

Equation 4. Let n = dx(y - y0) - 1: Look Before You Jump Those of you who have written fixed- ndymod x = ÍÍ n ˙ + ˙ ++1 x point edge rasterizers instead of error- earlier processors. int ÎÍÎÍdy˚˙ dy ˚˙ 0 term DDAs are probably wondering why we’re going to the trouble of doing and a DDA, with its accompanying jumps

22 GAME DEVELOPER • JUNE/JULY 1995 BEHIND THE SCREEN

in Part 1: Listing 1. The Integer Rasterizer (Continued on p. 26) int XStart = ceil(pLeft->X); struct edge { edge(gradients const &Gradients, POINT3D const *pVertices, float XPrestep = XStart - pLeft->X; int Top, int Bottom ); float OneOverZ = pLeft->OneOverZ + inline int Step( void ); XPrestep * Gradients.dOneOverZdX; long X, XStep, Numerator, Denominator; // DDA info for x long ErrorTerm; When we start a scanline, we need int Y, Height; // current y and vertical count to step in to the first pixel center from float OneOverZ, OneOverZStep, OneOverZStepExtra;// 1/z and step float UOverZ, UOverZStep, UOverZStepExtra; // u/z and step the real edge before we can start draw- float VOverZ, VOverZStep, VOverZStepExtra; // v/z and step ing, and our interpolants (like 1/z in this }; snippet) need to step with us. We had to inline int edge::Step( void ) { calculate XPrestep every scanline, and X += XStep; Y++; Height—; multiply it by the gradients of all our UOverZ += UOverZStep; VOverZ += VOverZStep; interpolants to get to the starting pixel OneOverZ += OneOverZStep; center before we could draw. This is ErrorTerm += Numerator; because we didn’t know how far we were if(ErrorTerm >= Denominator) { from the first pixel center until we did X++; ErrorTerm -= Denominator; the ceil() call. OneOverZ += OneOverZStepExtra; Now think about how this works UOverZ += UOverZStepExtra; VOverZ += VOverZStepExtra; with a DDA. We are stepping from one } return Height; pixel center to the next directly, and we } know exactly how far we had to come from the last pixel center: the floor of void DrawScanLine( BITMAPINFO const *pDestInfo, BYTE *pDestBits, gradients const &Gradients, edge *pLeft, edge *pRight, dx/dy in x plus 1 in y, or that step plus 1 BITMAPINFO const *pTextureInfo, BYTE *pTextureBits ); in x when our error term rolls over (see Equation 8). We never need to calculate /******** TextureMapTriangle **********/ our prestep to a pixel center because /********** handle floor divides and mods correctly ***********/ we’re always stepping on pixel centers! Take a minute to think this through—it inline void FloorDivMod( long Numerator, long Denominator, long &Floor, long &Mod ) means we get the advantages of sampling { from pixel centers, and we don’t pay the assert(Denominator > 0); // we assume it’s positive prestep multiply. As I’ve mentioned if(Numerator >= 0) { // positive case, C is okay before, these advantages include rock Floor = Numerator / Denominator; solid textures that don’t swim when you Mod = Numerator % Denominator; rotate and no “hairy texture” artifacts. } else { // Numerator is negative, do the right thing Listing 1 shows the salient parts of Floor = -((-Numerator) / Denominator); the integer rasterizer. Because of space Mod = (-Numerator) % Denominator; constraints, I’ve only included the dif- if(Mod) { // there is a remainder ferences from last column’s listing. You Floor—; Mod = Denominator - Mod; can pick up the entire listing on Com- } puServe in the Game Developer section } } of the SD Forum or from ftp://ftp.mfi.com/gdmag/src/. /********** edge constructor ***********/ The code is in a weird state because edge::edge( gradients const &Gradients, POINT3D const *pVertices. I left the texture coordinates as floats, int Top, int Bottom ) while the edge rasterization is in integer { coordinates, as we’ve been discussing. Y = pVertices[Top].Y; Height = pVertices[Bottom].Y - Y; This bizarre combination doesn’t affect int Width = pVertices[Bottom].X - pVertices[Top].X; the rasterizer, and it will be fixed in the next article when we address the texture if(Height) { // this isn’t necessary because we always start at TopY, mapping itself. One thing you may or // but if you want to start somewhere else you’d make may not notice when you run this raster- // Y your start izer is how jerky it is compared to the FloorDivMod(Width * (Y - pVertices[Top].Y) - 1, original floating point rasterizer. If you

24 GAME DEVELOPER • JUNE/JULY 1995 BEHIND THE SCREEN

compile two test programs, one with each Listing 1. The Integer Rasterizer (Continued from p. 24) rasterizer, and run them side by side, you’ll easily see the quality difference. Height,X,ErrorTerm); X += pVertices[Top].X + 1; The texture mapping is jerky because we use the endpoints of the tri- FloorDivMod(Width,Height,XStep,Numerator); angle to compute the gradients, and the Denominator = Height; endpoints are changing by relatively large OneOverZ = Gradients.aOneOverZ[Top]; amounts as the triangle moves because of OneOverZStep = XStep * Gradients.dOneOverZdX the integer truncation. You also see simi- + Gradients.dOneOverZdY; OneOverZStepExtra = Gradients.dOneOverZdX; lar jerkiness in a lot of game rasterizers, and it’s probably caused by the same UOverZ = Gradients.aUOverZ[Top]; thing (compounded with the artifacts UOverZStep = XStep * Gradients.dUOverZdX + Gradients.dUOverZdY; generated by not stepping on pixel cen- UOverZStepExtra = Gradients.dUOverZdX; ters). Even in the low 320 by 200 resolu- tion game world, this jitter is visible sep- VOverZ = Gradients.aVOverZ[Top]; VOverZStep = XStep * Gradients.dVOverZdX arately from the normal aliasing. In + Gradients.dVOverZdY; accordance with our quest to increase VOverZStepExtra = Gradients.dVOverZdX; rasterization quality around the world, I } } find this unacceptable. The solution hap- pens to be simple: fractional endpoints. /********** DrawScanLine ************/ Unfortunately, I was out of space a while void DrawScanLine( BITMAPINFO const *pDestInfo, BYTE *pDestBits, back, and my editor is beginning to hate gradients const &Gradients, edge *pLeft, edge *pRight, me, so the description of this solution BITMAPINFO const *pTextureInfo, BYTE *pTextureBits ) will have to wait until next time. { // assume dest and texture are top-down assert((pDestInfo->bmiHeader.biHeight < 0) && Summing Up (pTextureInfo->bmiHeader.biHeight < 0)); Once again, I’m over my word budget, int DestWidthBytes = (pDestInfo->bmiHeader.biWidth + 3) & ~3; and I still haven’t covered everything. I int TextureWidthBytes = (pTextureInfo->bmiHeader.biWidth + 3) & ~3; simply must give credit where credit is due, however—without my friend Kirk int XStart = pLeft->X; int Width = pRight->X - XStart; Olynyk’s help and tutelage I’d still be lighting the wrong pixels without know- pDestBits += pLeft->Y * DestWidthBytes + XStart; ing the difference. If you’re into this float OneOverZ = pLeft->OneOverZ; kind of discrete math (it’s so useful for float UOverZ = pLeft->UOverZ; raster graphics) and you want to learn float VOverZ = pLeft->VOverZ; more, Concrete Mathematics (Addison while(Width— > 0) { Wesley, 1994) by Ronald L. Graham float Z = 1/OneOverZ; and Oren Patashnik is great. int U = UOverZ * Z; Also, while discussing my article int V = VOverZ * Z; “Changing the Rules for Transparent *(pDestBits++) = *(pTextureBits + U + (V * TextureWidthBytes)); Blts” (Under the Hood, Feb. 1995) on rec.games.programmer, Rich Gorta- OneOverZ += Gradients.dOneOverZdX; UOverZ += Gradients.dUOverZdX; towsky ([email protected]) mentioned VOverZ += Gradients.dVOverZdX; that for best results, your RLE compres- } sor should try to compress vertically as } well as horizontally. I totally agree. Finally, I promise we’ll get back to the actual texture mapping portion of the texture mapper next time. ■

Chris Hecker wants a single-cycle integer multiply on future x86 processors so bad he can taste it. Yum yum. You can con- tact him via e-mail at [email protected] or through Game Developer magazine.

26 GAME DEVELOPER • JUNE/JULY 1995 DOUBLE-BUFFERED GRAPHICS

A C++ Class for Cross- Platform Double- Buffered Graphics

hat if someone told you that in the near future—will rely on copying you could release a game or page-flipping 256-color graphics from simultaneously on Win- offscreen memory to display memory. dows, Macintosh, and DOS Full-screen 8-bit double buffers with no more effort than it such as these are chunks of RAM man- takes you to release a DOS aged in such a way that a one-to-one game now? Of course, you’d mapping exists between pixels on the kick the person off your screen and bytes in the buffer. That’s all staff,W find a loophole in his or her con- double buffering is, so why not abstract it tract, or refuse the project proposal. in a platform-independent interface? There are no freebies in software devel- All it takes to create an image in the opment. offscreen buffer is a definition of the But what if someone said you could screen-to-offscreen mapping and a release your product on Macintosh and method to describe the image in the off- Windows with very little extra work and screen buffer to the screen. For all the showed you how to do it? platforms game developers generally deal This article takes the first step in with, this requires at most four pieces of that direction by defining a simple dou- information: ble-buffering architecture that will lever- • pBits, a pointer to the offscreen buffer age your existing three-dimensional ren- byte that maps to the screen point (0, dering, animation, sprite composition, 0). and other custom 8-bit graphics code • Stride, the number of bytes between onto Windows and Macintosh systems. the buffer byte that maps to the screen Using the small C++ class implemented point (x, y) and the buffer byte repre- here, you will be able to write 32-bit senting (x, y+1). graphics applications that compile and • Width, the width in pixels of the rec- run without changes on Macintosh Sys- tangle represented by the offscreen tem 6.0.7 and 32-bit Windows (includ- buffer. ing Win32s and Windows 95). • Height, the height in pixels of the rec- tangle represented by the offscreen Double-Buffered Graphics buffer. Double-buffered graphics provide the Given these four pieces of informa- core graphics technology that power tion, you can implement any graphics almost all high-performance desktop algorithm to render three-dimensional multimedia and entertainment software. texture-mapped environments, animate From simple card games to immersive complex action sequences, or present tic- three-dimensional environments, such tac-toe at 30 frames per second. To make graphics use offscreen memory to hide those graphics routines work on any plat- image composition from the user and form, all you need is that magical inter- provide smooth transitions between face that provides these four elemental frames of animation. Most games pieces of information and a way to dis- today—and probably most games created play completed images on the screen.

28 GAME DEVELOPER • JUNE/JULY 19954 Jon Blossom Listing 1 shows the public aspects pBuffer->GetBits(); of this dream interface in a simple C++ for (int y = 0; declaration of a class called COffscreen- y < pBuffer->GetHeight(); Buffer. All operations on the class except ++y, pBits += pBuffer->GetStride()) Double-buffering is GetBits are declared const because they memset(pBits, Color, do not allow change to the buffered pBuffer->GetWidth()); image or to the size of the buffer. I’ve added the Lock and Unlock methods, For every line in the buffer, this fills which I’ll explain. as many bytes with the specified color as the heart of high- Before digging into various imple- there are horizontal pixels, then skips mentations of COffscreenBuffer, let’s take down to the beginning of the next line. If a look at how we can use such an inter- I know that the buffer occupies contigu- face. Say I have a pointer called pBuffer ous memory, that any additional bytes to a COffscreenBuffer object, and I want included as padding are ignored, and that performance to set a single pixel to a given color index. Stride is positive, I can make a small From the definition of pBits and Stride, I optimization and write the buffer clear can deduce that for any point (x, y) in the like this: buffer such that x ≥ 0 and y ≥ 0 and x < graphics. With this Width and y < Height, the memory loca- long BufferSize = pBuffer-> tion pBits + Stride * y + x holds the GetHeight() * pBuffer->GetStride(); corresponding byte of offscreen memory. memset(pBuffer->GetBits(), Using this definition, I can con- Color, BufferSize); struct a SetPixel function using the fol- C-- class, you‘ll be lowing lines of code: This would, however, be a bad idea, as Stride has been defined as a signed char unsigned *pPixel = long value and will often be negative on pBuffer- >GetBits() Windows machines. + pBuffer->GetStride() * y + x; A third simple example would be to able to write your *pPixel = Color; draw a 45-degree line from the point (x, y) to the point (x+n, y+n), where n is Of course, this doesn’t include any positive. No problem: validation or clipping tests, and it’s also code once and com- not very useful in the inner loop of an char unsigned *pPixel = optimized rendering engine. But you get pBuffer->GetBits() + pBuffer-> the idea. GetStride() * y + x; Another simple graphics function // Adding Stride+1 moves the would be to fill the buffer with a solid //pointer from (x,y) to (x+1,y+1) pile it for Windows or color. Using the four atomic offscreen for (int i=0; iGetStride() + 1) with a few simple instructions: *pPixel = Color; char unsigned *pBits = With some extrapolation on the the Macintosh!

GAME DEVELOPER • JUNE/JULY 1995 29 DOUBLE-BUFFERED GRAPHICS

Listing 1. Public Functions API requires a rectangle describing the provides the GetGWorldPixMap and LockPix- dimensions of the desired buffer and a els functions to handle this, and Get- class COffscreenBuffer color table, both of which the COffscreen- PixBaseAddr provides the magic pBits { public: Buffer constructor swipes from the active pointer when all the locking is done. // Basic information access window. The dimensions come directly Apple provides the Stride value in the char unsigned *GetBits(void); off the CGrafPort structure, and the color rowBytes field of the PixMap structure, but long GetStride(void) const; int GetWidth(void) const; table comes from the associated PixMap. the system tacks on the two high bits to int GetHeight(void) const; For good measure, I’ve chosen to lock make things difficult. A simple mask of down every handle ever used here, 0x3FFF pulls them off the top. // Displaying the buffer void SwapBuffer(void) const; though you may not always have to do In addition to locking the image in so. memory and masking off the high bit of // Pixel access control The constructor’s task finishes with the scanline offset, I’ve heard off and on void Lock(void) const; void Unlock(void) const; the call to NewGWorld, at which point the that it’s also a good idea to make sure the }; calling application becomes the proud memory management unit is in true 32- parent of a COffscreenBuffer object. So bit access mode. SwapMMUMode handles this, far, so good. However, gaining access to storing the current mode for restoration part of the reader, these simple examples the bits of that GWorld proves to be a by the Unlock method. show that the COffscreenBuffer interface trifle difficult because the operating sys- The Unlock method mirrors the shown in Listing 1 provides all the essen- tem has allocated the buffer in moveable locking function, allowing the operating tial elements for a complete graphics sys- memory. Enter Lock and Unlock, those system to move the offscreen buffer tem. Further, none use any code outside traditional commands that prevent data around when the application doesn’t the accepted ANSI C++, supported by from moving in a linear address space. need it. The aptly named system call any compiler worth its salt. Before our application can touch the UnlockPixels handles this task, after In other words, as long as your tar- bits of the offscreen buffer, the Lock which I reset the cached pBits value to get platform can transfer an 8-bit packed method has to guarantee that the bits zero to avoid being bitten by an attempt pixel image from memory to the screen won’t move during pixel access. Apple to access the bits when the buffer is and supports an ANSI C++ compiler, you can write a COffscreenBuffer imple- Listing 2. Macintosh Declaration mentation and support the drawing func- tions above without changes. #include // For GWorld stuff

class COffscreenBuffer Making It Macintosh { So let’s get down to the business of public: implementing COffscreenBuffer on the // Basic information access char unsigned *GetBits(void) { return pBits; }; two platforms most likely to be the mul- long GetStride(void) const { return Stride; }; timedia systems of the future: Windows int GetWidth(void) const { return Width; }; and the Macintosh. On both, I’ll show int GetHeight(void) const { return Height; }; you how to exploit system-supported // Displaying the buffer double buffering to do everything you void SwapBuffer(void) const; ever wanted—or at least start you along // Pixel access control that path. void Lock(void) const; Color 32-bit QuickDraw intro- void Unlock(void) const; duced a new architecture for offscreen // Constructor and Destructor drawing support on the Macintosh called COffscreenBuffer(void); a GWorld, which became a reliable part ~COffscreenBuffer(void); of the operating system in version 6.0.7. private: This extension allows the use of Quick- // Common implementation data Draw functions to draw into structured char unsigned *pBits; offscreen memory, and it enables the long Stride; int Height; Macintosh version of COffscreenBuffer int Width; declared in Listing 2 and implemented in Listing 3. // Macintosh implementation data GWorldPtr OffscreenGWorld; Constructing a buffer from a char StoredMMUMode; GWorld requires a single call to the }; handy function called NewGWorld. This

30 GAME DEVELOPER • JUNE/JULY 1995 unlocked. Listing 3. Macintosh Implementation In debug versions, I also add an integer LockCount member variable incre- COffscreenBuffer::COffscreenBuffer(void) { mented by Lock and decremented by // Use the current GDevice and GrafPort to make a GWorld Unlock, and I assert it is zero when the CGrafPtr CurrentPort; COffscreenBuffer destructor is called. GDHandle CurrentDevice; GetGWorld(&CurrentPort, &CurrentDevice); The Macintosh requires the // Get the color table from the current port Lock...Unlock pair, and other platforms PixMapHandle CurrentPixMap = CurrentPort->portPixMap; may require it as well. All implementa- HLock((Handle)CurrentPixMap); CTabHandle ColorTable = (*CurrentPixMap)->pmTable; tions of COffscreenBuffer must include // Create a new GWorld with this information both methods, whether they do anything NewGWorld(&OffscreenGWorld, 8, &CurrentPort->portRect, ColorTable, or not, and all functions written for COff- CurrentDevice, noNewDevice); // Store data that doesn’t change screenBuffer must operate between a Width = CurrentPort->portRect.right - CurrentPort->portRect.left; Lock...Unlock pair to be completely Height = CurrentPort->portRect.bottom - CurrentPort->portRect.top; portable. This includes the previous // Release the current PixMap HUnlock((Handle)CurrentPixMap); examples and calls to SwapBuffer. } SwapBuffer provides the memory-to- screen transfer for the application when it COffscreenBuffer::~COffscreenBuffer(void) { finishes its graphics processing and wants // Free the allocated GWorld to display the image. SwapBuffer will call if (OffscreenGWorld) out to CopyBits to do the job, copying the DisposeGWorld(OffscreenGWorld); } entire offscreen image into the current CGrafPort, using the visRgn as a mask. void COffscreenBuffer::Lock(void) const The operating system will handle all the { PixMapHandle OffscreenPixMap = GetGWorldPixMap(OffscreenGWorld); work of clipping to the visible window if (OffscreenPixMap) area. { The COffscreenBuffer destructor is // Lock the PixMap memory and pull some info off the PixMap structure LockPixels(OffscreenPixMap); the easiest of all to implement on the Stride = (*OffscreenPixMap)->rowBytes & 0x3FFF; Macintosh. It’s just a call to pBits = (char unsigned *)GetPixBaseAddr(OffscreenPixMap); DisposeGWorld, which ditches the GWorld // Make sure the MMU is in true 32-bit access mode for good. StoredMMUMode = true32b; To use the COffscreenBuffer class SwapMMUMode(&StoredMMUMode); properly on the Macintosh, be sure to } } turn on the pmExplicit and pmAnimated flags of all entries in the palette of the void COffscreenBuffer::Unlock(void) const target window to ensure that the color { PixMapHandle OffscreenPixMap = GetGWorldPixMap(OffscreenGWorld); indices used in the offscreen buffer will if (OffscreenPixMap) properly match the colors on the screen, { yielding highest copying speeds and // Unlock the PixMap memory and reset Stride and pBits UnlockPixels(OffscreenPixMap); proper color matching. Stride = 0; pBits = 0; Windows // Restore the previous MMU mode Like GWorlds on the Macintosh, WinG SwapMMUMode(&StoredMMUMode); is the obvious candidate for implement- } ing a double-buffering architecture for } Windows. WinG lets us create a buffer, void COffscreenBuffer::SwapBuffer(void) const access its bits, and copy it to the screen { quickly. The Windows declaration of // Copy all bits from the offscreen GWorld to the active GrafPort // Note: The offscreen GWorld should be locked! COffscreenBuffer appears in Listing 4. CopyBits(&((GrafPort)OffscreenGWorld)->portBits, The following implementation appears in &((GrafPort)thePort)->portBits, Listing 5. &OffscreenGWorld->portRect, &thePort->portRect, srcCopy, thePort->visRgn); WinG allocates an offscreen buffer } for us when we use a WinGCreateDC/WinGCreateBitmap call pair. The buffer memory allocated this way

GAME DEVELOPER • JUNE/JULY 1995 31 DOUBLE-BUFFERED GRAPHICS

will always map to the same address. It structure containing the optimal format, // Align to the highest 4-byte boundary will never move in memory as far as our preserving the sign of biHeight. A color Stride = (Width + 3) & (~3); applications can see, so the unneeded table stolen from the current system extra limbs Lock and Unlock can be com- palette completes the information neces- If WinG recommends a top-down piled out by declaring them as empty sary to create a WinGBitmap and an accom- DIB, that’s all the calculation needed to inline functions. Only the constructor, panying WinGDC, which the COffscreen- set up the buffer. pBits points to the top destructor, and swap functions remain. Buffer constructor does for us. Selecting a of the buffer, coinciding with (0,0), and WinG supports both top-down WinGBitmap into a new WinGDC pops out a Stride indicates a positive step through and bottom-up buffer orientations, as stock monochrome bitmap that the memory. discussed in every piece of WinG litera- destructor will need later, so I store it in For bottom-up DIBs, however, ture to date, so the first step in con- the COffscreenBuffer object until then. things must be switched around. As it structing an offscreen buffer is to deter- The Width and Height of the buffer stands, pBits would point to the last mine the orientation that will make came from the foreground window, and scanline in the buffer, and Stride would memory-to-screen blts fastest. WinG WinGRecommendDIBFormat returns the pBits be the offset from (x, y) to (x, y-1). If provides this information through the for the buffer. Only the Stride remains, you’ve used WinG before, you’ll know WinGRecommendDIBFormat function, called and it’s easily calculated because we that flipping these values around to point by the constructor before creating the know the WinG buffer is actually a stan- in the correct direction requires only two offscreen buffer. dard Windows DIB. Every scanline of a lines: Once it has the optimal Device DIB begins on a 4-byte boundary, and Independent Bitmap (DIB) orientation, since our offscreen buffers are one byte // Point to first scanline (end the constructor fills in the biWidth and per pixel, Stride is just the DWORD aligned of buffer) biHeight fields of the BITMAPINFOHEADER Width: pBits = pBits + (Height - 1) * Stride; // Orient Stride from bottom to top Stride = -Stride; Listing 4. Windows Declaration With that, the constructor has fin- #include // For WinG stuff ished its work, and the calling application

// Note that this is supposed to be for Win32, so there are no FAR types. is the happy owner of a WinG-based off- // However, it could be adapted easily for 16-bit Windows. screen buffer, wrapped in a COffscreen- Buffer object. Your application can draw class COffscreenBuffer { into this buffer however you choose, call- public: ing SwapBuffer when you’re ready to dis- // Basic information access play an image. char unsigned *GetBits(void) { return pBits; }; SwapBuffer long GetStride(void) const { return Stride; }; The Windows imple- int GetWidth(void) const { return Width; }; mentation grabs the Device Context from int GetHeight(void) const { return Height; }; the active window and uses a straightfor- WinGBitBlt // Displaying the buffer ward call to copy the image void SwapBuffer(void) const; from the offscreen WinGDC to the topmost window on the screen. Nothing could be // Pixel access control - these are no-ops in Windows void Lock(void) const {}; easier. void Unlock(void) const {}; The call to GetDC returns a virgin device context that will not reflect selec- // Constructor and Destructor COffscreenBuffer(void); tions you may have made to previous ~COffscreenBuffer(void); DCs from the window. It contains no palette information. If you have gone private: // Common implementation data through the effort to create an identity char unsigned *pBits; palette for the window (or are using the long Stride; WinG halftone palette), your work will int Height; int Width; be in vain unless you register the Win- dow with the CS_OWNDC style, which pre- // Windows implementation data serves device context settings over HDC OffscreenDC; GetDC...ReleaseDC HBITMAP OffscreenBitmap; call pairs. HBITMAP OriginalMonoBitmap; When it comes time to destroy the }; COffscreenBuffer, only three steps need to be taken: selection of the original mono-

32 GAME DEVELOPER • JUNE/JULY 1995 chrome bitmap back into the WinGDC, Listing 5. Windows Implementation (Continued on p. 34) destruction of the WinGBitmap, and destruction of the WinGDC. // This is here to keep it off the stack during the constructor call struct { BITMAPINFOHEADER Header; Extending the Buffer Class RGBQUAD ColorTable[256]; The COffscreenBuffer class I’ve developed } BufferInfo; here provides only the most basic ele- COffscreenBuffer::COffscreenBuffer(void) ments of a double buffering system, { barely enough to be useful. Many other HWND ActiveWindow = GetActiveWindow(); features could make it a very useful tool // Make the buffer the same size as the active window in cross-platform game development, RECT ClientRect; but I have left them out for the sake of GetClientRect(ActiveWindow, &ClientRect); Width = ClientRect.right - ClientRect.left; brevity. Height = ClientRect.bottom - ClientRect.top; One important thing missing from Stride = (Width + 3) & (~3); this COffscreenBuffer class is the explicit // Set up the header for an optimal WinGBitmap connection of an offscreen buffer to a if (WinGRecommendDIBFormat((LPBITMAPINFO)&BufferInfo)) window. As implemented here, COff- { screenBuffer uses whatever window hap- // Preserve sign on biHeight for appropriate orientation BufferInfo.Header.biWidth = Width; pens to be active at the time a method is BufferInfo.Header.biHeight *= Height; invoked. When your application isn’t in the foreground, this can be a messy // Grab the color entries from the current palette HDC hdcScreen = GetDC(ActiveWindow); thing! if (hdcScreen) It’s easy to store a platform-specific { window identifier in the COffscreen- PALETTEENTRY Palette[256]; GetSystemPaletteEntries(hdcScreen, 0, 256, Palette); Buffer structure, and you can hang a pointer back to the buffer object on the ReleaseDC(ActiveWindow, hdcScreen); window, too. Under Win32, try using // Convert the palette entries into RGBQUADs for the color table Set/GetWindowLong and GWL_USER to store for (int i=0; i<256; ++i) the pointer. On the Macintosh, { Set/GetWRefCon performs a nearly identi- BufferInfo.ColorTable[i].rgbRed = Palette[i].peRed; BufferInfo.ColorTable[i].rgbGreen = Palette[i].peGreen; cal task. BufferInfo.ColorTable[i].rgbBlue = Palette[i].peBlue; Of course, attaching a buffer to a BufferInfo.ColorTable[i].rgbReserved = 0; resizable window means you’ll have to do } } something smart when the window changes size. Matching the buffer // Create the offscreen DC dimensions to the new dimensions of the OffscreenDC = WinGCreateDC(); if (OffscreenDC) window wouldn’t be a bad idea.... You’ll { need to look at UpdateGWorld on the Mac- // Create the offscreen bitmap intosh, and you’ll most likely have to cre- OffscreenBitmap = WinGCreateBitmap(OffscreenDC, (LPBITMAPINFO)&BufferInfo, (void * *)&pBits); ate a new WinGBitmap under Windows. Many applications don’t want an if (OffscreenBitmap) API as clumsy as SwapBuffer. You want { // Adjust pBits and Stride for bottom-up DIBs to optimize your screen accesses by if (BufferInfo.Header.biHeight > 0) writing only the areas that haven’t { changed. A SwapRect method would do pBits = pBits + (Height - 1) * Stride; Stride = -Stride; the trick very nicely. Implement it on } both platforms, and remember to make the rectangle description platform // Prepare the WinGDC/WinGBitmap OriginalMonoBitmap = (HBITMAP)SelectObject(OffscreenDC, independent! OffscreenBitmap); And what about colors? Both con- } structors use the current palette to initial- else { ize the offscreen color table, but wouldn’t // Clean up in case of error it be nice to enable color animation? Just DeleteDC(OffscreenDC); be sure to maintain that 1:1 offscreen mapping for speed.

GAME DEVELOPER • JUNE/JULY 1995 33 DOUBLE-BUFFERED GRAPHICS

Wrapping it Up Listing 5. Windows Implementation (Continued from p. 33) To compile the code presented in this article, I used Microsoft Visual C++ 2.0 OffscreenDC = 0; } on Windows NT version 3.5 and Syman- } tec C++ 7.0 on Macintosh System 7.0. I } ran the applications created on Windows } 3.11 with Win32s, Windows NT v. 3.5, COffscreenBuffer::~COffscreenBuffer(void) and Macintosh System 7.0. The graphics { code implemented on top of the COff- // Delete the offscreen bitmap, selecting back in the original bitmap if (OffscreenDC && OffscreenBitmap) screenBuffer API did not change. { If multiplatform graphics program- SelectObject(OffscreenDC, OriginalMonoBitmap); ming can be this easy, the excuses for DeleteObject(OffscreenBitmap); } writing DOS-only games begin to look silly. Take, for example, that it took only // Delete the offscreen device context a weekend (with no sleep) to create a if (OffscreenDC) DeleteDC(OffscreenDC); graphics-only version of Doom for Win- } dows using WinG because of the struc- tured design chosen by the programmers void COffscreenBuffer::SwapBuffer(void) const { at id Software. Most of the third-party // Use the DC of the active window three-dimensional rendering systems on // NOTE: You’ll lose the 1:1 palette mapping if the Window isn’t CS_OWNDC the market today have at least three ver- HWND ActiveWindow = GetActiveWindow(); if (ActiveWindow) sions—DOS, Windows, and Macintosh. { Why shouldn’t you? HDC ActiveDC = GetDC(ActiveWindow); The Microsoft machine has finally if (ActiveDC) { started cranking up and facing the prob- // Perform the blt! lems of providing real game support in if (ActiveDC) Windows, much of it promised for Win- { WinGBitBlt(ActiveDC, 0, 0, Width, Height, OffscreenDC, 0, 0); dows 95. More and more Macintosh ReleaseDC(ActiveWindow, ActiveDC); games are appearing on the market, and } maybe one day someone will actually } } come up with a decent Macintosh joy- } stick. DOS continues to score with game programmers, but users hate the configu- ration problems. Using a simple system like the COff- screenBuffer class introduced here will enable all of your existing graphics rou- tines on all three platforms and may help you reach more users. With the advent of Windows 95 and its promised support for sound mixing and joystick input, and with the multimedia capabilities already provided on Mac and Windows, your reasons for sticking exclusively to DOS begin to look shortsighted. Why not take the cross-platform plunge? ■

Jon Blossom is the coauthor of the WinG graphics library for Windows and is the author of Gossamer, a free three-dimen- sional polygon engine for the Macintosh. He currently works for Maxis and can be reached at [email protected] or through Game Developer magazine.

34 GAME DEVELOPER • JUNE/JULY 1995 GRAPHICS BENCHMARKS

Game Play Benchmarks for 3D Graphics

Figure 1. The Three-Dimensional Graphics Pipeline

Geometry and Rendering Rasterization 3D Lighting Pixels

magine you have just purchased Frame Rate Blues the top-of-the-line three-dimen- The frame rate fell below one frame per sional game board for your PC. second because the game accelerator’s You find yourself playing a flight graphics capability was unable to han- simulator with texture-mapped dle the number of polygons in the polygons and digital sound effects. scene. How do you avoid buying a You can hear the roar of the graphics card that makes a game engines as you fly over the San unplayable? What measurements or cri- MateoI bridge. You execute a steep dive, teria can we use to judge the perfor- and, squeezing down on the shaking mance of a particular game on a partic- joystick, you blast away at the terminals ular platform? spreading havoc amongst the innocent. These questions are of concern to You’ve fed your lust for destruc- many game developers as well as play- tion. Then you hear a voice say that ers. The answer is a standard bench- Moffett Field has just launched inter- mark that’s related to the game rather ceptor F14s to hunt you down. Let the than the hardware pixel memory rates. missiles fly—you’re ready for a dog- But a standard benchmark implies a fight. At this point, you don’t really care normalized level of understanding. In that the hills are texture-mapped poly- this article, we’ll explore the technology gons using real Landsat imagery. You associated with measuring game play. are much more interested in surviving Three-dimensional graphics are the upcoming dogfight. Unfortunately, the next great graphics hurdle for PCs as you pass over the Oakland hills at and console platforms. For the past two 500 feet, the frame rate goes down, and decades, the workstation industry has your game turns into a major drag. been building three-dimensional graph- What happened? ics engines for CAD/CAM that range

36 GAME DEVELOPER • JUNE/JULY 1995 Stephen Johnson in cost from $20,000 up to millions of for visual consumption by an observer. dollars. Suddenly that technology is This process of converting objects into available in a PC or a game console polygons is called tessellation. The platform. process of converting polygons into pix- Making three-dimen- When a new technology hits the els is called the three-dimensional streets, the first things we hear are per- graphics pipeline. The pipeline is com- formance quotes, which are usually plex and difficult to understand without exaggerations, and downright lies. Open a good understanding of geometry and sional games that are up any gaming magazine, and you can maybe a little physics. Most of the read about three-dimensional graphics details aren’t necessary for this discus- performance. For example, a recent arti- sion, but it is necessary to understand cle quoted that a certain console box that these steps exist and they affect the could do 1 million flat-shaded polygons overall performance measurements of a playable is no easy per second and 500,000 texture-mapped three-dimensional application. A sim- polygons per second. What do these plified version is shown in Figure 1, numbers really mean? What is flat shad- where the arrows show the flow of data ing, and why is it mentioned? How do from one stage to another. The larger task. It‘s up to the these numbers compare to the 100,000 the arrow, the larger the amount of data polygons per second that a $20,000 flow. The greatest amount of data is workstation can do? Is it actually true passed from the rasterization step to the that a $300 game console is 10 times pixels step. industry to create faster in three-dimensional graphics Suppose the house in our scene is then a $20,000 workstation? Obviously, represented by 1,000 polygons. When something must be wrong. Let’s look at these polygons are displayed on a the problem by digging a little deeper 1,280-by-1,024-pixel display, the actual standards and into three-dimensional graphics pro- number of pixels processed is very likely cessing and benchmarks. to be in the millions. This implies that the majority of the time in the graphics Graphics Processing pipeline is spent generating pixels—and benchmarks so Let’s define a three-dimensional scene this is true. Over 80% of the time spent that contains objects from the real world. in the graphics pipeline is spent in the A good example would be a room with rasterization stage generating pixels. To walls, a floor, table, chair, and TV. Each accelerate three-dimensional graphics, object is broken down into polygons. first-generation chip designers are consumers aren‘t We’ve given the polygons position infor- accelerating the rendering and rasteri- mation in terms of width, height, and zation steps. This produces the highest depth, which mathematicians and com- performance gain for the least amount puter graphics professionals usually refer of investment. The Glint chip from 3D confused by false to as x, y, and z respectively. Labs is a perfect example of a first-gen- Application software must turn eration hardware solution. This chip each polygon in each of the objects in converts triangles from x,y,z points into the scene into pixels in the frame buffer pixels, using a 64-bit memory interface. magic number models.

GAME DEVELOPER • JUNE/JULY 1995 37 GRAPHICS BENCHMARKS

Three-Dimensional Pixels Figure 2. 3D Pixels Plus Frame Buffer and Z Buffer Pixels are generated for the frame buffer by flat shading, Gouraud shading, or Z Buffer texture mapping. Flat shading fills a or Depth polygon with pixels that are all the same Memory color. Gouraud shading fills a polygon with pixels that are computed using color gradients. Texture mapping fills a polygon with a two-dimensional bitmap like a digital photograph. Each of these methods has its mer- its. Flat shading is very fast, but it doesn’t produce a very good simulation of the real world. Gouraud shading pro- duces a much better representation of a real-world object, and it too is fairly fast. Most three-dimensional graphics hardware can produce almost exactly Frame Buffer Memory the same performance with flat- or Gouraud-shaded polygons. Texture mapping produces very realistic effects, formance of a machine. Dhrystones and magical number that can be used for but it is much slower than flat or Whetstones are perfect examples of comparison. Gouraud shading. this. These benchmarks contain a vari- Benchmarks are not perfect. They The 3DO console and Doom use ety of application-like programs that don’t actually measure what a particular texture mapping—in the case of the run in a certain period of time on a par- user is doing on a particular day. game, the technique makes players feel ticular platform. Instead, benchmarks use a standard like they are in a real three-dimensional The time it takes to execute these selection of operations that are sup- environment. Unfortunately, for various programs on a particular platform is posed to represent the core activity of reasons, texture mapping is slow, and measured and can be compared on a the average user. Thus, the goal of a poor quality texture mapping produces relatively fair basis to the time it takes benchmark is to reduce the potentially a variety of nasty artifacts unacceptable to execute them on another platform. infinite combination of operations to players. Usually, the time measured is used to (CPU instructions or graphics primi- So, you can generate a three- compute a standard unit number. The tives) down into a subset that represents dimensional pixel using one of these industry as a whole looks over the pro- a reasonable cross-section of application techniques or any combination of them. grams in the benchmark and decides in or user activities. Presumably, the rep- Figure 2 shows a three-dimensional some sense what is fair and what is not resentation of user activity is fair across pixel, which is the depth value and the fair. the variety of platforms available. x, y location taken together. The z value A similar concept exists in the cur- In the workstation arena, the is stored into a z buffer. A z buffer is a rent PC graphics benchmark area. three-dimensional benchmark is large chunk of memory dedicated to Benchmarks execute a series of graphics Graphics Performance Criteria (GPC). saving the last z or depth value for a instructions using a standard applica- It took 10 years and hundreds of engi- particular x, y location in the display. tion programmer interface (API) like neers to implement this benchmark. For every pixel in the display, there is a the graphics device interface (GDI) in The result is a magic number that you z or depth value. For a 1,280-by-1,024 Windows. The time it takes to perform can easily translate into frames per sec- display, there exist 1,310,720 pixels in the operation is measured. The mea- ond. GPC is essentially an application the frame buffer and the same number sured time is used to determine how environment with database traversal, of depth values. The biggest problem many operations the platform can do lighting, clipping, and rendering. On with a z buffer is that it increases the per second. So, numbers like 40 million PC platforms there exists a large num- amount of memory on the display sub- lines per second for a benchmark that ber of GPC-style applications—that is, system, and this cost is passed onto the measures line rendering using GDI are games. Most of the games in the PC consumer by a price increase. reasonable. already output frames per second. A Some benchmarks execute real perfect example of this is Domark’s What’s in a Benchmark? applications in a scripted environment Flight Simulator Toolkit, which lets the Traditionally, benchmarks comprised resulting in a time measurement. These user display the performance levels small applications that measure the per- benchmarks often produce a single while the game is running.

38 GAME DEVELOPER • JUNE/JULY 1995 Current Benchmarks form runs Doom II at five frames per graphics board is a level 19, then there In terms of three-dimensional graphics second, and another runs it at 60 is some amount of confidence that the benchmarks, do the 1 million flat-shad- frames per second. The higher-perfor- later model is faster for most Windows ed polygons per second really tell us mance Doom II platform is obvious. applications. anything about the performance of the With frames per second, there exists a The magic number also has console box? A number of key factors system-level performance measurement another effect, which isn’t necessarily are missing from such a claim, such as that is reliable for comparing different seen by the consumer. If the operating the database traversal, geometric trans- platforms. system environment saves the perfor- formations, clipping, and lighting. This The performance of rendering one mance criteria for the platform into performance claim relates to the final scene is computed by taking the various system information, then the game can stage of the three-dimensional pipeline, boxes shown in Figure 1, measuring the scale its displayed data appropriately. the rasterization stage. This stage only performance of each box, and summing For example, if a certain platform pro- measures the performance of the frame the results into one aggregate number. duces 10,000 texture-mapped polygons buffer memory subsystem. The separate numbers are as vital as the per second through the benchmark Chip designers and developers total result because they give us the then the application can choose to quote the memory subsystem band- ability to understand where the bottle- scale back the scene complexity to width in pixels per second, which you necks are and optimize the graphics match the platform metrics. You can can easily convert to polygons per sec- pipeline to achieve higher performance easily accomplish this by storing the ond once you know the area of the for the application. results of the benchmark in a system polygon. If the area of the polygon is Unfortunately, the hardware man- file and making it accessible to the quoted with the polygons per second, at ufacturer provides only the polygons- application. Microsoft has already least we can better understand the ras- per-second statistic, and that isn’t announced its use of this strategy to terization stage in the pipeline. enough. We only capture the last stage the game developer community. This element is missing from the in the three-dimensional application This system-wide performance quote of 1 million polygons per second. pipeline. What other information can information is very important, as certain The performance claims for the console the manufacturer supply that will allow games show us. For example, Tie Fight- box and the workstation mentioned us to interpolate a frames-per-second er lets the player activate an options previously should be modified to 1 mil- statistic? panel to change the rendering pixel lion flat-shaded, single-pixel polygons complexity at run time. Gouraud shad- per second vs. 100,000 flat-shaded, Playing the Game ing and other effects can be turned on or 100-pixel polygons per second. Now we A fair benchmark and the subsequent off, depending on the player’s choice. can compare the last portion of the published results allow the consumer a The game runs in a default mode that is pipeline on a relatively fair basis and level of confidence. They also allow the aimed at a 486 DX2/66. With system- then make a straightforward determina- run-time application to choose an level performance information stored in tion that the workstation is 10 times appropriate level of complexity in each an easily accessible form, Tie Fighter faster than the console. frame at run time. For the actual user, it can automatically choose the appropri- Given the area of the polygons, we appears that a “magic” number is most ate level of complexity using the bench- can compare the performance of the appropriate, but this number must be mark results for the platform. memory subsystem. A fair comparison based on a benchmark that exercises the This doesn’t remove the necessity between two platforms can only be entire graphics pipeline. Game develop- for the options panel, but it does allow made if the other stages have been com- ers must insist that a benchmark can be the application to start out in a more puted. Then a frames per second num- easily translated into a metric like “30 appropriate complexity level. At run- ber can be computed. frames per second at 1,024-by-768 at time, the game software reads the 256 colors per pixel.” benchmark information and relates it to Game Play Benchmarks The magic number model can be database complexity and rendering per- A unit of measurement for graphics published with the graphics board or formance, thus determining a “best rendering must address the application the actual game platform. These num- guess” at the frames-per-second number, level processing that takes place. This is bers give the consumer some guarantee which determines the game play criteri- consistent with benchmarks that exist of game play performance. This is the on. This idea can also be applied to other for CPUs (Dhrystones and Whet- same model that is applied to Windows areas of the platform. System-level per- stones) and for GDI (WinBench). performance today. If a graphics board formance data can cover CPU, video, Frames per second is a perfectly good or system has a WinBench 95 of 15 CD-ROM, audio, fax/modem, and unit of measurement for game play. then the consumer knows the platform other areas to provide the application With this type of performance is a good accelerator for the majority of with complete performance information metric, it is possible to say one plat- Windows applications. Also, if another about the run-time environment.

GAME DEVELOPER • JUNE/JULY 1995 39 GRAPHICS BENCHMARKS

Conclusion frame-per-second number from a poly- in an easily accessible form so that It is very difficult today to choose a gons-per-second quote if the area in games can adjust scene complexity dur- platform that runs the latest and great- pixels is also mentioned. Thus, chip ing run time. ■ est three-dimensional game with any vendors must be encouraged to publish certainty that the game will be numbers that are fully qualified, like playable. This is a problem the PC “100,000 lighted, clipped, texture- industry must solve. Game developers mapped, 50-pixel polygons per frame at and large companies such as Microsoft 65,536 colors per pixel on a PPC 604 are working on a solution. I mentioned processor.” With this quote, a game Stephen Johnson has been a computer that the benchmark solution for the PC developer can make an intelligent guess software engineer for the last 15 years. He should result in run-time game com- as to the resolution and complexity of has extensive background in C, C++, and plexity adjustment based on a system each frame in relation to the game. several different assembly languages as information accessible to the game. In The PC industry should adopt a well as experience with UNIX, MacOS, addition, the benchmark results for standard benchmark for games and MSDOS, and Windows. About a year platforms and graphics cards should be applications that use three-dimensional ago, a game called DOOM popped up on published and understood by users. graphics. The benchmark should be his home computer. After one intense Obviously, the best benchmark for similar to the GPC benchmark used in weekend of blowing away demons, he a game is the actual game itself, but the workstation industry in that it decided to change his career. Strangely that isn’t enough. Some type of stan- should measure the application-level enough he discovered that writing game dard benchmark criteria must exist that performance and not just the memory software is way more fun than game developers and players can rely subsystem of the graphics device. If a CAD/CAM drafting packages. He cur- on for fair comparison between plat- “magic” number is used then it should rently resides at Diamond Multimedia, forms. The current performance num- easily translate into scene complexity where he is bringing high-resolution, bers of polygons per second usually and the various stages of the graphics high-performance three-dimensional only measure the memory subsystem pipeline. This magic number informa- graphics to every Windows user he can performance. It is possible to guess at a tion should be stored with the platform find.

40 GAME DEVELOPER • JUNE/JULY 1995 GETTING STARTED WITH VESA

Getting Started with VESA Graphics

Table 1. VESA Mode Numbers ave you seen some of the tal monitors. Manufacturers rushed to games that have come out outdo each other with 256 colors at 640- VESA recently? A new trend is afoot by-480, then 800-by-600, and 1,024-by- MODE in the game industry. Games 768 pixels. Chip makers added another NUMBER TYPE RESOLUTION COLORS are moving away from 320- wrinkle when they developed DAC by-200-pixel graphics to 640- chipsvesa capable of pumping out 16-bit and 100h GRAPHICS 640x400 256 by-480 and higher resolutions. 24-bit color. IBM tried to reassert itself 101h GRAPHICS 640x480 256 102h GRAPHICS 800x600 16 For a long time now, we’ve with the XGAbios graphics adaptor, but it 103h GRAPHICS 800x600 256 seenH game after game with a screen reso- was too little, too late. 104h GRAPHICS 1024x768 16 lution of 320-by-200 pixels—first with Lacking an IBM standard to 105h GRAPHICS 1024x765 256 EGA’s 16 colors and then VGA’s 256 mimic, each manufacturer was 106h GRAPHICS 1280x1024 16 colors. In this article I’ll introduce you to on its own when it came to implement- 107h GRAPHICS 1280x1024 256 the force that’s making this upward ing high- resolution modes. The result graphics mobility in games possible and was a complete lack of consistency 108h TEXT 80x 60 16 practical: VESA BIOS extensions. between video cards in mode numbers, 109h TEXT 132 x 25 16 In the beginning of the PC world, extended registers, and drivers. Each 10Ah TEXT 132 x 43 16 IBM vesawould introduce a display adapter, manufacturer was responsible for devel- 10Bh TEXT 132 x 50 16 and it would automatically become the oping drivers for popular programs and 10Ch TEXT 132 x 60 16 standard to bioswhich developers wrote pro- providing documentation to software 10Dh GRAPHICS 320x200 32K grams. First came the CGA in 1982, fol- developers. And to be honest, software 10Eh GRAPHICS 320x200 64K lowed by the EGA in 1985, and the developers were pretty low priority for 10Fh GRAPHICS 320x200 16M MCGA and VGA in 1987. Games and most video card makers. 110h GRAPHICS 640x480 32K other graphics programs adapted to the The only glimmer of hope for using 111h GRAPHICS 640x480 64K new video standard, compilers added a card’s high-resolution modes was pro- 112h GRAPHICS 640x480 16M built-in support, and the world was an vided by Microsoft’s Windows. As Win- 113h GRAPHICS 800x600 32K orderly place for developers. dows 3.0 and then 3.1 became an indus- 114h GRAPHICS 800x600 64K So what happened to produce the try juggernaut, it forced manufacturers to 115h GRAPHICS 800x600 16M video card Tower of Babel that we have make Windows video drivers a priority. 116h GRAPHICS 1024x768 32K today? IBM brought out the 8514/A dis- With a Windows video driver, any Win- 117h GRAPHICS 1024x768 64K 118h GRAPHICS 1024x768 16M play adaptor and users and developers dows program could take full advantage 119h GRAPHICS 1280x1024 32K gave it a big thumbs down. of the video card’s enhanced graphic 11Ah GRAPHICS 1280x1024 64K But the maturing PC industry capabilities. The only drawback—Win- 11Bh GRAPHICS 1280x1024 16M didn’t sit still for IBM. In the absence of dows was anything but an ideal choice a standard that the market was eager for, for graphics-intensive games. Microsoft’s * 32K color modes have 1 unused bit, video card manufacturers rushed in to WinG may bridge that shortfall in the and 5 bits of Reg,Green, and Blue data. provide their own solutions. First came future, but up to this point, games have * 64K color modes have 5 bits of Red enhanced EGA cards with resolutionsvesapretty much been forced to stick with and Blue data and 6 Bits ofGreen data. up to 800-by-600 pixels, which were DOS and the VGA standard. * 16M color modes (true color) have 8 quickly swept away by a new wave of biosTo alleviate this problem, the Video bits each of Red, Green, and Blue VGA-compatible cards that took full Electronics Standards Association data. advantage of analog VGA monitors, (VESA) was founded in 1989 as a non- which were rapidly replacing TTL digi- profit organization to set and support

42 GAME DEVELOPER • JUNE/JULY 1995 Matt Pritchard industry-wide open standards for the PC space, some new cards don’t have a com- environment. Starting in August 1989 plete VESA VBE implementation in with a standard mode number for 800- their ROMS. For older cards, the manu- by-600, 16-color Super VGA graphics, facturer can provide a driver that is VESA was founded to VESA has been busy working with the placed in the AUTOEXEC.BAT or PCVESA terms standards for video and CONFIG.SYS that augments the card’s related items. VESA came up with a sys- ROM BIOS and provides the VESA tem of extensions to the normal VGA VBE specific functions that reside in create industry-wide BIOS that manufacturers could retrofit RAM. Or a third-party driver, such as to existing cards. In October 1991, the SciTech Software’s UniVBE program, organization released the VESA BIOS vesacan provide the VESA VBE either as a Extension (VBE) standard, version 1.2. TSR or library that can be directly linked To keep up with evolving video cards, into a program, providing VESA VBE open standards for and the shift to pro- biosservices only while that program is run- grams, the VBE 2.0 standard was ning. In many cases, especially with older released in November 1994. video cards, some ROM BIOSes and Well, all this history is nice to drivers have bugs or are missing features, the PC environment. know, but by now you may be asking with hardware panning being the biggest “What’s in it for me, the game software culprit. In these cases, a third party driver developer?” The answer is simple: A sin- usually works better than the manufac- gle, clearcut method for using high-reso- turer supplied driver or ROM BIOS. By applying these vesalution video modes on most of the video The major features that VESA cards out there today. The rest of this VBEs provide are: biosarticle will give you an overview of what • A consistent way to identify a video VESA BIOS extensions can give your card, how much memory it has, and standards, develop- software, how they work, and how you what video modes and features it is go about coding them. capable of. • A consistent way to set high resolu- VESA Terms and Features tion (super VGA) video modes. ers have the benefit For starters, we need to clarify our terms. • A consistent way to access all of the VESA has developed many standards for memory on a video card through a power management, sound, hardware “window” of memory, usually at seg- and I/O bus interfaces and PC Videos ment A000. BIOSes. This article only covers VESA • A consistent way to save and restore of a universal method Video BIOS standardsvesa known as Video super VGA Modes. BIOS Extensions or VBE for short. • A consistent way to set logical screen A video card can providebios Video sizes and page-flip Super VGA BIOS extensions in different ways. The modes. for using high-reso- ROM BIOS physically on the video card • A consistent way to access video can support the VESA VBE 1.2 or 2.0 DAC registers, including 8-Bit features directly. Most new video cards DACs and DACs that are not VGA do this. However, due to limited ROM compatible. lution video modes.

GAME DEVELOPER • JUNE/JULY 1995 43 GETTING STARTED WITH VESA

The VESA VBE 2.0 standard Listing 1. VESACHK.C (Continued on p. 45) added two major features: • Support for fast direct access to /* ======*/ /* VESACHK.C - Check for VBE Extension and report mode available */ VESA VBE function from protected- /* ======*/ mode programs. • Support for direct access to all video #include #include memory in the form of a Linear #include Frame Buffer, accessible from pro- tected mode. #define uchar unsigned char #define uint unsigned int

Accessing VESA typedef struct { VBE Features /* These items defined in the VESA VBE 1.2 Spec */ All VESA VBE functions and features are accessed through the INT 10h inter- char Vbe_Signature[4]; /* “VESA” */ face. For programmers unfamiliar with int Vbe_Version; /* Vesa version * char far * Oem_String_Ptr ; /* Name of Video Card */ this process, allow me to explain. In uchar Capabilites[4]; /* Bitmapped features */ addition to traditional hardware inter- uint far * Video_Mode_Ptr; /* >List of Video Modes */ rupts, the Intel CPU design allows for int Total_Memory; /* Video Mem / 64K */ software to issue interrupts. Software /* These items added in the VESA VBE 2.0 Spec */ interrupts are numbered from 0 to 255 and allow a program to call a function int Oem_Software_Rev; char far * Oem_Vendor_Name_Ptr; without knowing where it is in memory. char far * Oem_Product_Name_Ptr; Interrupt number 10h (16 decimal) is char far * Oem_Product_Rev_Ptr; used to access video BIOS services. uchar reserved[222]; /* From the 1.2 spec */ These services can be in the video card’s uchar Oem_Data[256]; /* VBE 2.0 OEM strings */ ROM, DOS, or a driver loaded into RAM and can be chained together. } VbeInfoBlock; To call a Video BIOS function, the int get_VESA_version(VbeInfoBlock far* , int*, int*); function’s number is put into the CPU’s AX register and any parameters are put void main ( void ) { in the other CPU registers in a manner that is function specific. Then the INT VbeInfoBlock VESA_Info; 10h instruction is executed. The CPU int VESA_Version, MajorVer, MinorVer, Mode; uint far * Mptr; transfers control to the interrupt handler which processes the selected function VESA_Version = get_VESA_version(&VESA_Info, &MajorVer, &MinorVer); and returns tovesa the program just as if a if (VESA_Version) { normal function call had taken place. printf (“This video card has VBE version %d.%d extensions.\n”, MajorVer,MinorVer); The starting placebios for any VESA- printf (“The Card Name is ‘%Fs’\n”,VESA_Info.Oem_String_Ptr); aware program is determining if there /* Display List of Available Modes */ are VESA BIOS Extensions available to program. All VBE function numbers printf (“\nThe Following Modes are supported:\n”); have the value 4Fh in the AH register and Mptr = VESA_Info.Video_Mode_Ptr; while ( (Mode = *Mptr++) != 0xFFFF) { the actual function number in the AL reg- printf (“mode %4.4xh “,Mode); ister (The AH and AL registers make up } the AX register). printf(“\n\n”); The VBE function to return Super } else { VGA information is number 0, and printf (“This video card does not have VESA BIOS support\n”); before you can call it, you must have a } buffer into which VESA information can be put. The VBE 2.0 standard } increased the size of the buffer from int get_VESA_version( VbeInfoBlock far* VESA_Info,int * MajorVer, int * MinorVer ) 256 to 512 bytes, but to keep older { VESA programs from breaking you must put the four-character string VBE2 union REGS in_regs, out_regs; at the start of the buffer to get the VBE

44 GAME DEVELOPER •JUNE/JULY 19954 Listing 1. VESACHK.C (Continued from p. 44) The mode information block returned by function 01h contains a struct SREGS seg_regs; wealth of information about how to int ver, m; actually use that mode. That information /* Prepare VESA info Buffer */ includes: • Whether the mode is text or graphics, memset( VESA_Info, 0, 512); memcpy( VESA_Info->Vbe_Signature, “VBE2”, 4); monochrome or color. • Whether the BIOS text functions are /* Call Int 10, VBE Function (4F)00h */ available in that mode. in_regs.x.ax = 0x4F00; • The screen resolution and character seg_regs.es = FP_SEG(VESA_Info); cell sizes. in_regs.x.di = FP_OFF(VESA_Info); • The memory access model and pixel int86x(0x10, &in_regs, &out_regs, &seg_regs); layout used by that mode. • The addresses and sizes of the memo- /* Check if VBE Extions present & Get Revision Level */ ry regions usedvesa to read and write data if ( (out_regs.x.ax != 0x004F) || in that mode. (memcmp(VESA_Info->Vbe_Signature, “VESA”, 4) != 0) ) • Whether or not the VGA DAC can { be used in that mode. return 0; } else { ver = VESA_Info->Vbe_Version; VESA Memory Addressing *MajorVer = (ver >> 8); The whole point of using VESA Video /* bug check - Some BIOSes return 0x0102 instead of 0x0120 */ BIOS extensions is so that you can write /* Check for Minor version in wrong nibble and correct */ a program that doesn’t have to know a thing about the video card in your sys- m = (ver & 0xFF); if ((m != 0 ) && ((m & 0x0F) != 0)) { tem yet can still blast data to the screen *MinorVer = m * 10; at full speed. } else { Making a VESA VBE-aware pro- *MinorVer = (m >> 4) * 10; } gram requires some extra work on the return ver; part of the programmer, especially in the } area of graphics memory addressing and } pixel data organization. To make one or more megabytes of video memory acces- sible, VESA allows for one or two “win- 2.0 specific additional information. card, numbered from 14h to 7Fh, along dows” into video memory of up to 64K After calling the Video BIOS, if the AX with mode numbers that VESA has des- to be mapped into the CPU’s address register has the value 004Fh in it, then ignated to be standard on all cards, 100h space. your BIOS has VESA extensions, oth- to 11Bh. Because of this, it is possiblevesa for In practice, this usually means a erwise it doesn’t. Listing 1 is a function a mode to be listed under two different 64K window at segment A000, but there written in Borland C 3.1 that can tell mode numbers, both equally valid. See is no guarantee—you need to look. It’s you what version of VESA extension Table 1 for a list of standard VESAbiospossible two independent 32K win- your card supports, if any, and what mode numbers. dows might exist at segments A000 and VESA display modes it has. Now, just because a mode number A800. Or you might find two overlap- Once you know that your video is listed doesn’t mean that the mode is ping 64K windows at segment A000— card supports VBE, you still need to find actually supported (for example, there one for reading data from one part of out what video modes your card actually may not be enough video memory). To video memory and another for writing supports. Two pieces of informationvesa in check out the modes you want to use, data to a different section of video the VESA information buffer do this for you call VBE function 01h, return Super memory. you. The first is the Total_Memory word, VGA mode information. You must provide To access all of video memory VBE which returns the amount of actualbiosa 256-byte buffer for information to be function {05h, Display Window Control} memory on the video card in 64K returned in. If AX comes back with any- lets you change the position in video blocks. The second is the thing other than 004Fh then the mode is memory that the window accesses. This Video_Mode_Pointer, which is a pointer to not available. If AX is 004Fh and the first is also known as “bank switching.” One a list of video modes that the card sup- bit of the first word in the buffer thing you can count on varying from ports. The mode numbers can include (Mode_Attributes) is 0, then the mode is card to card is the window granularity. modes that are unique to your video not available. Window granularity is the “coarseness”

GAME DEVELOPER • JUNE/JULY 1995 45 GETTING STARTED WITH VESA

by which the window can be positioned MORE INFO in video memory. Some cards can let you move the window address around in 1K ciTech Software makes a VESA VBE 2.0 compatible “universal” driver that sup- increments while others can only move ports over 160 different graphics chips. Its VBE driver is available in TSR form as 32K or 64K at a time. Your drawing shareware for end users or developers. Linkable library versions are also avail- able for software developers. For more information contact SciTech at (916) 894- code will have to take into account that 8400 or via e-mail at [email protected]. some cards may need to switch banks in S the middlevesa of drawing while others For more information about VBE contact Kevin Giliett at VESA. The VESA VBE 1.2 and 2.0 won’t. For speed considerations, bank Specs can also be ftp’ed on the internet from x2ftp.oulu.fi. Write to VESA at 2150 N. First switching is the onlybios operation that you St., Ste. 440, San Jose, Calif. 95131-2029 or call (408) 435-0333. don’t need to execute an interrupt to access. The VBE can give your program the address of a direct function to switch tional need is to use bank switching to Dword (4-byte) boundary, while another banks for the current video mode. move the currently needed portion of might require paragraph (16-byte) For protected mode programs, video memory into the access window. boundaries. In true color modes, the VBE version 2.0 opens up a whole new For high-color and true-color modes, pixel size is usually 3 bytes with no set of possibilities. With the advent of you need to do more work. The size andvesaunused bytes. So unless the screen start local bus architectures, it became popular position of each color component can position is a multiple of 4 pixels (12 among video card manufacturers to sup- vary and your drawing code will need to biosbytes), the display would start in the port linear frame buffers. A linear frame adapt to the different layouts. For exam- middle of a pixel, scrambling the color buffer is where a block of very high ple, many new cards use 32-bit pixels for data stream! Fortunately, page flipping memory addresses are directly mapped 24-bit true color modes for higher inter- can avoid this easily by starting each into the card’s video memory, eliminat- nal performance. Fortunately, the VBE page on a large boundary such as 4K. ing the need for bank switching entirely. mode information block contains Smooth panning, on the other hand, Some cards offer both modes of memory detailed information on the layout of suffers badly on some cards. access, others just one. Developers pixels in these modes. Listing 2 demon- should expect linear frame buffers to strates drawing simple patterns using the Palette Functions become the preferred method of video VESA 640-by-480 256-color mode. VESA VBEs also provide palette func- memory access in the years ahead. tions. Two aspects of the palette func- Panning and Page Flipping tions make them more desirable than the Reading and One of the biggest benefits of VBEs for traditional method of program the VGA Writing Video Memory game programs is that it makes possible card directly. The first is that the VGA Once you have gotten through VESA page-flipping and smooth, high-resolu- Palette registers don’t work in super mode selection and memory addressing, tion animation. VBE functions are pro- VGA modes on some newer cards, while actually reading and writing image data vided to let the program change the logi- using the VBE palette functions does. is anticlimactic. The most common cal width of a scan line and select the The second benefit is that VESA VBEs memory layout for 256-color modes is position in video memory from which provide access to 8-bit DACs on cards identical to mode 13h. The only addi- the screen display starts. Just like in that have them. Normal VGA DAC Mode X, these features registers only have 6 bits of color data Table 2. VESA VBE Functions (AH = 4FH) let programs scroll the per color, but most newer cards can screenvesa and use double process 8 bits of color data per color. AL= Function Description VBE Revision and triple animation Using 8-Bit DACs allows for smoother buffering.bios looking color ranges and color effects. 000h Return VBE Controller Information 1.2 These functions 01h Return VBE Mode Information 1.2 are simple to use, but Conclusion 02h Set VBE Mode 1.2 there are some catches. A well written VESA-aware program 03h Return current VBE Mode 1.2 Different video cards should have few problems running high 04h Save/Restore VBE Mode State 1.2 have different limits on performance graphics on video cards that 05h Display Memory Window Control 1.2 06h Set/get Logical Scan Line Length 1.2 how small an adjust- have yet to be introduced, including the 07h Set/Get Display Start 1.2 ment can be made to increasing number of cards that do not 08h Set/Get DAC Palette Control 1.2 line widths and screen have a VGA-compatible core for their 09h Set/Get Palette Data 2.0 start position. For high-resolution graphic modes. 0Ah Return VBE example, a card may If I may share an observation from Protected-Mode Interface 2.0 only allow the start experience, when making a VESA VBE- position to be on a aware program for the first time, you

46 GAME DEVELOPER • JUNE/JULY 1995 GETTING STARTED WITH VESA

Listing 2. VESADEMO.C (Continued on p. 49)

/* ======*/ char Red_Mask_Size; /* VESADEMO.C - A simple 640x480 VESA Graphics Demo */ char Red_Field_Position; /* ======*/ char Green_Mask_Size; char Green_Field_Position; #include char Blue_Mask_Size; #include char Blue_Field_Position; #include char Rsvd_Mask_Size; char Rsvd_Field_Position; #define uchar unsigned char char Direct_Color_mode_Info; #define uint unsigned int /* This section available is VBE revision 2.0 & up */ /* Stucture to hold VESA VBE Get SVGA Info Results */ void far * Physical_Base_Ptr; typedef struct { void far * Off_Screen_Mem_Offset; int Off_Screen_Mem_size; /* These items defined in the VESA VBE 1.2 Spec */ char Reserved[206]; char Vbe_Signature[4]; /* “VESA” */ int Vbe_Version; /* Vesa version */ } ModeInfoBlock; char far * Oem_String_Ptr; /* Name of Video Card */ uchar Capabilites[4]; /* Bitmapped features */ /* Global Registers for calling INT 10h */ uint far * Video_Mode_Ptr; /* >List of Video Modes */ int Total_Memory; /* Video Mem / 64K */ union REGS in_regs, out_regs; struct SREGS seg_regs; /* These items added in the VESA VBE 2.0 Spec */ /* Function Prototypes */ int Oem_Software_Rev; char far * Oem_Vendor_Name_Ptr; int get_VESA_version(VbeInfoBlock far* , int*, int*); char far * Oem_Product_Name_Ptr; int check_VESA_Mode(int, ModeInfoBlock far* ); char far * Oem_Product_Rev_Ptr; int set_VESA_Mode(int);

uchar reserved[222]; /* From the 1.2 spec */ void main ( void ) uchar Oem_Data[256]; /* VBE 2.0 OEM strings */ {

} VbeInfoBlock; VbeInfoBlock VESA_Info; ModeInfoBlock MODE_Info; /* Stucture to hold VESA VBE Get Mode Info Results */ int VESA_Version, MajorVer, MinorVer; typedef struct { /* Check if VESA Video BIOS Extension installed */ /* This section available is all VESA revisions */ if (!(VESA_Version = get_VESA_version(&VESA_Info, uint Mode_Attributes; &MajorVer, &MinorVer))) { uchar Win_A_Attributes; /* Memory Window A */ printf (“Unabale to run demo.\n”); uchar Win_B_Attributes; /* Memory Window B */ printf (“This video card does not have VESA BIOS support\n”); int Win_Granularity; /* in 1K units */ return; int Win_Size; /* Window Size in K */ } uint Win_A_Segment; /* Segment of Window A */ uint Win_B_Segment; /* Segment of Window B */ /* Check if Mode 101h is available */ void far * Win_Func_Ptr; /* Bank Switch func addr */ int Bytes_Per_Scan_Line; /* just what it says */ if (!check_VESA_Mode(0x0101, &MODE_Info)) { printf (“Odd... This card has VESA BIOS extension but no “ /* This section available is VBE revision 1.2 & up */ “support for mode 101h\n”); return; int X_Resolution; } int Y_Resolution; char X_Char_Size; /* Set display to VESA Mode 101h */ char Y_Char_Size; char Number_Of_Planes; set_VESA_Mode(0x0101); char Bits_Per_Pixel; char Number_Of_Banks; /* Draw our Test pattern and wait for a keypress */ char Memory_Model; char Bank_Size; draw_VESA_triangle_pattern(&MODE_Info,640,480); char Number_Of_Image_Pages; char Reserved1; /* restore */

/* This section is used for Memory_Model 0x06 and 0x07 i.e. Direct set_VESA_Mode (0x03); Color and YUV color modes */ printf (“this VESA 640x480x256 demo is done.\n”);

48 GAME DEVELOPER • JUNE/JULY 1995 Listing 2. VESADEMO.C (Continued from p. 48)

return; “VESA”, 4) != 0) ) } { return 0; /* Function to get VESA VBE Mode Info for a given mode */ } else { ver = VESA_Info->Vbe_Version; int check_VESA_Mode(int Mode_Num, ModeInfoBlock far* MODE_Info) *MajorVer = (ver >> 8); { /* bug check - Some BIOSes return /* First we get info on the desired mode */ 0x0102 instead of 0x0120 */ /* Check for Minor version in memset( MODE_Info, 0, 256); /* Clear Mode Info */ wrong nibble and correct */

in_regs.x.ax = 0x4F01; /* Get mode Info Function */ m = (ver & 0xFF); in_regs.x.cx = Mode_Num; /* Mode number */ if ((m != 0 ) && ((m & 0x0F) != 0)) seg_regs.es = FP_SEG(VESA_Info); /* Buffer to hold results */ { in_regs.x.di = FP_OFF(VESA_Info); *MinorVer = m * 10; } else { int86x(0x10, &in_regs, &out_regs, &seg_regs); *MinorVer = (m >> 4) * 10; } if (out_regs.x.ax != 0x004F) { /* Did an Error occur? */ return ver; return 0; } } else { } return Mode_Num; }

}

/* Function to perform VESA VBE Mode Set */ should start by getting the VESA VBE 1.2 and 2.0 specifications and studying int set_VESA_Mode(int Mode_Num) { them. Then I heartily recommend that you obtain other VESA VBE code and in_regs.x.ax = 0x4F02; /* Get mode Info Function */ study it. VBE support varies and the in_regs.x.bx = Mode_Num; /* Mode number */ specifications leave some room for inter- int86x(0x10, &in_regs, &out_regs, &seg_regs); pretation. For example: Where the VBE 2.0 says “All other registers are pre- if (out_regs.x.ax != 0x004F) { /* Did an Error occur? */ printf (“Error attempting to set Mode %xh\n”, Mode_Num); served,” many VBEs still trash the high return 0; words of extended registers. Another } else { example is that some VBEs return a return -1; } value of 0 for a window granularity of 64K instead of returning 64. } There is a wealth of information int get_VESA_version( VbeInfoBlock far* VESA_Info, and detail involved in using VESA Video int * MajorVer, int * MinorVer ) BIOS Extensions, and we didn’t have { room in one article to cover it all. I do int ver, m; hope you now have an idea of what you’ll be facing when you develop a program /* Prepare VESA info Buffer */ that uses VESA graphic modes. Making memset( VESA_Info, 0, 512); the effort to use VESA VBEs can bring memcpy( VESA_Info->Vbe_Signature, “VBE2”, 4); great rewards to the developers who want their programs to stay on the cutting /* Call Int 10, VBE Function (4F)00h */ edge. Until next time, happy coding! ■ in_regs.x.ax = 0x4F00; seg_regs.es = FP_SEG(VESA_Info); in_regs.x.di = FP_OFF(VESA_Info); Matt Pritchard is presently launching int86x(0x10, &in_regs, &out_regs, &seg_regs); his software company Innovatix in Gar- land, Texas, and is the author of /* Check if VBE Extions present & Get Revision Level */ MODEX105, a comprehensive freeware if ( (out_regs.x.ax != 0x004F) || ModeX library. You can reach him via e- (memcmp(VESA_Info->Vbe_Signature, mail at [email protected] or through Game Developer magazine.

GAME DEVELOPER • JUNE/JULY 1995 49 CHOPPING BLOCK

Wing Commander III

Wayne Sikes n this edition of the Chopping nology—which was used in other Ori- Block, I review Wing Comman- gin games such as Privateer, Strike der III by Origin Systems Inc. Commander, and Pacific Strike— There are a lot of This technical review contains mixed with advanced polygonal rou- minor spoilers. Wing Comman- tines created specifically for Wing der III is the third installment in Commander III. the Wing Commander series. fighter pilot games out This version is far more techno- This Is A Big Game! logicallyI advanced than previous Wing The combined English, French, and Commander episodes. Game features German versions of Wing Commander include SVGA digitized movies using III comes on four CD-ROMs. Total well-known actors at the game intro distribution size is about 2.3 gigabytes. there these days. and end as well as in all cutscenes; the The Wing Commander III executable graphic engine uses polygon-based, (WC3.EXE) plus several primary data texture-mapped VGA and SVGA files are duplicated on each CD-ROM; graphics, which result in impressive, the unique data files require over 1.8 Wayne Sikes navigates realistic looking spacecraft; the user gigabytes of CD-ROM storage space. interface has a clean simple layout and The movie files are by far the largest is easy to use; and the General MIDI files in the game and range in size from soundtrack and digitized sound effects 108MB to 408MB. through Origin‘s Wing add a full layer of realism and excite- Installing Wing Commander III is ment to the game. Wing Commander quite an extensive process. To mini- III appears to use a combination of mize data file loading times during Commander III, the Origin’s trademarked RealSpace tech- game play, a full installation is required third release of the Wing Commander series, and it mea-

The latest addition to the Wing Commander series features more technologically advanced sures up impressively. graphics that allow for impressive, realistic looking spacecraft.

GAME DEVELOPER • JUNE/JULY 1995 51 CHOPPING BLOCK

Listing 1. General TRE File Format undocumented keystrokes while explor- ing game operation, and I’ll summarize FILE DATA them further on. OFFSET SIZE DESCRIPTION

0-3 char “XTRE” char string. Data Storage 4-7 char Blanks. 4 bytes of 00. Essentially all of the game data is stored 8-11 long Starting Offset of the Indirect Record Pointer Table. in files suffixed with TRE. (I will refer 12-15 long Starting Offset of the Path Name Table. to these data files as TRE files.) TRE 16-19 long Starting Offset of the Record Pointer Table. 20-23 long Offset of the first Data Record in this TRE file. files use a very flexible, open-ended 24-(xx-1) var Indirect Record Pointer Table. This table contains indirect data storage format that allows for very pointers, or “pointers to pointers”. The values in this table large files. You can store hundreds of point into the Path Name Table or into the Record Pointer megabytes of data in a single TRE file. Table. xx-(yy-1) var Path Name Table. Table of variable-length records containing Listing 1 gives a general summary system path names and other path-related data. of the TRE file format. The first four bytes in the file contain the XTRE yy-(zz-1) var Record Pointer Table. This table consists of structures ASCII text string. The XTRE string containing the file offsets and sizes of the Data Records in this TRE file. possibly indicates this file contains cross-referenced data records. The bytes zz-EOF var Individual Data Records. at offsets 8 to 23 contain four pointers. The first three pointers give the file off- NOTES: 1. var refers to data having variable sizes. sets (offsets into the TRE file with the 2. xx is the Starting Offset of the Path Name Table. first byte in the file referenced as byte 3. yy is the Starting Offset of the Record Pointer Table. 0) of three data tables. The fourth 4. zz is the Offset of the First Data Record. pointer gives the offset of the first Data 5. EOF refers to the end of the file. Record in the file. The first data table in the TRE file, the Indirect Record Pointer Table, contains pointers (file offset values) that and uses about 40MB of hard disk swap file is created when Wing Com- reference data in the other TRE file space. A VESA driver is required for mander III is booted and erased when data tables. In C nomenclature, the SVGA graphics. Because Wing Com- you exit the game. (This file is erased Indirect Record Pointer Table contains mander III is such a large game and when you exit the game via the Alt-X pointers to pointers. The Indirect weighs heavily on system resources, it is keystrokes. So be sure to erase the swap Record Pointer Table entries “point” to no surprise that many users have had file from your Wing Commander III various “pointers” contained in other trouble installing it. (I experienced hard drive subdirectory if you exit the TRE file tables. Each entry in this table installation troubles because the size of game using any other method such as is an 8-byte structure. The first four my CD-ROM drivers combined with a rebooting your PC.) bytes are bit flags and the last four bytes Pro Audio Spectrum driver exceeded The primary Wing Commander contain the pointer expressed as a 32- the minimum conventional memory III executable, WC3.EXE, is about bit long value. I observed that the Indi- requirements for my 8MB RAM sys- 1.1MB in size. Wing Commander III rect Record Pointer Tables of several tem. The game features a boot disk cre- was developed using the MetaWare TRE files had “blanks” or empty data ation routine that solved my memory High C/C++ system and is written pri- slots. As I mentioned earlier, the TRE management problems.) marily in C++. (The MetaWare High C file format is flexible and expandable, Wing Commander III requires a system features C++ templates and a and these empty data slots are probably minimum of 360K conventional RAM compiler for developing 32-bit protect- part of this expandable format. plus 7,000K of either extended or ed mode applications.) The WC3.EXE The Path Name Table follows the expanded memory. Access to memory game engine includes a built-in Exami- Indirect Record Pointer Table. Embed- above 640K is provided by Origin’s cus- nation Mode that provides general ded in this table are the ASCII text tom JEMM.OVL protected mode development and debugging informa- strings of the source paths along with (DPMI), 32-bit driver. Virtual memory tion while the game is running. Devel- binary (possibly file offset) data related is emulated through the use of a swap opers can observe the status of the to each path name. file named SWAPFILE.$$$. The size numerous game engine flags, accumula- The Record Pointer Table follows of the swap file is generally determined tors, stack manipulation calls, and game the Path Name table. The Record by the amount of free hard disk space, flow data such as act, scene, and mis- Pointer Table contains the file offsets and it is usually 15MB to 20MB. The sion information. I found several and sizes of the Data Records stored in

GAME DEVELOPER • JUNE/JULY 1995 53 CHOPPING BLOCK

the TRE file. The offset and size of up table containing the file names of gin’s IFF file format. This format is each Data Record is contained in an the Wing Commander III missions. discussed in the next section. Listing 2 eight-byte structure. The first four The game engine opens the GAME- gives a summary of the Wing Com- bytes of each structure give the offset of FLOW.TRE file and reads down the mander III mission file names that the Data Record as a long value and the list of entries in the Indirect Record we’ve extracted from the look-up table. last four bytes contain the long size. Pointer Table until it finds the entry The individual Data Records follow corresponding to our mission file name IFF File Formats these tables. These Data Records vary in look-up table. The engine reads the hex Origin has used the IFF file format in size from just a few bytes to several values 62 2b 01 3f 84 07 00 00. As the several games including Privateer, thousand bytes and contain the actual Indirect Record Pointer Table entries Strike Commander, and Pacific Strike game data—fonts, palettes, space and showed us, the 62 2b 01 3f values are (see “Bandits at 0x1200 High!” Chop- vehicle graphics, mission data, game bit flags and the 84 07 00 00 bytes con- ping Block, Dec. 1994, for a discussion flow data, artificial intelligence informa- tain the long pointer. of the IFF files used in Pacific Strike). tion, and so on. Some of the game data The data beginning at hex offset To summarize the IFF file format, an is stored in IFF format, which I’ll cover 784 (don’t forget about the PC’s method IFF file is composed of one or more in the next section. of storing data in low byte and high forms, with each form containing one Does the TRE file structure seem byte format) references an entry in the or more records. The following general a bit confusing? Although somewhat Record Pointer Table that reads as ae 13 rules are used in IFF file formatting: difficult to understand, this file format f4 00 ac 04 00 00. Keeping in mind that • All forms have a header consisting of is cleanly organized. Basically, the the Record Pointer Table contains the the “form” text string followed by a entries in the three data tables at the file offset and size of the actual Data 4-byte number. This number is the top of a TRE file reference—or point Record, you’ll see the data for the mis- number of data bytes in the form. to—all the Data Records found in the sion file names is stored at hex offset • All records have a header consisting TRE file. In other words, these tables f413ae and is 4ac (hex) bytes in size. If of a record name (that can be up to tell the game engine where to find the you verify my example by looking in the eight bytes of text characters) fol- desired data. GAMEFLOW.TRE file for the mis- lowed by a 4-byte number. This As an example, let’s trace the path sion file names, you will see these number is the number of data bytes the game engine follows to find a look- names (as ASCII text) listed using Ori- in the record. • Records can be located both inside and outside of a form. Listing 2. The Mission Look-Up Form Mission Ordering RECORD NAME RECORD DATA (MISSION FILE NAMES) Refer to Listing 2 and examine the hex code that include the mission file name LOOK0000 0001 0002 0003 misna001 misna002 misna003 misna004 0004 0005 0006 0007 misnb001 misnb002 misnb003 misnb004 look-up table we discussed previously, 0008 0009 0010 0011 misnc001 misnc002 misnc003 misnc004 and you will notice that each mission is 0012 0013 0014 misnd001 misnd002 misnd003 referenced by a unique record name and 0015 0016 0017 misne001 misne002 misne003 data group. Each mission record name 0018 0019 0020 misnf001 misnf002 misnf003 0021 0022 0023 misng001 misng002 misng003 is a text number and the data is a text 0024 0025 0026 misnh001 misnh002 misnh003 file name. For example, mission 0014 is 0027 0028 0029 misni001 misni002 misni003 stored in file misnd003. 0030 0031 0032 misnj001 misnj002 misnj003 The first mission’s record name is 0033 0034 0035 misnk001 misnk002 misnk003 0036 0037 0038 0039 misnl001 misnl002 misnl003 misnl004 LOOK0000 (file name misna001) and the last 0040 0041 0042 misnm001 misnm002 misnm003 mission’s record name is 0066 (misnp000). 0043 0044 0045 misnn001 misnn002 misnn003 The missions are generally grouped 0046 0047 0048 misnp001 misnp002 misnp003 according to the space system in which 0049 0050 misnr001 misnr002 0051 misnb2ne they are located. For example, missions 0052 misnc2ne 0036 (misnl001) through 0039 (misnl004) 0053 misnd3bd occur in the Alcor System. 0054 misnd1b Even though the missions have 0055 0056 0057 0058 0059 0060 tsim001 tsim002 tsim003 tsim004 tsim005 tsim006 0061 misnl01d record names giving a one-up order, the 0062 0063 0064 0065 tsim007 tsim008 tsim009 tsim010 game engine does not play the missions 0066 misnp000 in the specified order. The order in which the missions are played is deter- mined by how well or how poorly the

54 GAME DEVELOPER • JUNE/JULY 1995 player is performing. For example, cussed. The Ctrl-F keystroke toggles seeable future. The beauty of its graphic assume you, the player, are doing poorly the readout of the current frame rate in renderings combined with a good, well- and you fail to complete mission 0039 frames per second. The Ctrl-M, Ctrl-J, acted storyline combine to create a clas- (misnl004). (Mission 0039 requires that and Ctrl-K keystrokes select the mouse, sic game. I can honestly say that very you fly down to Alcor V, take out all the joystick, or the keyboard, respectively, few games hold my attention long ground installations, and rescue the sci- as your primary flight control device. enough to keep me playing and replay- entist who knows how to make the ing scenarios. I found myself constantly Tembler Bomb.) This failure sends you Make Your Missions A wanting the current mission to be com- to the Proxima System to play missions Little Easier (Or Harder) pleted just so I could see what was 0049 (misnr001) and 0050 (misnr002). While playing through the various mis- going to happen next. The term “Inter- (Mission 0050 is the horrid mission sions and scenarios I quickly decided active Movie” doesn’t seem to do justice where never-ending waves of enemy that my computer pilot needed help to what Origin has created in Wing Kilrathi appear; the game never ends surviving some of the missions. Altering Commander III. and you have lost.) the game weapons (guns and missiles) Wing Commander III exacts a In a different scenario, if you are seemed to be the best method for high price in terms of system horsepow- doing well and complete mission 0039 increasing my pilot’s survival time. I er. A Pentium is not required, but in successfully, you jump to the Freya Sys- wrote a utility called WCEASY that order to get the most from the game tem and begin mission 0040 (misnm001). If edits most of the primary gun and mis- you will need one. Testing the flight all goes well after a few missions, you sile parameters. The WCEASY.ZIP combat sequences using VGA graphics will be heading to downtown Kilrah routine can be found on CompuServe in on my 486DX2/50 gave frame rates of with the Tembler Bomb during mission the Flight Simulation Forum (GO three-to-six frames per second during 0048 (misnp003). FSFORUM), Space Combat Library. periods of heavy combat action, and the Note that more than one mission If you want to write your own util- game occasionally hesitated for several file can be played during a mission. For ities for altering Wing Commander III seconds in order to load the graphics example, consider mission 0041 game play, let me warn you that the and sounds for explosions or new waves (misnm002). The misnm002 file is played Wing Commander III game engine is of enemy vehicles. The loading times during the initial space combat part of very sensitive and very inflexible. The ranged from 10 seconds during mission the mission. Next, the misnm02g file complexity of this engine is such that waypoint sequencing to 70 seconds at plays when the player is doing combat little allowance is made for altering mission start up. Is a game with longer on the surface of a planet. Lastly, file weapons or missions in drastic ways. (I loading times and lower frame rates misnm02b plays during space combat at wrote an editor for Privateer, PRED- worth playing until I can upgrade to a the end of the mission. IT, a couple of years ago that let you Pentium? If the game is Wing Com- Now that I have explained IFF file add several hundred missiles to your mander III, you bet it is! ■ formatting and how the mission file vehicle. Do not do this with Wing names are stored, I have a little home- Commander III!) work for you. Try to find the look-up Also some of the mission (and table that contains the names of the possibly other nonmission) data is space systems. Hint: The space systems encrypted or somehow abbreviated in IFF file data is in the GAME- structure—possibly a new type of IFF FLOW.TRE file. What is the record file format. Unless you study this for- data that corresponds to the record mat carefully, I would not advise chang- name LOOK0000 in the space systems ing it. Any unallowed changes will at Wayne Sikes has been a computer look-up table? best cause the game to halt and will hardware and software engineer for the quite possibly crash your PC. (Don’t last 12 years. He has an extensive back- Undocumented Keystrokes forget to erase the Wing Commander ground in C, C++, and assembly language I found several undocumented key- III swap file on your hard drive if your programming. He also has several years strokes that are not referenced in the PC crashes.) experience as a computer systems intelli- game’s literature. These keystrokes only gence analyst, where he specialized in deci- appear to be active during the flight Wing Commander III: phering and disassembling computer code mode (when you are in the cockpit fly- The Next Generation while working on classified government ing a mission). The Alt-V keystroke The first two installments of Wing projects. He has written game engines as displays the game version and the file Commander were impressive to say the well as numerous computer gaming help name of the current mission. The dis- least. Wing Commander III is destined utilities. You can reach him via e-mail at played file name is found in the mission to be a landmark that other gaming [email protected] or through file name look-up table previously dis- companies will try to reach in the fore- Game Developer.

GAME DEVELOPER •JUNE/JULY 1995 55 BY DESIGN

Descending to the Top

Alexander mbarking on an ambitious Startup Antoniades project such as a commercial Toschlog and Kulas had each worked on game can be a taxing experi- a number of games for various compa- What does it take to ence, and it’s good to have nies and were interested in working on friends to help get you their own creation. Originally, they had through lean times. For two kicked around the idea of doing an programmers who had a indoor flight simulator using shaded start your own studio dream of starting a company polygons, similar to the way they’d Eand writing their own three-dimen- worked on Flight Simulator 2. But after sional game, the journey from concept working on Ultima Underworld they to product became a real learning realized that they could use texture experience. mapping to make the game more spec- and develop a new Matt Toschlog first met Mike tacular. After considering this for a Kulas in 1986 at SubLogic, where they while, they finally got together in April were both working on Flight Simulator 1993 and wrote the two-page sketch for 2 for 68000 series processors (Com- Descent. game? In 1993, Matt modore Amiga, Atari ST, and Macin- Their next step was to break away tosh). In 1988, Toschlog left SubLogic and form a company. They settled on for Looking Glass, where he worked the name Parallax studios and started with Ned Lerner on the Car and Driver looking for a publisher. One of the first Toschlog and Mike computer game. Kulas joined them in companies they contacted was Apogee. 1990 creating game tools for Car and Scott Miller, the president of Apogee, Driver. While they enjoyed working at was excited by their proposal and set Looking Glass both Toschlog and Kulas them up with a contract. Over the next Kulas learned the yearned for something different. nine months Parallax and Apogee ropes when they formed Parallax studios. This is

Descent, the first game developed jointly by Matt Toschlog’s and Mike Kulas’s Parallax stu- their story. dio, takes place in a mine on a distant planet.

GAME DEVELOPER • JUNE/JULY 1995 57 BY DESIGN

worked closely in putting Descent texture mapped and viewed from any Despite the fact that Descent was no together. Apogee supplied them with angle. The game takes place in a mine on longer being published by Apogee, money and experience the company had a distant planet, so there’s no sky to view, Apogee let Parallax post Descent on its gained making three-dimensional share- and all of the remaining objects that highly accessible Software Creations BBS ware games, while Parallax implemented aren’t polygons are either rotated, so for distribution. any artistic and structural changes that they’re always facing the viewer, or situat- Despite careful planning and pro- Apogee requested. ed in areas where they can’t be viewed gramming there were some problems While the relationship was work- from above. with the 1.0 release of Descent. One bug able Apogee had to break it off. Apogee Early in the development process, that bit Parallax hard was when robots was in the midst of starting its three- Parallax toyed with the idea of having recharged their shields after the player dimensional retail project (see “The Sul- irregular objects that were flat bitmaps died, forcing the player back to the begin- tans of Shareware Go Retail,” By rapidly shift to simulate different view- ning of the level. This took a terrible toll Design, Feb./Mar. 1995), and Descent points. But having over 70 bitmaps for on level 7 (the last level of the shareware was entering a more expensive stage of each stage of a movement ended up using version), in which wearing down the production. Soon Apogee became too much memory, hence the decision to “” robot’s shield over the course of overextended—it simply had too many stick with simple polygons. many players’ ships was the strategy. games in the works—and made a clean Even though Descent’s game play “People aren’t going to register a game, if break with Parallax. didn’t change much from its beginnings they can’t even finish the shareware lev- So it came to be that nearly a year with Apogee, Toschlog and Kulas els,” lamented Kulas. later, in January 1994, Parallax Software’s learned more about project management After fixing the rejuvenated robots five-person team (Toschlog, Kulas, artist this time around. For example, Toschlog bug, another aspect of gameplay was Adam Pletcher, programmer John Slagel, observed that in a project of this size criticized by Descent players. While and level designer Che-Yuan Wang) was almost all things need to be done onsite. players could save pilots and return to almost as far from releasing its first game Sometimes they learned this the hard levels they had completed, there was no as when it started. They had serious work way, as when the music files came back in-level save game feature (as in to do. Working from the code they had towards the end of the project too large LucasArts’s Dark Forces). Convinced finished, they spent the next three weeks to fit on two disks. A more positive sur- that this was too popular a feature to frantically putting a mock game to show prise development was that team mem- overlooked, Parallax added an in-level prospective investors. They sent the mock bers like Adam Pletcher, who was hired save game option to one of its first up, with accompanying letters, to 50 as an artist, would often make great sug- revisions. game companies. From the 50 letters, gestions in areas outside of their special- they received three replies, which turned ty, such as game design. Ascent out to be two more than they needed. Following the lead of many other What does the future hold for Parallax? Interplay was one of the three companies, Parallax used Doom as a First will be the CD-Enhanced version of interested. The company signed Parallax benchmark of what to include in its Descent, which will be to Descent what up immediately. Interplay had been game. While this took off the pressure of Doom II is to Doom, that is, more levels eager to test the waters of the shareware worrying about things like cut scenes, the with a few new features. After that maybe market ever since it had handled the team balked at including one of Doom’s Descent II, but definitely Descent for Macintosh release of Wolfenstein 3D. most popular features—Network play. Macintosh, for Sega’s Saturn, and Sony’s Under the guiding hand of producer Parallax was reluctant to add networking Playstation. Rusty Buchert, Parallax added two more capability because the work required was While the saying around Parallax people to their team and ended up fin- difficult, but the team also knew it was during the making of Descent was “This ishing Descent eleven months after important for comparison with Doom, so project is our company,” in the future starting with Interplay. they gave in. Interestingly, it was not net- Parallax will concentrate on two projects work bandwidth that instituted the instead of one. “We can’t compete with Descent eight-player limit in the final version of Wing Commander III,” admits Toschlog, One of the aspects that made Descent Descent, but the incredible slowdown but with two small teams of programmers unique was that it combined all six that occurred if more than eight players Parallax hopes its games will be written degrees of freedom from a flight simula- were in the same room during a network and designed well enough that it won’t tor with the traditional Doom texture game. have to. ■ mapping. Toschlog, Kulas, and their One area where Parallax took a team did this by placing the player in a definitive Doom approach was making Alexander Antoniades is Game Devel- spaceship surrounded by robot adver- Descent a shareware release. This was a oper’s editor-at-large. Contact him via e- saries. This let them create all the moving decision made during the Apogee days mail at [email protected] or through Game objects using big polygons that could be and Interplay decided to stick with it. Developer magazine.

GAME DEVELOPER • JUNE/JULY 1995 59 ARTIST‘S VIEW

The Three Fs of 3D: Features, Functionality, And ’Fordability

Working in the three-dimensional arena is compute-intensive and on the PC that can turn into a major time- sink, with scene renders dragging on interminably while your poor little hard drive emits soul-wrenching little- engine-that-could sound effects. Fortu- nately, faster CPUs and system buses, built-in floating-point units, and a new generation of graphics accelerator cards have greatly speeded the PC’s ability to deal with the rigors of working in and rendering three dimensions. While of course you want all the processor speed and RAM you can get your little meat hooks into, fledgling three-dimensional artists on a tight budget can squeak by on a 386 with math coprocessor and 8MB RAM. Useful libraries of ready- made objects and textures are generally The incredible can be made to look believable with the wide array of special effects going to be on CD, so it would be a available to 3D Studio users. Shown, a scene from The Daedelus Encounter, a Mechadeus good idea for even a minimalist setup to title. include a CD-ROM drive.

Autodesk 3D Studio hree-dimensional design is hot, Estimates show that 3D Studio now and you want it, but a high-end accounts for more than half of the PC workstation isn’t on your shop- modeling and animation market, which ping list just yet. Where does that makes it a natural standard for compari- leave you? Well, hardware son. This magazine ran a more in-depth improvements are making the PC overview of 3D Studio in a previous a more and more viable alterna- article (“What is 3D Studio?” June, tive, and PC-based three-dimen- 1994), but since that time Autodesk has Tsional modeling, rendering, and animation come out with Release 4, and its new software is cropping up everywhere to cap- features make a revisit worthwhile. italize on that fact. These products all 3D Studio runs in DOS, which promise the moon, and the ads look swell, may seem something of an anachronism but do they really deliver? And how usable these days. While the interface might are they? This time around I’ll give you an initially come across as clunky to Win- artist’s view of three packages representing dows-dependent users, given the pro- a broad range of features, functionality, gram’s depth it’s probably much more and price. usable than if it were icon driven. Five

60 GAME DEVELOPER • JUNE/JULY 1995 David Sieks modules make up the working area of uses BASIC-like commands to build in 3D Studio: collision detection and elementary • The 3D Editor, which allows the physics. There’s also a Fast Preview fea- user to create and alter objects and to ture that allows rendering modes from You need to weigh position virtual lights and cameras wireframe to Phong-highlighted • The 2D Shaper for creating spline Gouraud shading for full-color previews polygons, which then are used to of animations. Perhaps the coolest new build three-dimensional objects or to feature is the addition of Inverse Kine- define complex paths for animations matics. This makes possible hierarchi- many factors when • The 3D Lofter, where two-dimen- cally linked object chains—such as sional polygons are built up into jointed limbs—that recognize range-of- objects movement constraints. • The Materials Editor, to create and While it is tempting to describe edit surface materials 3D Studio as fully featured, its tremen- choosing software • The Keyframer, for animating lights, dous flexibility is further enhanced by cameras, and action. the availability of myriad third-party The user moves back and forth plug-ins: alluring little extras that let freely within these modules, which are you, for example, twist, crumple, or for three-dimension- like task-specific workspaces. Release 4 explode your three-dimensional cre- features a significantly speedier 3D ations or add smoke, snow, or fireworks Editor, which is where users spend to a scene and much, much more. much of their time. Autodesk encourages developers to One great advantage of 3D Studio build around its product and claims that al design. Sure, it‘s is its support of network rendering. new plug-ins are coming at a rate of Using a single copy of the software you about one a week—there are already can add any number of networked com- over 200 available. All of which makes puters to a queue to participate in ren- for a very richly featured tool, indeed. dering a project, essentially multiplying And it can be yours for about $3,000 great if a tool is hip your computer’s resources manyfold and (third-party plug-ins, of course, are sold saving you valuable time. Multiple files separately). can be lined up for unattended network But what’s it like to use? While the rendering while 3D Studio manages the breadth and depth of 3D Studio is a and cool—but is it workload, assigning tasks to slave spur to the imagination, the sheer scope machines as they become available. of it is also somewhat daunting. I found A 250-page manual is devoted to the five manuals (that’s right, five) were outlining the many new features in clearly written and well organized. They Release 4. One highlight is the Camera include an excellent book of tutorials affordable, usable, Control and Perspective Match capabil- that’s over 500 pages long yet still bare- ity, which aids in camera placement and ly scratches the surface. Savvy users also rendering for coordinating your view recommend Inside 3D Studio from New with a scanned photo image. Another is Riders Publishing (Indianapolis, Ind.), a Keyframe Scripting Language that a hefty book of tips for newcomers and and versatile?

GAME DEVELOPER • JUNE/JULY 1995 61 ARTIST‘S VIEW

techniques for professionals, loaded lated onscreen in real time. All this is almost immediately comfortable. While with hands-on examples. These and a geared toward making trueSpace more I’m griping, let me just add my hopes lot of patient experimentation will get readily understandable on an immedi- that in future releases Caligari pays you going, as the interface—while not ate, visual level. more attention to documentation. necessarily intuitive—is certainly fairly And it is. Navigation around the While trueSpace does not support logical once you’re grounded. But keep workspace could not be more straight- networkable functions, many users those manuals handy. New users will quickly find that complex paths for animating objects and cameras can be achieved fairly easi- ly. Geometric forms can likewise be created, deformed, and combined with relative ease to represent an armchair, say, or a spacecraft. Even experienced users, however, complain of the diffi- culty of creating biomorphic forms. One workaround is to check out plug- ins from Crestline Software (Crestline, Calif.), which offer virtual mannequins with walk and run motion, facial expressions and hand gestures. Crest- line’s Tim Wilson says models of other creatures, starting with dinosaurs, are in the works. Joel Gwynn, applications specialist Some users find the trueSpace interface lends itself more readily to character creation than at Cambridge, Mass.-based Designers’ do other three-dimensional modelers. Here, a fighter wielding a 'body-ripper' from a game- CADD Company, an Autodesk reseller in-progress by Megabyte Industries. and design shop, finds that most 3D Studio purchasers have a specific task in mind when they begin. Designer’s forward. You can shift your viewpoint speak favorably of its speedy rendering CADD can go onsite and train users up, down, and around in relation to the time. Robert Riter of Megabyte Indus- through that project so the knowledge scene or to a selected object, or along tries (Moravia, N.Y.) used trueSpace to they’re gaining is immediately applica- the Cartesian axes. Objects, lights, and create three-dimensional animations for ble, which is a great way for a new user cameras are all manipulated in the same the Dark Force Productions title to get up to speed. Check with your way. You can open smaller, auxiliary Wormhole and is using it throughout a Autodesk dealer about the availability view windows (and drag them to any first-person action game of his own cur- of training. There are also training sem- location on the screen) to display a rently in development. A former 3D inars from Autodesk University. If you camera’s viewpoint or to show an Studio user, his experience is that ren- don’t have the luxury of a long stretch almost instantaneous preview of an ani- dering tasks that might have run for innocent, childlike exploration and mation or rendered scene. overnight with that program can be experimentation, that may be your best I have only one gripe about the completed in a fraction of the time with bet. interface, and it’s admittedly a niggling trueSpace. one. The icon buttons are small and the He also finds trueSpace a far better Caligari trueSpace icons themselves rather obscure. As tool for character creation. Indeed, its Or maybe you’ll want to take a look at your mouse pointer encounters each modeling tools are not only powerful, what Caligari Corp. has to offer. icon, a brief description does appear in flexible, and easy to use, they’re getting “Usable” is the word Caligari prefers in the status bar at the bottom of the better—trueSpace for Windows 2.0 was reference to its product, trueSpace for screen. However, that means you have in beta test when I wrote this, with Windows. Rather than splitting func- to keep looking back and forth from the release expected for the summer of tions between various modules its so- toolbar to the status bar until you 1995. I’ve been working with the beta called “natural user interface” consists of become familiar enough with the loca- myself for the past week and have been one large work area. Features are con- tion and function of each button. That impressed with the fluidity of the mod- tained on a single menu bar of icons, comes with time, but it’s a little frus- eling process. Deformation tools have with additional controls accessible via trating for the novice user, especially been improved over version 1.0 so that, pull-down menus. Objects are manipu- since so much else about the program is using the mouse, you can easily push

62 GAME DEVELOPER • JUNE/JULY 1995 and pull object faces to alter form. Cali- • Renderize Live is the workhorse of process rather than just providing a gari has also added three-dimensional the group. It serves as the stage quick run-through. Boolean operations, which means that around which you place objects, What Visual Software invites is the you can sculpt complex shapes as lights, and cameras and is also where creation of virtual worlds, and toward though with a chisel, or by fusing three- you will render final images or ani- this end Visual Reality’s set design tools dimensional shapes together like lumps mations. are impressive. The Light Designer in of clay. • Visual Model is where you create Renderize Live provides complete con- Another coup for Caligari is the three-dimensional objects that you trol over light and shadow: define addition of real-time solid rendering. If can then transfer to your scene in ambient lighting, point lights, spot you’ve used a three-dimensional pro- Renderize Live. lights, and area lights; specify color, gram before to create anything more • Visual Font makes possible three- intensity, and attenuation, as well as than a simple geometric form, you dimensional text objects with bevel- position and direction; shadows can be know how confusing it can get at times ing and extruding properties. enabled or disabled for each light, and to work in wireframe. With trueSpace • Visual Image is a two-dimensional the intensity and sharpness of the shad- 2.0, it is possible to work with rendered image editor. ow set by the user. Photorealistic effects solid forms onscreen in real-time. Two • Visual Catalog organizes projects are enhanced by adjustable distance renderers are included: 3DR, from from the preceding modules and haze/fog levels and colors, and by cam- Intel, and Renderware, from Criterion facilitates the sharing of resources era settings that simulate the look of (wireframe is still also an option and within the suite. zoom and wide-angle lenses. Cameras remains most useful for point editing). Visual Catalog is a new feature are also fully animatable (though it is I’ve found that 3DR updates the screen with Visual Reality 1.5 and it’s a wel- important to note that objects are not much more quickly than does Render- come addition that makes it much easi- animatable). Materials editing and ware, though the colors tend to get er to carry on a project between the dif- mapping capabilities are extensive, not lurid. You can expect even better results ferent applications. Also the handbooks to mention that the package comes with if you’re using one of the new graphics for each module, previously available over 1,000 textures, including 200 cards, such as the Matrox Impression, separately, have been combined into seamless textures. Rendering options with built-in support for these APIs. one integrated user’s manual. It’s well allow for texture, bump, reflection, and Some further improvements to written and helpful, filled with pointers transparency mapping. enhance the program’s creation of pho- for optimizing performance as well as Visual Model, the arena for three- torealistic effects are the addition of aesthetic tips. The tutorials are in dimensional object creation, is also adjustable depth of field; Adobe Photo- depth, explaining each step of the packed with features including Boolean shop plug-in support; motion blur; and new seamless procedural textures— including wood, granite, and marble— that allow user-definable settings for roughness, scale, and color. trueSpace 2.0 will retain the $795 SRP and, if it’s still not out by the time this hits the stands, you can buy version 1.0 and get a free upgrade from Caligari when the new version does come to market.

Visual Software’s Visual Reality Visual Software (Woodland Hills, Calif.) wants to maketh you like unto a god. Yea, verily, and for cheap, too. Their Visual Reality suite is a virtual Swiss Army knife for the aspiring world maker on a budget. It doesn’t attempt to do everything, mind, and it’s not exactly a quick learn, but what it does it Create your own virtual worlds with Visual Reality or sample one of theirs. The Northern Castle is just one royalty-free three-dimensional environment available to game developers does thoroughly—and for under $300. in the Simply Scenes series from Visual Software. Visual Reality consists of five sepa- rate but cooperative applications:

GAME DEVELOPER • JUNE/JULY 1995 63 ARTIST‘S VIEW

operations for adding, subtracting, and There’s also a soup-to-nuts assemblage give up the depth afforded by 3D Stu- intersecting forms, along with the usual of everyday settings such as a dining dio, I love the natural feel of working in editing tools. Unfortunately, I haven’t room, a beach, and a country club lock- trueSpace, and if I was just starting found it very easy to make use of all er room. On deck are Western Town, with three-dimensional graphics the these goodies. Its method of defining the Solar System, and Lunar and Sea bang-for-the-buck value of Visual Real- three-dimensional space is not very Colonies. You can wander alone ity would surely be tempting. Fortu- intuitive, so that I’m always having to through each of these exotic locales for nately, certain file formats are common refer to the manual to make sense of the a mere $49 per. between programs, so if you do have process. And the worlds I’ve created access to a variety of three-dimensional with Visual Reality are lonely places, 3D For You Too software you can probably make use of given how difficult I’ve found it to We’ve looked at three significantly dif- the best features of each. attempt organic forms in the modeler. ferent programs, each with its own dis- If you’ve been using one three- Speaking of lonely virtual worlds, tinct advantages and disadvantages. dimensional program and you’re not Visual Software is introducing a com- And the marketplace is crowded with satisfied with what you’ve been able to panion series called Simply Scenes that many more than I could profile here do with it, there may be a better choice consists of fully rendered yet eerily even if I’d had the chance to use them out there for you. It doesn’t necessarily uninhabited royalty-free three-dimen- all, which I haven’t...yet. mean spending more money this time sional settings for game developers to If you’ve been thinking about mak- around, either. Rather, it’s that quest use. You can take elements of the three- ing the move to three-dimensional for the brush that fits your hand. ■ dimensional environment and modify, design, think some more about just move, retexture, or even remove them what it is you hope to find in those for use elsewhere. The idea is for three dimensions. As these three exam- designers to place their own characters ples show, there’s a wide range of David Sieks is a contributing editor and objects within these ready-made prices, features, and functionality to to Game Developer. Contact him via e- scenes. A hauntingly beautiful fortress, consider. Asked to choose between mail at [email protected] or The Northern Castle, is one of the first. them, I’m not sure I could. I’d hate to through Game Developer magazine.

64 GAME DEVELOPER • JUNE/JULY 1995