Home

June/July 1995

image

Contents

1. This last thing is a compliment Your arti cles were excellent they all covered subjects that were interesting up to date and relevant to game programming today There s no Faster drawing in Mode X stuff that was covered in Dr Dobb s Journal three years ago Texture mapping ripping apart Tie Fighter push button game design Yes But as said before give us more Jeff Miller via e mail p clip n save Se Se Se SP IS THIS PROMINENT ENOUGH ae ae he ke ftp ftp mfi com odmag SIC O Ici clip n save ro Ll m m CROSSFIRE Alex Dunne Microsoft s Softimage is suddenly chal lenged by Silicon Graphics s merger with Alias and Wave front What can game 3D Graphics Goliaths Square Off esterday as was cleaning out a bookshelf in our office came upon an issue of Byte magazine from Aug 1987 Although was throwing everything away had an urge to flip through its pages there s something com peling about a computer mag azine that s over seven years old Volume 12 number 9 sues Sf ain of Byte may only have been 49 in dog years but it was much older in computer years couldn t believe it ads for 386 16M hz computers sell ing for 4 400 9600 baud modems for 1 000 and articles about EGA graphics It s amazing we got through those rough times Some know it all will read this in 2002 and s
2. card supports VBE you still need to find al memory on the video card in 64K blocks The second is the Video_Mode_Pointer which is a pointer to a list of video modes that the card sup ports The mode numbers can include modes that are unique to your video card numbered from 14h to 7Fh along with mode numbers that VE SA has des ignated to be standard on all cards 100 to 11Bh Because of this it is possible fi a mode to be listed under two diff mode numbers both equally valid Table 1 for a list of standard VESA mode numbers N ow just because a mode number is listed doesn t mean that the mode is actually supported for example there may not be enough video memory To che k out the modes you want to use 1 call VBE function 01h return Super mode information You must provide d 256 byte buffer for information to be returned in If AX comes back with any thing other than 004Fh then the mode is not available If AX is 004Fh and the first bit of the first word in the buffer Mode Attributes is 0 then the mode is not available The mode information block returned by function 01h contains a wealth of information about how to actually use that mode T hat information includes Whether the mode is text or graphics monochrome or color Whether the BIOS text functions are available in that mode The screen resolution and character cell sizes The memory access model and pixel layout u
3. 1 First we get info on the desired mode memset MODE Info 0 256 Clear Mode Info in regs x ax Ox4F01 Get mode Info Function in_regs x cx Mode Num Mode number seg regs es FP SEG VESA Info Buffer to hold results in regs x di FP OFF VESA Info int86x 0x10 amp in regs amp out regs amp seg regs if out regs x ax 0x004F Did an Error occur return 0 else return Mode Num Function to perform VESA VBE Mode Set int set_VESA_Mode int Mode_Num in_regs x ax 0x4F02 Get mode Info Function in_regs x bx Mode Num Mode number int86x 0x10 amp in regs amp out regs amp seg regs if out regs x ax 0x004F Did an Error occur printf Error attempting to set Mode xh n Mode Num return 0 else return 1 int get_VESA_version VbeInfoBlock far VESA_Info int MajorVer int MinorVer int ver m Prepare VESA info Buffer memset VESA Info 0 512 memcpy VESA Info Vbe Signature VBE2 4 Call Int 10 VBE Function 4F 00h in_regs x ax Ox4F00 seg_regs es FP_SEG VESA_Info in regs x di FP_OFF VESA_Info int86x 0x10 amp in regs amp out regs amp seg regs Check if VBE Extions present amp Get Revision Level if out regs x ax 0x004F memcmp VESA_Info gt Vbe_Signature VESA 4 0 return 0 else ver VESA_Info
4. GAME Brain PLAN Goes Whoosh oing to the Computer Game D eveloper s C onference is like having your brain ripped from your skull spun up to 9096 of the speed of light and fired into a reaction chamber filled with 2 000 other brains moving at relativistic speeds It s just as hard recreating the CGD C from business cards press releases and scrawled notes as it is seeing the signature of a T op quark in the spirals and parabolas of a reaction chamber photograph A bove any other impression the overwhelming support for Game D evdoper from the community was both gratifying and humbling To have so many people known to us only from their credits on shrinkwrap games come up and tell us that they read the magazine was amazing enough but when they continued with specific comments about this column or that feature realized that our magazine s editorial staff isn t what s on the masthead it s 20 000 strong D espite the overload of informa tion that makes it impossible to say what the story of the show was think there were three candidates sound 3D and W indows The sound story was a howl of rage against FM synthesis and its gaming syn onym SoundBlaster compatible T o many at the CGDC the chirpy voice of an FM card through the molded plastic speakers bundled with a 60 card repre sents the jackboot of tyranny on the throat of the gaming public Although rendered on the fly sounds like what happens wh
5. These items added in the VESA VBE 2 0 Spec int em Software Rev char far em Vendor Name Ptr char far em Product Name Ptr char far Dem Product Rev Ptr uchar reserved 222 uchar em Data 256 VbeInfoBlock From the 1 2 spec VBE 2 0 OEM strings Stucture to hold VESA VBE Get Mode Info Results typedef struct This section available is all VESA revisions uint Mode Attributes uchar Win A Attributes uchar Win B Attributes int Win_Granularity int Win_Size uint Win_A_Segment uint Win_B_Segment void far Win_Func_Ptr int Bytes_Per_Scan_Line Memory Window A Memory Window B in 1K units Window Size in K Segment of Window A Segment of Window B Bank Switch func addr just what it says This section available is VBE revision 1 2 amp up int X Resolution int Y Resolution char X Char Size char Y Char Size char Number 0f Planes char Bits Per Pixel char Number 0f Banks char Memor y Model char Bank Size char Number 0f Image Pages char Reserved1 This section is used for Memory Model 0x06 and 0x07 i e Direct Color and YUV color modes 48 GAMEDEVELOPER J UNE J ULY 1995 char Red Mask Size char Red Field Position char Green Mask Size char Green Field Position char Blue Mask Size char Blue Field Position char Rsvd Mask Size char Rsvd Field Position char Direct
6. portRect amp thePort gt portRect srcCopy thePort gt visRgn GAME DEVELOPER J UNE J ULY 1995 31 Le a GRAPHICS will always map to the same address It will never move in memory as far as our applications can see so the unneeded extra limbs Lock and Unlock can be com piled out by declaring them as empty inline functions Only the constructor destructor and swap functions remain WinG supports both top down and bottom up buffer orientations as discussed in every piece of W inG litera ture to date so the first step in con structing an offscreen buffer is to deter mine the orientation that will make memory to screen blts fastest W inG provides this information through the WinGRecommendDIBFormat function called by the constructor before creating the offscreen buffer Once it has the optimal D evice Independent Bitmap DIB orientation the constructor fills in the biWidth and bileight fields of the BITMAPINFOHEADER structure containing the optimal format preserving the sign of biHeight A color table stolen from the current system palette completes the information neces sary to create a WinGBitmap and an accom panying WinGDC which the COffscreen Buffer constructor does for us Selecting a WinGBitmap into a new WinGDC pops out a stock monochrome bitmap that the destructor will need later so store it in the COffscreenBuffer object until then The Width and Height of the buffer came from the foregr
7. developer can make an intelligent guess as to the resolution and complexity of each frame in relation to the game The PC industry should adopt a standard benchmark for games and applications that use three dimensional graphics The benchmark should be similar to the GPC benchmark used in the workstation industry in that it should measure the application level performance and not just the memory subsystem of the graphics device If a magic number is used then it should easily translate into scene complexity and the various stages of the graphics pipeline This magic number informa tion should be stored with the platform in an easily accessible form so that games can adjust scene complexity dur ing run time NM Stephen Johnson has been a computer software engineer for the last 15 years H e has extensive background in C C and several different assembly languages as well as experience with UNIX MacOS MSDOS and Windows About a year ago a game called DOOM popped up on his home computer After one intense weekend of blowing away demons he decided to change his career Strangely enough he discovered that writing game software is way more fun than CAD CAM drafting packages H e cur rently resides at Diamond M ultimedia where he is bringing high resolution high performance three dimensional graphics to every Windows user he can find GETTING STARTED WITH VESA Getting Started with VESA Graphics Tabl
8. multiply it by the gradients of all our interpolants to get to the starting pixel center before we could draw T his is because we didn t know how far we were from the first pixel center until we did the ceil call Now think about how this works with a DDA W e are stepping from one pixel center to the next directly and we know exactly how far we had to come from the last pixel center the floor of dx dy in x plus 1 in y or that step plus 1 in x when our error term rolls over see Equation 8 W e never need to calculate our prestep to a pixel center because we re always stepping on pixel centers Take a minute to think this through it means we get the advantages of sampling from pixel centers and we don t pay the prestep multiply As I ve mentioned before these advantages include rock solid textures that don t swim when you rotate and no hairy texture artifacts Listing 1 showsthe salient parts of the integer rasterizer B ecause of space constraints I ve only included the dif ferences from last column s listing Y ou can pick up the entire listing on C om puServe in the Game D evdoper section of the SD Forum or from ftp ftp mfi com gdmag src The code is in a weird state because left the texture coordinates as floats while the edge rasterization is in integer coordinates as we ve been discussing This bizarre combination doesn t affect the rasterizer and it will be fixed in the next article when we address the
9. 11 with W in32s Windows NT v 3 5 and M acintosh System 7 0 T he graphics code implemented on top of the COff screenBuffer A PI did not change If multiplatform graphics program ming can be this easy the excuses for writing DOS only games begin to look silly T ake for example that it took only a weekend with no sleep to create a graphics only version of D oom for W in dows using WinG because of the struc tured design chosen by the programmers at id Software M ost of the third party three dimensional rendering systems on the market today have at least three ver sions D OS W indows and M acintosh W hy shouldn t you The M icrosoft machine has finally started cranking up and facing the prob lems of providing real game support in W indows much of it promised for W in dows 95 M ore and more M acintosh games are appearing on the market and maybe one day someone will actually come up with a decent M acintosh joy stick D OS 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 W ith the advent of W indows 95 and its promised support for sound mixing and joystick input and with the multimedia capabilities already provided on M ac and W indows your reasons for sticking exclusively to DOS begin to look
10. SwapMMUMode handles this storing the current mode for restoration by the Unlock method T he Unlock method mirrors the locking function allowing the operating system to move the offscreen buffer around when the application doesn t need it The aptly named system call UnlockPixels handles this task after which reset the cached pBits value to zero to avoid being bitten by an attempt to access the bits when the buffer is unlocked In debug versions also add an integer LockCount member variable incre mented by Lock and decremented by Unlock and assert it is zero when the COffscreenBuffer destructor is called The Macintosh requires the Lock Unlock pair and other platforms may require it as well All implementa tions of C ffscreenBuffer must include both methods whether they do anything or not and all functions written for coff screenBuffer must operate between a Lock Unlock pair to be completely portable This includes the previous examples and calls to SwapBuffer SwapBuffer provides the memory to screen transfer for the application when it finishes its graphics processing and wants to display the image SwapBuffer will call out to CopyBits to do the job copying the entire offscreen image into the current CGrafPort using the visRgn as a mask The operating system will handle all the work of clipping to the visible window area T he COffscreenBuffer destructor is the easiest of all to implement on the M
11. T he Sul tans of Shareware Go Retail By Design Feb M ar 1995 and D escent was entering a more expensive stage of production Soon Apogee became overextended it simply had too many games in the works and made a clean break with Parallax So it came to be that nearly a year later in January 1994 Parallax Software s five person team T oschlog Kulas artist A dam Pletcher programmer John Slagel and level designer C he Y uan W ang was almost as far from releasing its first game as when it started T hey had serious work to do W orking from the code they had finished they spent the next three weeks frantically putting a mock game to show prospective investors T hey sent the mock up with accompanying letters to 50 game companies From the 50 letters they received three replies which turned out to betwo more than they needed Interplay was one of the three interested T he company signed Parallax up immediately Interplay had been eager to test the waters of the shareware market ever since it had handled the M acintosh release of W olfenstein 3D Under the guiding hand of producer Rusty Buchert Parallax added two more people to their team and ended up fin ishing D escent eleven months after starting with Interplay Descent O ne of the aspects that made D escent unique was that it combined all six degrees of freedom from a flight simula tor with the traditional D oom texture mapping T oschlog Kulas and t
12. While they enjoyed working at Looking Glass both T oschlog and K ulas yearned for something different Startup T oschlog and Kulas had each worked on a number of games for various compa nies and were interested in working on their own creation O riginally they had kicked around the idea of doing an indoor flight simulator using shaded polygons similar to the way they d worked on Flight Simulator 2 But after working on Ultima Underworld they realized that they could use texture mapping to make the game more spec tacular After considering this for a while they finally got together in A pril 1993 and wrote the two page sketch for D escent Their next step was to break away and form a company T hey settled on the name Parallax studios and started looking for a publisher O ne of the first companies they contacted was A pogee Scott M iller the president of A pogee was excited by their proposal and set them up with a contract O ver the next nine months Parallax and Apogee GAME DEVELOPER JUNE JULY 1995 57 BY DESIGN worked closely in putting D escent together A pogee supplied them with money and experience the company had gained making three dimensional share ware games while Parallax implemented any artistic and structural changes that A pogee requested W hile the relationship was work able A pogee had to break it off A pogee was in the midst of starting its three dimensional retail project see
13. XTRE string possibly indicates this file contains cross referenced data records T he bytes at offsets 8 to 23 contain four pointers T he first three pointers give the file off sets offsets into the TRE file with the first byte in the file referenced as byte 0 of three data tables The fourth pointer gives the offset of the first D ata Record in the file T he first data table in the TRE file the Indirect Record Pointer T able contains pointers file offset values that reference data in the other TRE file data tables In C nomenclature the Indirect Record Pointer T able contains pointers to pointers The Indirect Record Pointer T able entries point to various pointers contained in other TRE filetables Each entry in this table is an 8 byte structure T he first four bytes are bit flags and the last four bytes contain the pointer expressed as a 32 bit long value observed that the Indi rect Record Pointer T ables of several TRE files had blanks or empty data slots As mentioned earlier the TRE file format is flexible and expandable and these empty data slots are probably part of this expandable format T he Path Name T able follows the Indirect Record Pointer T able E mbed ded in this table are the ASCII text strings of the source paths along with binary possibly file offset data related to each path name T he Record Pointer T able follows the Path N ame table The Record Pointer T able contains the file off
14. a frames per second num ber can be computed Game Play Benchmarks A unit of measurement for graphics rendering must address the application level processing that takes place T his is consistent with benchmarks that exist for CPUs Dhrystones and W het stones and for GDI WinBench Frames per second is a perfectly good unit of measurement for game play With this type of performance metric it is possible to say one plat form runs Doom II at five frames per second and another runs it at 60 frames per second T he higher perfor mance D oom II platform is obvious W ith frames per second there exists a system level performance measurement that is reliable for comparing different platforms T he performance of rendering one scene is computed by taking the various boxes shown in Figure 1 measuring the performance of each box and summing the results into one aggregate number T he separate numbers are as vital as the total result because they give us the ability to understand where the bottle necks are and optimize the graphics pipeline to achieve higher performance for the application U nfortunately the hardware man ufacturer provides only the polygons per second statistic and that isn t enough W e only capture the last stage in the three dimensional application pipeline W hat other information can the manufacturer supply that will allow us to interpolate a frames per second statistic Playing the Game A fa
15. erman versions of W ing C ommander III comes on four CD ROM s T otal distribution size is about 2 3 gigabytes The Wing Commander III executable W C3 EXE plus several primary data files are duplicated on each CD ROM the unique data files require over 1 8 gigabytes of CD ROM storage space The movie files are by far the largest files in the game and range in size from 108M B to 408M B Installing Wing Commander III is quite an extensive process To mini mize data file loading times during game play a full installation is required The latest addition to the Wing Commander series features more technologically advanced graphics that allow for impressive realistic looking spacecraft GAME DEVELOPER JUNE JULY 1995 51 CHOPPING BLOCH Listing 1 General TRE File Format Starting ffset of the Indirect Record Pointer Table Offset of the first Data Record in this TRE file Indirect Record Pointer Table This table contains indirect pointers or pointers to pointers The values in this table point into the Path Name Table or into the Record Pointer Path Name Table Table of variable length records containing Record Pointer Table This table consists of structures containing the file offsets and sizes of the Data Records FILE DATA OFFSET SIZE DESCRIPTION 0 3 char XTRE char string 4 7 char Blanks 4 bytes of 00 8 11 long 12 15 long Starting ffset of the Path Name Table 16 19 long Starting ffset of the
16. fan into her costar from the high school play 16 GAME DEVELOPER J UNE J ULY 1995 Live from the CGDC Show Floor or those souls lucky enough to get in the CGDC usually has enough information to make it the best show for both the sea soned and prospective game developer and 1995 was no exception M ushrooming up to 2 500 attendees the CGDC irked prospective conference goers by severely underestimating demand for the second year in a row so anyone who didn t buy tickets or register as press well in advance of the show has to read about it here and hope they didn t miss out on too much The main buzz was about the CGDC show itself and revolved around founding member Chris C rawford s talk on the second day Crawford railed against show management and admitted that he had been kicked off the board of directors It was a sad note to this show which started nine years ago in someone s living room and has grown larger than anyone would have thought possible W hile last year s unofficial theme was the invasion of H ollywood money and fear of ratings the definite themes this year would have to be three dimen sional development and the move to W indows M ost of the exhibitors were hawking three dimensional tools both sight and sound offering to turn you into the next industry superstar if you d just buy their tool and the box usually a RISC one it runs on On the W in dows side M icrosoft explained it
17. in frames per second The Ctrl M Ctrl J and Ctrl K keystrokes select the mouse joystick or the keyboard respectively as your primary flight control device Make Your Missions A Little Easier Or Harder W hile playing through the various mis sions and scenarios quickly decided that my computer pilot needed help surviving some of the missions Altering the game weapons guns and missiles seemed to be the best method for increasing my pilot s survival time wrote a utility called W CEASY that edits most of the primary gun and mis sile parameters The WCEASY ZIP routine can be found on C ompuServe in the Flight Simulation Forum GO FSFORUM Space Combat L ibrary If you want to write your own util ities for altering W ing Commander III game play let me warn you that the Wing Commander III game engine is very sensitive and very inflexible The complexity of this engine is such that little allowance is made for altering weapons or missions in drastic ways I wrote an editor for Privateer PRED IT a couple of years ago that let you add several hundred missiles to your vehicle Do not do this with Wing Commander III Also some of the mission and possibly other nonmission data is encrypted or somehow abbreviated in structure possibly a new type of IFF file format Unless you study this for mat carefully would not advise chang ing it Any unallowed changes will at best cause the game to halt and will quite
18. increase rasterization quality around the world find this unacceptable T he solution hap pens to be simple fractional endpoints Unfortunately was out of space a while back and my editor is beginning to hate me so the description of this solution will have to wait until next time Summing Up Once again I m over my word budget and still haven t covered everything simply must give credit where credit is due however without my friend Kirk Olynyk s help and tutelage I d still be lighting the wrong pixels without know ing the difference If you re into this kind of discrete math it s so useful for raster graphics and you want to learn more Concrete M athematics A ddison W esley 1994 by Ronald L Graham and Oren Patashnik is great Also while discussing my article C hanging the Rules for Transparent Blts Under the H ood Feb 1995 on rec games programmer Rich G orta towsky rg raster kodak com mentioned that for best results your RLE compres sor should try to compress vertically as well as horizontally totally agree Finally promise we ll get back to the actual texture mapping portion of the texture mapper next time BI Chris H ecker wants a single cycle integer multiply on future x86 processors so bad he can tasteit Yum yum You can con tad him via email at checker bix com or through G ame D eveloper magazine 26 GAME DEVELOPER J UNE J ULY 1995 Listing The Height X Er
19. on a 1 280 by 1 024 pixel display the actual number of pixels processed is very likely to be in the millions This implies that the majority of the time in the graphics pipeline is spent generating pixels and this is true O ver 8096 of the time spent in the graphics pipeline is spent in the rasterization stage generating pixels T o accelerate three dimensional graphics first generation chip designers are accelerating the rendering and rasteri zation steps T his produces the highest performance gain for the least amount of investment T he G lint chip from 3D L abs is a perfect example of a first gen eration hardware solution T his chip converts triangles from x y z points into pixels using a 64 bit memory interface Stephen J ohnson Making three dimen sional games that are playable i5 no easy task It s up to the industry to create standards and benchmarks S0 consumers aren t confused by false magic number models GAME DEVELOPER J UNE J ULY 1995 37 GRAPHICS BENCHMARKS Three Dimensional Pixels Pixels are generated for the frame buffer by flat shading G ouraud shading or texture mapping Flat shading fills a polygon with pixels that are all the same color G ouraud shading fills a polygon with pixels that are computed using color gradients T exture mapping fills a polygon with a two dimensional bitmap like a digital photograph E ach of these methods has its mer its Flat shading is very fa
20. possibly crash your PC Don t forget to erase the W ing Commander III swap file on your hard drive if your PC crashes Wing Commander III The Next Generation T he first two installments of W ing Commander were impressive to say the least W ing Commander III is destined to be a landmark that other gaming companies will try to reach in the fore seeable future T he beauty of its graphic renderings combined with a good well acted storyline combine to create a clas Sic game can honestly say that very few games hold my attention long enough to keep me playing and replay ing scenarios found myself constantly wanting the current mission to be com pleted just so could see what was going to happen next T he term Inter active M ovie doesn t seem to do justice to what Origin has created in W ing Commander III Wing Commander II exacts a high price in terms of system horsepow er A Pentium is not required but in order to get the most from the game you will need one T esting the flight combat sequences using VGA graphics on my 486D X2 50 gave frame rates of three to six frames per second during periods of heavy combat action and the game occasionally hesitated for several seconds in order to load the graphics and sounds for explosions or new waves of enemy vehicles The loading times ranged from 10 seconds during mission waypoint sequencing to 70 seconds at mission start up Is a game with longer loading times and
21. set up the buffer pBits points to the top of the buffer coinciding with 0 0 and Stride indicates a positive step through memory For bottom up DIBs however things must be switched around As it stands pBits would point to the last scanline in the buffer and Stride would be the offset from x y to x y 1 If you ve used WinG before you ll know that flipping these values around to point in the correct direction requires only two lines Point to first scanline end of buffer pBits pBits Height 1 Stride Orient Stride from bottom to top Stride Stride W ith that the constructor has fin ished its work and the calling application is the happy owner of a W inG based off screen buffer wrapped in a COffscreen Buffer object Your application can draw into this buffer however you choose call ing SwapBuffer when you re ready to dis play an image The W indows SwapBuffer imple mentation grabs the Device Context from the active window and uses a straightfor ward WinGBitBlt call to copy the image from the offscreen WinGDC to the topmost window on the screen N othing could be easier T he call to GetDC returns a virgin device context that will not reflect selec tions you may have made to previous D Cs from the window It contains no palette information If you have gone through the effort to create an identity palette for the window or are using the WinG halftone palette your work will be in
22. shortsighted W hy not take the cross platform plunge Nl Jon Blossom is the coauthor of the WinG graphic library for Windows and is the author of Gossamer a free three dimen sonal polygon engine for the M adntosh He currently works for M axis and can be reached at blossom mobius net or through Game D eveloper magazine 34 GAME DEVELOPER J UNE J ULY 1995 Listing 5 Windows Implementation Continued from p 33 OffscreenDC 0 COffscreenBuffer COffscreenBuf fer void Delete the offscreen bitmap selecting back in the original bitmap if OffscreenDC amp amp OffscreenBitmap SelectObject OffscreenDC OriginalMonoBitmap DeleteOb ject OffscreenBitmap y Delete the offscreen device context if ffscreenDC DeleteDC 0ffscreenDC void COffscreenBuffer SwapBuffer void const Use the DC of the active window NOTE You ll lose the 1 1 palette mapping if the Window isn t CS_OWNDC HWND ActiveWindow GetActiveWindow if ActiveWindov HDC ActiveDC GetDC ActiveWindow if ActiveDC Perform the blt if ActiveDC WinGBitBlt ActiveDC 0 0 Width Height OffscreenDC 0 0 ReleaseDC ActiveWindow ActiveDC H GRAPHICS GRAPHICS BENCHMARKS Game Play Benchmarks for 3D Graphics Figure 1 The Three Dimensional Graphics Pipeline 36 GAME DEVELOPER J UNE J ULY 1995 Geometry and Render
23. stare at a screen with three objects composed of approximately 8 000 G ouraud shaded polygons rotating at dozens of frames per second T hen they made me watch other displays with alpha channels specular highlights and smooth panning T hey overlayed three dimen sional sounds T hey did it all okay A nd all of this in well behaved Windows applications M aybe it is hypnosis though need perspective and some feedback from you our 20 000 editors E mail us at gdmag mfi com and tell us what to do M ore graphics more W indows more Al more design more channel issues It s your magazine tell us what to do NI Larry O Brien E ditor LEA cli DEVELOPER Editor Larry O Brien gdmag mfi com Senior Editor Nicole Freeman 76702 706 compuserve com N icole Claro 71743 452 compuserve com Editorial Assistant D eborah Sommers dsommers mfi com Contributing Editors Alex Dunne 75010 2665 compuserve com Chris H ecker checker bix com D avid Sieks ds eksgarnarb harv ard edu W ayne Sikes 70733 1562 compuserve com Editor at Large Alexander Antoniades sander mfi com Managing Editor Cover Photography Charles Ingram Photography Publisher Veronica C ostanza Group Director Regina Starr R idley Advertising Sales Staff West Southwest Y vonneL abat 415 905 2353 ylabat mfi com New England Midwest Kristin M organ 212 626 2498 kmorgan mfi com Marketing Manager Susan M cD onald Advertising Production Coordinator
24. texture mapping itself One thing you may or may not notice when you run this raster izer is how jerky it is compared to the original floating point rasterizer If you 24 GAME DEVELOPER J UNE J ULY 1995 THE SCREEN Listing 1 The Integer Rasterizer Continued on p 26 struct edge edge gradients const amp Gradients POINT3D const pVertices int Top int Bottom inline int Step void long X XStep Numerator Denominator ODA info for x long ErrorTerm int Y Height current y and vertical count float OneOverZ OneOverZStep ne verZStepExtra 1 z and step float UOverZ U verZStep U verZStepExtra u z and step float VOverZ VOverZStep VOverZStepExtra v z and step ys inline int edge Step void X XStep Y Height U verZ U verZStep VOverZ VOverZStep OneOverZ OneOverZStep ErrorTerm Numerator if ErrorTerm gt Denominator Yet ErrorTerm Denominator OneOverZ OneOverZStepExtra U verZ U verZStepExtra VOverZ VOverZStepExtra J return Height l void DrawScanLine BITMAPINFO const pDestInfo BYTE pDestBits gradients const amp Gradients edge pLeft edge pRight BITMAPINFO const pTextureInfo BYTE pTextureBits eeeeeeee TexturelapTriangle eee eeeeeeREIF handle floor divides and mods correctly RRK inline void FloorDivMod long Numerator long Denominator long amp Floor long amp Mod assert Denominator gt 0 if Nu
25. vain unless you register the W in dow with the CS_OWNDC style which pre serves device context settings over GetDC ReleaseDC call pairs W hen it comes time to destroy the COffscreenBuffer only three steps need to be taken selection of the original mono chrome bitmap back into the WinGDC destruction of the WinGBitmap and destruction of the WinGDC Extending the Buffer Class T he COffscreenBuffer class ve developed here provides only the most basic ele ments of a double buffering system barely enough to be useful M any other features could make it a very useful tool in cross platform game development but have left them out for the sake of brevity One important thing missing from this COffscreenBuffer class is the explicit connection of an offscreen buffer to a window As implemented here coff screenBuffer uses whatever window hap pens to be active at the time a method is invoked When your application isn t in the foreground this can be a messy thing It s easy to store a platform specific window identifier in the COffscreen Buffer structure and you can hang a pointer back to the buffer object on the window too Under W in32 try using Set GetWindowLong and GWL USER to store the pointer On the M acintosh Set GetWRefCon performs a nearly identi cal task Of course attaching a buffer to a resizable window means you ll have to do something smart when the window changes size M atching the buf
26. 02 misne003 misnf001 misnf002 misnf003 misng001 misng002 misng003 misnh001 misnh002 misnh003 misni001 misni002 misni003 misnj001 misnj002 misnj003 misnk001 misnk002 misnk003 misnl001 misnl002 misnl003 misnl004 misnm001 misnm002 misnm003 misnn001 misnn002 misnn003 misnp001 misnp002 misnp003 misnr001 misnr002 tsim001 tsim002 tsim003 tsim004 tsim005 tsim006 tsim007 tsim008 tsim009 tsim010 gin s IFF file format This format is discussed in the next section Listing 2 gives a summary of the W ing Com mander III mission file names that we ve extracted from the look up table IFF File Formats Origin has used the IFF file format in several games including Privateer Strike Commander and Pacific Strike see Bandits at 0x1200 H igh C hop ping Block D ec 1994 for a discussion of the IFF files used in Pacific Strike To summarize the IFF file format an IFF file is composed of one or more forms with each form containing one or more records T he following general rules are used in IFF file formatting All forms have a header consisting of the form text string followed by a 4 byte number T his number is the number of data bytes in the form All records have a header consisting of a record name that can be up to eight bytes of text characters fol lowed by a 4 byte number This number is the number of data bytes in the record Records can be located both inside and outside of a form Mission O
27. Color mode Info This section available is VBE revision 2 0 amp up void far Physical Base Ptr void far Off Screen Mem Offset int Off Screen Mem size char Reserved 206 ModeInfoBlock Global Registers for calling INT 10h union REGS in regs out regs struct SREGS seg regs Function Prototypes int get VESA version VbeInfoBlock far int int int check VESA Mode int ModeInfoBlock far int set VESA Mode int void main void 1 VbeInfoBlock VESA Info ModeInfoBlock MODE Info int VESA Version MajorVer MinorVer Check if VESA Video BIOS Extension installed if VESA_Version get_VESA_version amp VESA_Info amp MajorVer amp MinorVer printf Unabale to run demo n printf This video card does not have VESA BIOS support n return Check if Mode 101h is available if check VESA Mode 0x0101 amp MODE Info printf dd This card has VESA BIOS extension but no support for mode 101hin return Set display to VESA Mode 101h set VESA Mode 0x0101 Draw our Test pattern and wait for a keypress draw VESA triangle pattern amp M DE Info 640 480 restore text Mode set VESA Mode 0x03 printf this VESA 640x480x256 demo is done Wn Listing 2 VESADEMO C Continued from p 48 return Function to get VESA VBE Mode Info for a given mode int check VESA Mode int Mode Num ModeInfoBlock far MODE Info
28. Denise T emple Director of Production Andrew A M ickus Vice President Circulation Jerry M O kabe Group Circulation Director Gina Oh Group Circulation Manager Kathy H enry Circulation Manager M ike Poplardo Newsstand Manager Pam Santoro Reprints Stella Valdez 415 655 4269 Chairman of the Board G raham J S W ilson President CEO M arshall W Freeman Executive Vice President COO Thomas L Kemp Senior Vice Presidents W arren Andy Ambrose H Verne Packer Donald A Pazour W ini D Ragus Vice President Production Andrew A M ickus Vice President Circulation Jerry O kabe Vice President Software Development Division Regina Starr Ridley un Miller Freeman A United News amp Media publication by Our Readers This column i5 for your feedback Send us queries suggestions complaints and praise especially praise YOU want code We Ve got code Really Check the end of this section for a special Clip and save piece Delphi Why Dear Editor hanks for a magazine for developers of es just finished reading the April May issue and have to question your editorial What does Delphi have to do with game development The magazine is thin enough without extra noise being put in also hope the magazine stays away from articles that compare games unless it s going to help me or someone else develop a game Comparing Tetris on the SNES to Tetris on Sega doesn t do me any good and can read that in the
29. Display Memory Window Control 06h Set get Logical Scan Line Length 07h Set Get Display Start 08h Set Get DAC Palette Control 09h Set Get Palette Data 0Ah Return VBE Protected M ode Interface 46 GAMEDEVELOPER J UNE J ULY 1995 STARTED WITH VE ES f MORE INFO ciTech Software makes a VESA VBE 2 0 compatible universal driver that sup ports over 160 different graphics chips Its VBE driver is available in TSR form as shareware for end users or developers Linkable library versions are also avail able for software developers For more information contact SciTech at 916 894 8400 or via e mail at sales scitechsoft com For more information about VBE contact Kevin Giliett at VESA The VESA VBE 1 2 and 2 0 Specs can also be ftp ed on the internet from x2ftp oulu fi Write to VESA at 2150 N First St Ste 440 San J ose Calif 95131 2029 or call 408 435 0333 tional need is to use bank switching to move the currently needed portion of video memory into the access window For high color and true color modes you need to do more work T he size and position of each color component can vary and your drawing code will need to adapt to the different layouts F or exam ple many new cards use 32 bit pixels for 24 bit true color modes for higher inter nal performance Fortunately the VBE mode information block contains detailed information on the layout of pixels in these modes L isting 2 demon strates drawing
30. Record Pointer Table 20 23 long 24 xx 1 var Table xx Cyy 1 var system path names and other path related data yy zz 1 var in this TRE file zz E0F var Individual Data Records NOTES 1 var refers to data having variable sizes 2 xx is the Starting Offset of the Path Name Table 3 yy is the Starting Offset of the Record Pointer Table 4 zz is the Offset of the First Data Record 5 EOF refers to the end of the file and uses about 40M B of hard disk space A VESA driver is required for SVGA graphics Because W ing Com mander III is such a large game and weighs heavily on system resources it is no surprise that many users have had trouble installing it I experienced installation troubles because the size of my CD ROM drivers combined with a Pro Audio Spectrum driver exceeded the minimum conventional memory requirements for my 8M B RAM sys tem T he game features a boot disk cre ation routine that solved my memory management problems Wing Commander III requires a minimum of 360K conventional RAM plus 7 000K of either extended or expanded memory A ccess to memory above 640K is provided by O rigin s cus tom JEMM OVL protected mode D PM I 32 bit driver Virtual memory is emulated through the use of a swap file named SW APFILE The size of the swap file is generally determined by the amount of free hard disk space and it is usually 15M B to 20M B The swap file is created when W ing Com mander III is boot
31. T he first is that the VGA Palette registers don t work in super VGA modes on some newer cards while using the VBE palette functions does T he second benefit is that VESA VBEs provide access to 8 bit DACs on cards that have them Normal VGA DAC registers only have 6 bits of color data per color but most newer cards can process 8 bits of color data per color Using 8 Bit DACs allows for smoother looking color ranges and color effects Conclusion A well written VE SA aware program should have few problems running high performance graphics on video cards that have yet to be introduced including the increasing number of cards that do not have a VG A compatible core for their high resolution graphic modes If may share an observation from experience when making a VESA VBE aware program for the first time you GETTING Listing 2 VESADEMO C Continued on p 49 STARTED WITH VESA include lt stdio h gt include lt dos h gt include lt string h gt define uchar unsigned char define uint unsigned int Stucture to hold VESA VBE Get SVGA Info Results typedef struct These items defined in the VESA VBE 1 2 Spec char Vbe Signature 4 int Vbe Version char far Dem String Ptr uchar Capabilites 4 uint far Video Mode Ptr int Total Memory VESA Vesa version Name of Video Card Bitmapped features gt List of Video Modes Video Mem 64K
32. Tie Fighter and recreating beautiful sym phonic arrangements AM D is enthusi astic about the M icrosoft Game SDK as was O rigin s Zachary Simpson who said T he InterW ave chip and the M icrosoft DirectSound API will allow unprece dented levels of audio quality and realism at consumer price points H 00 doggie this is one nice chip with its 16 bit 32 voice wavetable synthesis and on chip support for vibrato tremolo chorus echo phase shifting and reverb L ook for boards with this chip to be available and flying off the shelves for C hristmas For more information contact AMD Inc 1 AMD PI P O Box 3453 Sunnyvale Calif 94088 3453 Tel 408 732 2400 The 0 J Files ioVision of San Francisco is a turnkey motion capture service provider Inverse kinematics isn t time effective for complex human motion but with BioVision s low cost service you can have rotoscoped actors that can be disturbingly realistic you might have seen BioVision s work in the frightening recreation of the murder of Nicole Simpson and Ronald Goldman that s making the rounds on the Internet or thrilling as in a certain wildly popular football game F or every day of shooting BioVision estimates two days of post processing to massage the data into for mats for popular animation packages such as Alias Softimage W avefront and Nichimen G raphics BioVision will even supply the actors If you don t need cus tom work BioVis
33. acintosh It s just a call to DisposeGWorld which ditches the G W orld for good To use the COffscreenBuffer class properly on the M acintosh be sure to turn on the pmExplicit and pmAnimated flags of all entries in the palette of the target window to ensure that the color indices used in the offscreen buffer will properly match the colors on the screen yielding highest copying speeds and proper color matching Windows Like GW orlds on the M acintosh W inG is the obvious candidate for implement ing a double buffering architecture for W indows W inG lets us create a buffer access its bits and copy it to the screen quickly The W indows declaration of COffscreenBuffer appears in Listing 4 T he following implementation appears in Listing 5 W inG allocates an offscreen buffer for us when we use a WinGCreateDC WinGCreateBitmap call pair The buffer memory allocated this way COffscreenBuffer COffscreenBuffer void Use the current GDevice and GrafPort to make a GWorld CGrafPtr CurrentPort GDHandle CurrentDevice GetGWorld amp CurrentPort amp CurrentDevice Get the color table from the current port PixMapHandle CurrentPixMap CurrentPort gt portPixMap HLock Handle CurrentPixMap CTabHandle ColorTable CurrentPixMap gt pmTable Create a new GWorld with this information NewGWorld amp 0ffscreenGWorld 8 amp CurrentPort gt portRect ColorTable CurrentDevice noNewDevice Sto
34. alues 62 2b 01 3f 84 07 00 00 Asthe Indirect Record Pointer T able entries showed us the 62 2b 01 3f values are bit flags and the 84 07 00 00 bytes con tain the long pointer T he data beginning at hex offset 784 don t forget about the PC s method of storing data in low byte and high byte format references an entry in the Record Pointer T able that reads as ae 13 f4 00 ac 04 00 00 Keeping in mind that the Record Pointer T able contains the file offset and size of the actual D ata Record you ll see the data for the mis sion file names is stored at hex offset f413ae and is 4ac hex bytes in size If you verify my example by looking in the GAMEFLOW TRE file for the mis sion file names you will see these names as ASCII text listed using O ri Listing 2 The Mission Look Up Form RECORD NAME LOOK0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 0050 0051 misnb2ne 0052 misnc2ne 0053 misnd3bd 0054 misndib 0055 0056 0057 0058 0059 0060 0061 misnl01d 0062 0063 0064 0065 0066 misnp000 54 GAME DEVELOPER J UNE J ULY 1995 RECORD DATA MISSION FILE NAMES misna001 misna002 misna003 misna004 misnb001 misnb002 misnb003 misnb004 misnc001 misnc002 misnc003 misnc004 misnd001 misnd002 misnd003 misne001 misne0
35. ass of function or performance as either the M icrosoft or SGI tools on IRIX they seem to be exert ing pressure on software prices for the entire market regardless of platform asked D ave Larson how Silicon G raphics viewed these lower priced products and how his company would respond W e re moving down in terms of markets declared L ar son As our price points come down we re cutting deeper into various mar kets Historically SG has been per ceived as vastly more expensive and out of reach a boutique kind of machine We think we re rapidly expanding beyond that and that we re within reach for a lot ghana been launched for the Windows of people developing digital entertain ment for a living It s all about how much time you have to get your work done For instance a friend of mine just of audio work on the M ac and he just started using a new audio application on our platform H e says it s dramatically affected his work just after a few days of working with it W hat he used to think ahead to do he now does in real time H e can test his decisions as he goes T hat s the metaphor for performance change Everything happens so much more quickly on the SGI platform and your creativity can increase E came up who s been doing a lot LT p g Sega and Nintendo Choose Sides T here s an interesting sidebar concerning SGI and M icrosoft T he two archrivals in the game
36. ay the same thing about 1995 no doubt One article that caught my eye focused on the technique of transferring cartoon quality film a clip from D isney s Snow White and the Sven D warves into digitized EGA display Y eeeesshhh the final result looked horrible So maybe the time wasnt right back then for creating digital media from live footage B ut like a rolling snowball picking up size and speed the graphics industry is maturing to the point where there s not too much anyone can t do at an affordable price M icrosoft and Silicon G raphics SGI thanks to recent acquisitions and merg ers are helping to fuel this momentum Competitive Partners ee TAS The relationship between Microsoft and Silicon G raphics has changed enormously over the past 12 months Silicon G raphics is the dominant player in the graphics workstation market and M icrosoft is the giant in the PC software market H owev er when M icrosoft acquired Softimage last summer M icrosoft gained a powerful 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 SGI platform but Microsoft has stated its plans to port Softimage tools to Windows NT from these two GAME DEVELOPER J UNE J ULY 1995 11 CROSSFIRE suite of IRIX based animation editing compositing and cel animation tools It in
37. cartridge market N intendo and Sega have gone to separate corners for their respective development tools and you can probably guess whom each has enlist ed In 1994 Nintendo selected A lias whose software was used to create the Super NES blockbuster D onkey Kong Country as the authorized graphics devel opment system for both current games and next generation 64 bit games L ast Janu ary Sega chose Softimage 3D as the offi cial three dimensional development tool for the new SegaSaturn game platform 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 W indows NT version users stand to gain from a price war between two resource rich companies like Silicon Graphics and M icrosoft Feature sets and performance should evolve more rapidly and it undoubtedly will spur other SGI platform competitors to keep up Y ou 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 NI Alex Dunne is contributing editor for Game D eveloper magazine BI BLASTS Game Developer Staff If was some show Alexander Antoniades kept an eye on the tenor of the Show Larry O Brien and Barbara Hanscome cheched out new prod ucts And Nicole Claro
38. ces R elease 4 features a significantly speedier 3D Editor which is where users spend much of their time One great advantage of 3D Studio is its support of network rendering Using a single copy of the software you can add any number of networked com puters to a queue to participate in ren dering a project essentially multiplying your computer s resources manyfold and saving you valuable time M ultiple files can be lined up for unattended network rendering while 3D Studio manages the workload assigning tasks to slave machines as they become available A 250 page manual is devoted to outlining the many new features in Release 4 O ne highlight is the C amera Control and Perspective M atch capabil ity which aids in camera placement and rendering for coordinating your view with a scanned photo image A nother is a Keyframe Scripting Language that uses BASIC like commands to build in collision detection and elementary physics T here s also a Fast Preview fea ture that allows rendering modes from wireframe to Phong highlighted G ouraud shading for full color previews of animations Perhaps the coolest new feature is the addition of Inverse Kine matics T his makes possible hierarchi cally linked object chains such as jointed limbs that recognize range of movement constraints W hile it is tempting to describe 3D Studio as fully featured its tremen dous flexibility is further enhanced by the availability of myriad t
39. ction as we sometimes think of it with an integer part and a fractional part since a mod b is always smaller than b Even if we want to ignore the ANSI standard and hope our platform calculates mod correctly we re out of luck on most machines including Intel x86 processors T he x86 signed divide instruction idiv truncates towards 0 when dividing negative numerators which is exactly the opposite of the real floor function It appears we need to develop a flooring divide and mod function that works on any standard platform that is any platform that computes positive mods and divides correctly If a2 0 then we ll just do the nor mal divide and mod On the other hand if a lt 0 let m 2 a mod b pres 5l o Gm mz0 b 0 m 0 amodb l ii 7 b a mod D m 0 In other words Equations 6 and 7 say that if m 20 there is no remainder then we do the flooring divide and mod differently than if there is a remainder This probably seems really complicat ed but if you sit down with a piece of paper and refer to the equations and Figure 3 you ll see how this works in no time okay maybe five or ten min utes it took me a while too Our C function to correctly compute flooring divides and mods looks like this inline void FloorDivMod long Numerator long Denominator long amp Floor long amp Mod assert Denominator gt 0 we assume it s positive if Numerator gt 0 po
40. d Lunar and Sea Colonies You can wander alone through each of these exotic locales for a mere 49 per 3D For You Too W e ve looked at three significantly dif ferent programs each with its own dis tinct advantages and disadvantages And the marketplace is crowded with many more than could profile here even if I d had the chance to use them all which haven t yet If you ve been thinking about mak ing the move to three dimensional design think some more about just what it is you hope to find in those three dimensions As these three exam ples show there s a wide range of prices features and functionality to consider Asked to choose between them I m not sure could I d hate to give up the depth afforded by 3D Stu dio love the natural feel of working in trueSpace and if was just starting with three dimensional graphics the bang for the buck value of Visual R eal ity would surely be tempting Fortu nately certain file formats are common between programs so if you do have access to a variety of three dimensional software you can probably make use of the best features of each If you ve been using one three dimensional program and you re not satisfied with what you ve been able to do with it there may be a better choice out there for you It doesn t necessarily mean spending more money this time around either Rather it s that quest for the brush that fits your hand BI D avid Sieks is a contributi
41. dients d ne verZdX UOverZ Gradients dU verZdX VOverZ Gradients dVOverZdX SCREEN The Integer Rasterizer Continued from p 24 DOUBLE BUFFERED GRAPHICS A C Class for Cross Platform Double Buffered Graphics 28 GAME DEVELOPER J UNE J ULY 19954 hat if someone told you that you could release a game simultaneously on Win dows M acintosh and DOS with no more effort than it takes you to release a DOS game now O f course you d kick the person off your staff find a loophole in his or her con tract or refuse the project proposal T here are no freebies in software devel opment But what if someone said you could release your product on M acintosh and W indows with very little extra work and showed you how to do it This article takes the first step in that direction by defining a simple dou ble buffering architecture that will lever age your existing three dimensional ren dering animation sprite composition and other custom 8 bit graphics code onto W indows and M acintosh systems Using the small C class implemented here you will be able to write 32 bit graphics applications that compile and run without changes on M acintosh Sys tem 6 0 7 and 32 bit W indows includ ing W in32s and W indows 95 Double Buffered Graphics D ouble buffered graphics provide the core graphics technology that power almost all high performance desktop multimedia and entertainment software From simpl
42. e separately have been combined into one integrated user s manual It s well written and helpful filled with pointers for optimizing performance as well as aesthetic tips T he tutorials are in depth explaining each step of the process rather than just providing a quick run through W hat V isual Software invites is the creation of virtual worlds and toward this end V isual R eality s set design tools are impressive T he Light D esigner in Renderize L ive provides complete con trol over light and shadow define ambient lighting point lights spot lights and area lights specify color intensity and attenuation as well as position and direction shadows can be enabled or disabled for each light and the intensity and sharpness of the shad ow set by the user Photorealistic effects are enhanced by adjustable distance haze fog levels and colors and by cam era settings that simulate the look of zoom and wide angle lenses C ameras are also fully animatable though it is important to note that objects are not animatable M aterials editing and mapping capabilities are extensive not to mention that the package comes with over 1 000 textures including 200 seamless textures Rendering options allow for texture bump reflection and transparency mapping Visual M odel the arena for three dimensional object creation is also packed with features including Boolean Create your own virtual worlds with Visual Reality or samp
43. e 1 VESA Mode Numbers games that have come out VESA recently A new trend is afoot MODE in the game industry G ames NUMBER TYPE are moving away from 320 by 200 pixel graphics to 640 by 480 and higher resolutions For a long time now we ve seen game after game with a screen reso lution of 320 by 200 pixels first with EGA s 16 colors and then VGA s 256 colors In this article I ll introduce you to the force that s making this upward graphics doni in Sams possible and RESOLUTION COLORS 100h GRAPHICS 101h GRAPHICS 102h GRAPHICS 103h GRAPHICS 104h GRAPHICS 105h GRAPHICS 106h GRAPHICS 107h GRAPHICS 640x400 256 640x480 256 800x600 16 800x600 256 1024x768 16 1024x765 256 1280x1024 16 1280x1024 256 109h TEXT 132x25 16 Ini 10Ah TEXT 132 x 43 16 IBM i men OD Bum ago it woude standard to whi ers wrote pro 10Dh GRAPHICS 320x200 32K grams First came the CGA in 1982 fol 10Eh GRAPHICS 320x200 64K lowed by the EGA in 1985 and the MCGA and VGA in 1987 G ames and other graphics programs adapted to the new video standard compilers added built in support and the world was an orderly place for developers So what happened to produce the video card T ower of Babel that we have today IBM brought out the 8514 A dis play adaptor and users and developers gave it a big thumbs down But the maturing PC industry didn t sit still for IBM In the absence of a standard that the market was eager for video card manufac
44. e card games to immersive three dimensional environments such graphics use offscreen memory to hide image composition from the user and provide smooth transitions between frames of animation M ost games today and probably most games created in the near future will rely on copying or page flipping 256 color graphics from offscreen memory to display memory Full screen 8 bit double buffers such as these are chunks of RAM man aged in such a way that a one to one mapping exists between pixels on the Screen and bytes in the buffer T hat s all double buffering is so why not abstract it in a platform independent interface All it takes to create an image in the offscreen buffer is a definition of the screen to offscreen mapping and a method to describe the image in the off Screen buffer to the screen For all the platforms game developers generally deal with this requires at most four pieces of information pBits a pointer to the offscreen buffer byte that maps to the screen point 0 0 Stride the number of bytes between the buffer byte that maps to the screen point x y and the buffer byte repre senting x y 1 Width the width in pixels of the rec tangle represented by the offscreen buffer Height the height in pixels of the rec tangle represented by the offscreen buffer Given these four pieces of informa tion you can implement any graphics algorithm to render three dimensional texture map
45. ed and erased when you exit the game T his file is erased when you exit the game via the Alt X keystrokes So be sure to erase the swap file from your Wing Commander III hard drive subdirectory if you exit the game using any other method such as rebooting your PC T he primary W ing Commander III executable WC3 EXE is about 1 1M B in size Wing Commander II was developed using the M etaW are H igh C C system and is written pri marily in C T he M etaW are H igh C system features C templates and a compiler for developing 32 bit protect ed mode applications The W C3 EXE game engine includes a built in E xami nation M ode that provides general development and debugging informa tion while the game is running D evel opers can observe the status of the numerous game engine flags accumula tors stack manipulation calls and game flow data such as act scene and mis sion information found several undocumented keystrokes while explor ing game operation and I ll summarize them further on Data Storage E ssentially all of the game data is stored in files suffixed with TRE I will refer to these data files as TRE files TRE files use a very flexible open ended data storage format that allows for very large files You can store hundreds of megabytes of data in a single TRE file Listing 1 gives a general summary of the TRE file format T he first four bytes in the file contain the XTRE ASCII text string The
46. ed int Accessing VESA typedef struct VBE Features e Th iti defined in the VESA VBE 1 2 All VESA VBE functions and features ee esos itene detinedlinithe NES ect are accessed through the INT 10h inter char Vbe_Signature 4 VESA face For programmers unfamiliar with a Usar PAGES HE e thi g ilow met xplain In char far Uem String Ptr Name of Video Card 3 p visae de ie C0 XD a uchar Capabilites 4 Bitmapped features addition to traditional hardware inter uint far Video Mode Ptr gt List of Video Modes rupts the Intel CPU design allows for daretur do ceo ben sd edd software to issue interrupts Software f 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 ah ee TES char far em Vendor Name tr without knowing where it is in memory char far amp en Product Mame Par Interrupt number 10h 16 decimal is char far Oem_Product_Rev_Ptr used to access video BIOS services s TA EE x 1 uchar reser vet 3 From the 1 spec T hese 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
47. en an acceler ated brain hits a screen door it s also where the action is in terms of software Although demos that don t have to bother with little things like gameplay always achieve higher frame rates vendor after vendor was showing convincing evidence that the bar s been raised or extruded for 4 GAME DEVELOPER J UNE J ULY 1995 popular graphics But why fight it The truly amazing thing is that all of this the sound work the three dimensional graphics with incredible frame rates the hottest con tent was running under a single platform W indows Y ou heard me right bunkies M icrosoft has decided it wants the home market and will do what it takes to make the successor to W indows 95 W indows 95 H the number one game platform Like anyone in the press I m used to getting a lot of opinions about major M icrosoft initiatives Y ou expect some people to love it on technical merit some people to hate it on technical merit and a lot of people to hate it on the general prin ciple that M icrosoft s a big successful company and therefore is evil But no mat ter who talked to about the M icrosoft Game SDK with its four APIs for graph ics input network connection and sound it was a love story N ot one to be swayed by public sen timent put on my sunglasses with the special A nti H ypnosis coating and met with M icrosoft s Game SDK advance team W hat can say T hey ripped off the glasses and made me
48. ention we derived last issue As did last time encourage you to get out a piece of graph paper and join in the fun Speaking for myself find it impossible to learn math with out scribbling all over the place If you don t like math well com puter graphics is math for the most part so I m not sure what to tell you M y goal is to describe the math in an accessible way but I m not going to hide the fact that math underlies every thing about computer graphics espe cially three dimensional computer graphics If you like programming you will definitely like math heck math s even better than computer program ming because there are no compiler or operating system bugs Of course there s no compiler or operating system to tell you when you ve done something wrong either Raster Blaster W hen say rasterization mean taking the continuous geometric triangle defined by its vertices and displaying it on the monitor s discrete display grid or raster The rule we defined for doing this is called a top left fill con vention where we light all pixels that are strictly inside the polygon bound aries and any pixels that are exactly on the polygon boundary if they re on the top or left edges remember pixels are boxes with a center not just points Figure 1 shows this fill convention in action Pixel 5 2 is lit but pixel 9 4 is not even though our polygon edge intersects both within the limits of
49. ey cant even finish the shareware lev els lamented K ulas After fixing the rejuvenated robots bug another aspect of gameplay was criticized by D escent players W hile players could save pilots and return to levels they had completed there was no in level save game feature as in L ucasA rts s D ark Forces Convinced that this was too popular a feature to overlooked Parallax added an in level save game option to one of its first revisions Ascent W hat does the future hold for Parallax First will be the C D E nhanced version of D escent which will be to D escent what D oom II is to D oom that is more levels with a few new features A fter that maybe Descent II but definitely D escent for M acintosh for Sega s Saturn and Sony s Playstation W hile the saying around Parallax during the making of D escent was T his project is our company in the future Parallax will concentrate on two projects instead of one W e can t compete with W ing Commander III admits T oschlog but with two small teams of programmers Parallax hopes its games will be written and designed well enough that it won t haveto MI Alexander Antoniades is G ame D evel oper s editor at large Contact him via e mail at sander gmfi com or through G ame D eveloper magazine GAME DEVELOPER JUNE J ULY 1995 59 ARTIST S VIEN The Three Fs of 3D Features Functionality And Fordability The incredible can be made to look believable
50. fer dimensions to the new dimensions of the window wouldn t be a bad idea Y ou ll need to look at UpdateGWorld on the M ac intosh and you ll most likely have to cre ate a new WinGBitmap under W indows M any applications don t want an API as clumsy as SwapBuffer Y ou want to optimize your screen accesses by writing only the areas that haven t changed A SwapRect method would do the trick very nicely Implement it on both platforms and remember to make the rectangle description platform independent And what about colors Both con structors use the current palette to initial ize the offscreen color table but wouldn t it be nice to enable color animation Just be sure to maintain that 1 1 offscreen mapping for speed Listing 5 Windows Implemen This is here to keep it off the stack during the constructor call struct BITMAPINFOHEADER Header RGBQUAD ColorTable 256 BufferInfo COffscreenBuffer COffscreenBuffer void HWND ActiveWindow GetActivelWindow Make the buffer the same size as the active window RECT ClientRect GetClientRect ActiveWindow amp ClientRect Width ClientRect right ClientRect left Height ClientRect bottom ClientRect top Stride Width 3 amp 73 Set up the header for an optimal WinGBitmap if WinGRecommendDIBFormat LPBITMAPINFO amp BufferInfo Preserve sign on biHeight for appropriate orientation BufferInfo Header biWidth Wid
51. for devel oping drivers for popular programs and providing documentation to software developers And to be honest software developers were pretty low priority for most video card makers T he only glimmer of hope for using a card s high resolution modes was pro vided by M icrosoft s W indows As W in dows 3 0 and then 3 1 became an indus try juggernaut it forced manufacturers to make W indows video drivers a priority W ith a W indows video driver any W in dows program could take full advantage of the video card s enhanced graphic capabilities T he only drawback W in dows was anything but an ideal choice ol 3 graphiste games M icrosoft s W inG may bridge that shortfall in the ut up to this point games have much been forced to stick with id the VGA standard T o alleviate this problem the Video ectronics Standards A ssociation VESA was founded in 1989 as a non profit organization to set and support industry wide open standards for the PC environment Starting in August 1989 with a standard mode number for 800 by 600 16 color Super VGA graphics VESA has been busy working with the PCVESA terms standards for video and related items VESA came up with a sys tem of extensions to the normal VGA BIOS that manufacturers could retrofit to existing cards In October 1991 Space some new cards don t have a com plete VESA VBE implementation in their ROM S For older cards the manu facturer can provide a dri
52. gt Vbe_Version MajorVer ver gt gt 8 bug check Some BI Ses return 0x0102 instead of 0x0120 Check for Minor version in wrong nibble and correct ver amp OxFF if m 0 amp amp m amp Ox0F 0 1 MinorVer m 10 else MinorVer m gt gt 4 10 return ver should start by getting the VESA VBE 1 2 and 2 0 specifications and studying them Then heartily recommend that you obtain other VESA VBE code and study it VBE support varies and the specifications leave some room for inter pretation For example W here the VBE 2 0 says All other registers are pre served many VBEs still trash the high words of extended registers A nother example is that some VBEs return a value of 0 for a window granularity of 64K instead of returning 64 T here is a wealth of information and detail involved in using VESA Video BIOS Extensions and we didn t have room in one article to cover it all do hope you now have an idea of what you ll be facing when you develop a program that uses VESA graphic modes M aking the effort to use VESA VBEs can bring great rewards to the developers who want their programs to stay on the cutting edge Until next time happy coding NI M att Pritchard is presently launching his software company Innovatix in Gar land Texas and is the author of MODEX105 a comprehensive freeware M odeX library You can reach him via e mail at matthew p netcom com
53. he 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 W oodland H ills Calif wants to maketh you like unto a god Y ea verily and for cheap too Their Visual Reality suite is a virtual Swiss A rmy 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 does thoroughly and for under 300 Visual Reality consists of five sepa rate but cooperative applications Renderize Live is the workhorse of the group It serves as the stage around which you place objects lights and cameras and is also where you will render final images or ani mations Visual M odel is where you create three dimensional objects that you can then transfer to your scene in Renderize L ive Visual Font makes possible three dimensional text objects with bevel ing and extruding properties Visual Image is a two dimensional image editor Visual Catalog organizes projects from the preceding modules and facilitates the sharing of resources within the suite Visual Catalog is a new feature with Visual Reality 1 5 and it s a wel come addition that makes it much easi er to carry on a project between the dif ferent applications Also the handbooks for each module previously availabl
54. heir team did this by placing the player in a spaceship surrounded by robot adver saries T his let them create all the moving objects using big polygons that could be texture mapped and viewed from any angle T he game takes place in a mine on a distant planet so there s no sky to view and all of the remaining objects that aren t polygons are either rotated so they re always facing the viewer or situat ed in areas where they can t be viewed from above Early in the development process Parallax toyed with the idea of having irregular objects that were flat bitmaps rapidly shift to simulate different view points But having over 70 bitmaps for each stage of a movement ended up using too much memory hence the decision to stick with simple polygons E ven though D escent s game play didn t change much from its beginnings with Apogee T oschlog and Kulas learned more about project management this time around For example T oschlog observed that in a project of this size almost all things need to be done onsite Sometimes they learned this the hard way as when the music files came back towards the end of the project too large to fit on two disks A more positive sur prise development was that team mem bers like A dam Pletcher who was hired as an artist would often make great sug gestions in areas outside of their special ty such as game design Following the lead of many other companies Parallax used Doom as a benchmar
55. hird party plug ins alluring little extras that let you for example twist crumple or explode your three dimensional cre ations or add smoke snow or fireworks to a scene and much much more A utodesk encourages developers to build around its product and claims that new plug ins are coming at a rate of about one a week there are already over 200 available All of which makes for a very richly featured tool indeed And it can be yours for about 3 000 third party plug ins of course are sold separately But what s it like to use W hile the breadth and depth of 3D Studio is a spur to the imagination the sheer scope of it is also somewhat daunting found the five manuals that s right five were clearly written and well organized T hey include an excellent book of tutorials that s over 500 pages long yet still bare ly scratches the surface Savvy users also recommend Inside3D Studio from N ew Riders Publishing Indianapolis Ind a hefty book of tips for newcomers and David Sieks You need to weigh manu factors when choosing software for three dimension al design Sure I s great if a tool is hip and cool but is it affordable usable and versatile GAME DEVELOPER JUNE J ULY 1995 61 ARTIST S VIEN techniques for professionals loaded with hands on examples These and a lot of patient experimentation will get you going as the interface while not necessarily intuitive is certainly fa
56. hmarks do the 1 million flat shad ed polygons per second really tell us anything about the performance of the console box A number of key factors are missing from such a claim such as the database traversal geometric trans formations clipping and lighting T his performance claim relates to the final stage of the three dimensional pipeline the rasterization stage T his stage only measures the performance of the frame buffer memory subsystem Chip designers and developers quote the memory subsystem band width in pixels per second which you can easily convert to polygons per sec ond once you know the area of the polygon If the area of the polygon is quoted with the polygons per second at least we can better understand the ras terization stage in the pipeline This element is missing from the quote of 1 million polygons per second T he performance claims for the console box and the workstation mentioned previously should be modified to 1 mil lion flat shaded single pixel polygons per second vs 100 000 flat shaded 100 pixel polygons per second N ow we can compare the last portion of the pipeline on a relatively fair basis and then make a straightforward determina tion that the workstation is 10 times faster than the console Given the area of the polygons we can compare the performance of the memory subsystem A fair comparison between two platforms can only be made if the other stages have been com puted Then
57. hundreds of magazines devoted to games Other than these few complaints really like the magazine hope it grows and becomes very successful feel that this magazine will be a valuable resource for my library Brien King via e mail Editor Larry O Brien responds Close your eyes and visualize this Games Windows What do you see A virtually empty universe with Solitaire the brightest star Now close your eyes and visualize this Win dows Home market What do you see The fastest growing sector in the computer industry Vast clouds of money being sucked faster and faster into the pockets of those who create digital entertainment Delphi Is a tool for those who want to become little neu tron stars of dense money DON T FORGET THE MACINTOSH Dear Editor charter subscriber l ve been reading Game Developer since your premiere issue and while you generally do a fine job on the article topics and writing in general am concerned about your blatant pro DOS and Windows bias Why not just change the name to Windows Game Develop er and avoid confusion l ve developed on both PCs and Macin toshes and greatly prefer the latter The fact that there is a much larger market for DOS and Windows software than for Macintosh software is a tribute to Microsoft s market ing abilities However Macintosh developers do exist and we would like to read some articles pertinent to us Mode 13 and Sound Blaster prog
58. ing Lighting magine you have just purchased the top of the line three dimen sional game board for your PC Y ou find yourself playing a flight simulator with texture mapped polygons and digital sound effects You can hear the roar of the engines as you fly over the San M ateo bridge Y ou execute a steep dive and squeezing down on the shaking joystick you blast away at the terminals spreading havoc amongst the innocent Y ou ve fed your lust for destruc tion T hen you hear a voice say that M offett Field has just launched inter ceptor F 14s to hunt you down Let the missiles fly you re ready for a dog fight At this point you don t really care that the hills are texture mapped poly gons using real Landsat imagery Y ou are much more interested in surviving the upcoming dogfight Unfortunately as you pass over the Oakland hills at 500 feet the frame rate goes down and your game turns into a major drag W hat happened Rasterization 3D Pixels Frame Rate Blues T he frame rate fell below one frame per Second because the game accelerator s graphics capability was unable to han dle the number of polygons in the scene H ow do you avoid buying a graphics card that makes a game unplayable W hat measurements or cri teria can we use to judge the perfor mance of a particular game on a partic ular platform T hese questions are of concern to many game developers as well as
59. ing x regardless if we re stepping left or right T his probably differs from other DDAs you ve used before the mathematically defined floor and mod terms work out so that you re always adding 1 when your error term rolls over not just when you re stepping in the positive direction Look Before You J ump T hose of you who have written fixed point edge rasterizers instead of error term DDAs are probably wondering why we re going to the trouble of doing a DDA with its accompanying jumps when the error term rolls over E ven though the jump is in the scanline loop not the pixel loop jumps are get ting more and more expensive as processors get deeper and deeper pipelines In fact on more recent Intel architectures the jump prediction logic makes mispredicted jumps that fall through even more expensive than jumps that are taken on earlier proces sors Fear not there is a good reason to use an error term DDA instead of fixed point to scan our edges Remember the following lines from our floating point texture mapper BEHIND in Part 1 int XStart ceil pLeft gt X float XPrestep XStart pLeft gt X float OneOverZ pLeft gt 0nelverZ XPrestep Gradients d0neOverZdX W hen we start a scanline we need to step in to the first pixel center from the real edge before we can start draw ing and our interpolants like 1 z in this snippet need to step with us W e had to calculate XPrestep every scanline and
60. ing you ever wanted or at least start you along that path Color 32 bit QuickD raw intro duced a new architecture for offscreen drawing support on the M acintosh called a GW orld which became a reliable part of the operating system in version 6 0 7 T his extension allows the use of Quick D raw functions to draw into structured offscreen memory and it enables the M acintosh version of C ffscreenBuffer declared in Listing 2 and implemented in Listing 3 Constructing a buffer from a G W orld requires a single call to the handy function called NewGWorld T his 30 GAME DEVELOPER J UNE J ULY 1995 API requires a rectangle describing the dimensions of the desired buffer and a color table both of which the C ffscreen Buffer constructor swipes from the active window The dimensions come directly off the CGrafPort structure and the color table comes from the associated PixMap For good measure ve chosen to lock down every handle ever used here though you may not always have to do SO T he constructor s task finishes with the call to NewGWorld at which point the calling application becomes the proud parent of a COffscreenBuffer object So far so good H owever gaining access to the bits of that GW orld proves to be a trifle difficult because the operating sys tem has allocated the buffer in moveable memory Enter Lock and Unlock those traditional commands that prevent data from moving in a linear address space Befo
61. inner loop of an optimized rendering engine But you get the idea Another simple graphics function would be to fill the buffer with a solid color Using the four atomic offscreen data could perform this buffer clear with a few simple instructions char unsigned pBits pBuffer gt GetBits for int y 0 y lt pBuffer gt GetHeight y pBits pBuffer gt GetStride memset pBits Color pBuffer GetWidth For every line in the buffer this fills as many bytes with the specified color as there are horizontal pixels then skips down to the beginning of the next line If know that the buffer occupies contigu ous memory that any additional bytes included as padding are ignored and that Stride is positive can make a small optimization and write the buffer clear like this long BufferSize pBuffer gt GetHeight pBuffer gt GetStride memset pBuffer gt GetBits Color BufferSize T his would however be a bad idea as Stride has been defined as a signed long value and will often be negative on W indows machines A third simple example would be to draw a 45 degree line from the point x y to the point x n y n where n is positive N o problem char unsigned pPixel pBuffer gt GetBits pBuffer gt GetStride y x Adding Stride 1 moves the pointer from x y to x 1 y 1 for int i 0 i lt n i pPixel pBuffer gt GetStride 1 pPixel Color W
62. ion has partnered with Viewpoint D ataL abs to provide over 200 standard motion sets For more information contact BioVision 1580 California St San Francisco Calif 94109 Tel 800 866 3463 VIOLENCE 15 FINE BUT WHAT ELSE IS THERE f you were at the right place at the right time at the CGDC this year the lobby of the Westin Hotel at 5 30 on Sunday you might have been asked to join an informal round table discussing game strategies that appeal to a broader audience namely women and nontraditional game players J ust what kind of games appeal to game players who aren t 18 to 35 year old men And what can game designers do to reach them Jessica Miller game designer and president of Spirit Games in Salem N H and myself were lucky enough to be so well positioned in the lobby and for the next two hours we chatted with three game designers interested in bursting out of the shoot and kill model Alex Uttermann game designer and author of several game strategy books including Dragon Lore the Official Strategy Guide Rusel DeMaria game industry journalist and president of DeMaria Studio and Dennis Hescox vice president of Lightside Inc Hescox organized the roundtable in hopes to build a network share information and discuss marketing development and research strategies for alternative games He came armed with psychological and academic theories and studies relating to differences between male and female game playing
63. ir benchmark and the subsequent published results allow the consumer a level of confidence T hey also allow the run time application to choose an appropriate level of complexity in each frame at run time For the actual user it appears that a magic number is most appropriate but this number must be based on a benchmark that exercises the entire graphics pipeline G ame develop ers must insist that a benchmark can be easily translated into a metric like 30 frames per second at 1 024 by 768 at 256 colors per pixel T he magic number model can be published with the graphics board or the actual game platform T hese num bers give the consumer some guarantee of game play performance T his is the same model that is applied to W indows performance today If a graphics board or system has a W inBench 95 of 15 then the consumer knows the platform is a good accelerator for the majority of W indows applications Also if another graphics board is a level 19 then there is some amount of confidence that the later model is faster for most W indows applications The magic number also has another effect which isn t necessarily seen by the consumer If the operating system environment saves the perfor mance criteria for the platform into system information then the game can scale its displayed data appropriately For example if a certain platform pro duces 10 000 texture mapped polygons per second through the benchmark then the app
64. irly logical once you re grounded But keep those manuals handy N ew 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 E ven experienced users however complain of the diffi culty of creating biomorphic forms O ne workaround is to check out plug ins from Crestline Software C restline Calif which offer virtual mannequins with walk and run motion facial expressions and hand gestures C rest line s Tim Wilson says models of other creatures starting with dinosaurs are in the works Joel Gwynn applications specialist at Cambridge M ass based D esigners CADD Company an A utodesk reseller and design shop finds that most 3D Studio purchasers have a specific task in mind when they begin D esigner s CADD can go onsite and train users through that project so the knowledge they re gaining is immediately applica ble which is a great way for a new user to get up to speed Check with your Autodesk dealer about the availability of training T here are also training sem inars from Autodesk University If you don t have the luxury of a long stretch for innocent childlike exploration and experimentation that may be your best bet Caligari trueS pace Or maybe you ll want to take a look at what Caligari Corp has to offer Usable i
65. it is already an integer F or example Hle pja is 3 EI and EIE Notice how the ceiling behaves with negative numbers it bumps the value to the next highest value not to the next highest absolute value T he ceiling is the perfect function to realize a top left fill convention for left edges and top edges if you solve for y instead of x in Equation 2 If we re exactly on an integer pixel center we will light the pixel but if our x is at all greater than the integer to the left of the pixel center the ceiling will bump us up to the next pixel that s strictly inside the edge It should be pretty obvious that the equations for right and bottom edges are the same as for top and left edges with the addition of a minus one outside the ceiling T hat is if the edge is on the integer pixel the ceiling won t affect it but the Chris Hecker Perspective texture mapping is a huge subject much too big to cover in one or even two articles In Part Il of his series on the subject Chris Hecker tackles fasterization an essential concept GAME DEVELOPER J UNE J ULY 1995 19 BER INO THE SCREEN minus one will knock us back one pixel following our fill convention If the edge is greater than the pixel the ceil ing will bump it up one to the first pixel outside the edge and the minus one will bump it right back inside the polygon Another way of looking at it is if we have two polygons with a
66. ith some extrapolation on the J on Blossom Double buffering is the heart of high performance graphics With this C class you ll be able to write your code once and com pile it for Windows Of the Macintosh GAME DEVELOPER J UNE J ULY 1995 29 DOUBLE BUFFEREJD GRAPHICS Listing 1 Public Functions class COffscreenBuffer public Basic information access char unsigned GetBits void long GetStride void const int GetWidth void const int GetHeight void const Displaying the buffer void SwapBuffer void const Pixel access control void Lock void const void Unlock void const part of the reader these simple examples show that the COffscreenBuffer interface shown in L isting 1 provides all the essen tial elements for a complete graphics sys tem Further none use any code outside the accepted ANSI C supported by any compiler worth its salt In other words as long as your tar get platform can transfer an 8 bit packed pixel image from memory to the screen and supports an ANSI C compiler you can write a COffscreenBuffer imple mentation and support the drawing func tions above without changes Making It Macintosh So let s get down to the business of implementing COffscreenBuffer on the two platforms most likely to be the mul timedia systems of the future W indows and the M acintosh On both I ll show you how to exploit system supported double buffering to do everyth
67. k of what to include in its game W hile this took off the pressure of worrying about things like cut scenes the team balked at including one of D oom s most popular features N etwork play Parallax was reluctant to add networking capability because the work required was difficult but the team also knew it was important for comparison with D oom so they gave in Interestingly it was not net work bandwidth that instituted the eight player limit in the final version of D escent but the incredible slowdown that occurred if more than eight players were in the same room during a network game O ne area where Parallax took a definitive Doom approach was making D escent a shareware release T his was a decision made during the A pogee days and Interplay decided to stick with it D espite the fact that D escent was no longer being published by A pogee A pogee let Parallax post D escent on its highly accessible Software C reations BBS for distribution D espite careful planning and pro gramming there were some problems with the 1 0 release of D escent O ne bug that bit Parallax hard was when robots recharged their shields after the player died forcing the player back to the begin ning of the level T his took a terrible toll on level 7 the last level of the shareware version in which wearing down the boss robot s shield over the course of many players ships was the strategy People aren t going to register a game if th
68. l offer very attractive price to performance ratio in the range of performance that it delivers W e also feel that for people who have PC based net works for example developers who are CROSSFIRE using A utodesk s 3D Studio it will be important for them to run a high quality 3D product in the same environment that they re running their other tools think that s going to be key to the games devd opment area Downward Pressure on Prices In addition to announcing the porting of Softimage tools over to Windows NT M icrosoft announced in January that it was slashing the price of all Softimage software by up to 5096 W hat was behind this aggressive move W right explained O ver the last couple of years inter active developers have begun to require high OCC end tools as games have become more sophisticated W e looked at our pricing structure and said W ell those prices make sense if we continue to main tain our high end feature set for our tradi tional market But if M icrosoft really wants to penetrate the market for game developers as well as other emerging inter 14 GAME DEVELOPER J UNE J ULY 1995 active media it s important to have more aggressive price points and maintain that leadership position A large number of graphics and animation products have D OS and M acintosh platforms recently by companies like C aligari and Strata Although these products arent in the same cl
69. le one of theirs The Northern Castle is just one royalty free three dimensional environment available to game developers in the Simply Scenes series from Visual Software GAME DEVELOPER J UNE J ULY 1995 63 AR T Sag VIEW operations for adding subtracting and intersecting forms along with the usual editing tools Unfortunately haven t found it very easy to make use of all these goodies Its method of defining three dimensional space is not very intuitive so that I m always having to refer to the manual to make sense of the process And the worlds I ve created with Visual Reality are lonely places given how difficult I ve found it to attempt organic forms in the modeler Speaking of lonely virtual worlds Visual Software is introducing a com panion series called Simply Scenes that consists of fully rendered yet eerily uninhabited royalty free three dimen sional settings for game developers to use Y ou can take elements of the three dimensional environment and modify move retexture or even remove them for use elsewhere The idea is for designers to place their own characters and objects within these ready made Scenes A hauntingly beautiful fortress The N orthern Castle is one of the first 64 GAME DEVELOPER J UNE J ULY 1995 T here s also a soup to nuts assemblage of everyday settings such as a dining room a beach and a country club lock er room On deck are W estern T own the Solar System an
70. le others can only move 32K or 64K at a time Y our drawing code will have to take into account that some cards may need Switch banks in the middle of drawin 3 won t For speed considerations switching is the only operation that you don t need to execute an interrupt to access T he VBE can give your program the address of a direct function to switch banks for the current video mode For protected mode programs VBE version 2 0 opens up a whole new set of possibilities W ith the advent of local bus architectures it became popular among video card manufacturers to sup port linear frame buffers A linear frame buffer is where a block of very high memory addresses are directly mapped into the card s video memory eliminat ing the need for bank switching entirely Some cards offer both modes of memory access others just one D evelopers should expect linear frame buffers to become the preferred method of video memory access in the years ahead Reading and Writing Video Memory Once you have gotten through VESA mode selection and memory addressing actually reading and writing image data is anticlimactic The most common memory layout for 256 color modes is identical to mode 13h The only addi Table 2 VESA VBE Functions AH 4FH AL Function Description 000h Return VBE Controller Information 01h Return VBE Mode Information 02h Set VBE Mode 03h Return current VBE Mode 04h Save Restore VBE Mode State 05h
71. lication can choose to scale back the scene complexity to match the platform metrics You can easily accomplish this by storing the results of the benchmark in a system file and making it accessible to the application M icrosoft has already announced its use of this strategy to the game developer community T his system wide performance information is very important as certain games show us For example T ie F ight er lets the player activate an options panel to change the rendering pixel complexity at run time G ouraud shad ing and other effects can be turned on or off depending on the player s choice T he game runs in a default mode that is aimed at a 486 DX2 66 W ith system level performance information stored in an easily accessible form T ie Fighter can automatically choose the appropri ate level of complexity using the bench mark results for the platform T his doesn t remove the necessity for the options panel but it does allow the application to start out in a more appropriate complexity level At run time the game software reads the benchmark information and relates it to database complexity and rendering per formance thus determining a best guess at the frames per second number which determines the game play criteri on T his idea can also be applied to other areas of the platform System level per formance data can cover CPU video CD ROM audio fax modem and other areas to provide the applicati
72. lower frame rates worth playing until can upgrade to a Pentium If the game is Wing Com mander III you bet itis NI Wayne Sikes has been a computer hardware and software engineer for the last 12 years H e has an extensive back ground in C C and assembly language programming H e also has several years experience as a computer systems intelli gence analyst where he spedalized in dedi phering and disassembling computer code while working on dassified government projects He has written game engines as well as numerous computer gaming help utilities You can reach him via email at 70733 1562 compuserve com or through G ame D eveloper GAME DEVELOPER J UNE J ULY 1995 55 Alexander Antoniades Descending to the Top mbarking on an ambitious project such as a commercial game can be a taxing experi ence and it s good to have friends to help get you through lean times For two programmers who had a dream of starting a company and writing their own three dimen sional game the journey from concept to product became a real learning experience M att T oschlog first met M ike Kulas in 1986 at SubL ogic where they were both working on Flight Simulator 2 for 68000 series processors Com modore A miga Atari ST and M acin tosh In 1988 T oschlog left SubL ogic for Looking Glass where he worked with N ed Lerner on the Car and D river computer game Kulas joined them in 1990 creating game tools for Car and D river
73. math coprocessor and 8M B RAM Useful libraries of ready made objects and textures are generally going to be on CD so it would be a good idea for even a minimalist setup to includea CD ROM drive Autodesk 3D Studio Estimates show that 3D Studio now accounts for more than half of the PC modeling and animation market which makes it a natural standard for compari son T his magazine ran a more in depth overview of 3D Studio in a previous article W hat is 3D Studio June 1994 but since that time A utodesk has come out with Release 4 and its new features make a revisit worthwhile 3D Studio runs in DOS which may seem something of an anachronism these days W hile the interface might initially come across as clunky to W in dows dependent users given the pro gram s depth it s probably much more usable than if it were icon driven Five modules make up the working area of 3D Studio The 3D Editor which allows the user to create and alter objects and to position virtual lights and cameras The 2D Shaper for creating spline polygons which then are used to build three dimensional objects or to define complex paths for animations The 3D Lofter where two dimen sional polygons are built up into objects The M aterials E ditor to create and edit surface materials T he K eyframer for animating lights cameras and action The user moves back and forth freely within these modules which are like task specific workspa
74. merator gt 0 positive case C is okay Floor Numerator Denominator Mod Numerator Denominator else Numerator is negative do the right thing Floor Numerator Denominator Mod Numerator Denominator if Mod there is a remainder Floor Mod Denominator Mod we assume it s positive k edge constructor eeeeeeoerer edge edge gradients const amp Gradients POINT3D const pVertices int Top int Bottom 1 Y plertices Top Y Height pVertices Bottom Y Y int Width plertices Bottom X pVertices Top X if Height this isn t necessary because we always start at TopY but if you want to start somewhere else you d make Y your start FloorDivMod Width Y pVertices Top Y 1 BEHIND compile two test programs one with each rasterizer and run them side by side you ll easily see the quality difference The texture mapping is jerky because we use the endpoints of the tri angle to compute the gradients and the endpoints are changing by relatively large amounts as the triangle moves because of the integer truncation Y ou also see simi lar jerkiness in a lot of game rasterizers and it s probably caused by the same thing compounded with the artifacts generated by not stepping on pixel cen ters Even in the low 320 by 200 resolu tion game world this jitter is visible sep arately from the normal aliasing In accordance with our quest to
75. n abutting edge the edge will be the left edge of one and the right edge of the other or the top and the bottom and they ll draw the same set of pixels Figure 2 A 2D Line Xoo XV except offset by a single pixel for one polygon The code to implement this was pretty straightforward in our floating point rasterizer shown in last month s listing int XStart ceil pLeft X We call the ANSI standard math h function ceil and use the integer returned for our starting x coor dinate As we step from one scanline to the next our real x value steps by the inverse slope as Equation 2 shows when you set y zy 1 W hile floating point math cer tainly is convenient when you re trying to get code up and running it s proba 20 GAME DEVELOPER J UNE J ULY 1995 bly not the best choice for a produc tion rasterizer First even though floating point coprocessors are com monplace on today s machines and are even faster than the integer processor for some operations converting from floating point to integer is still slow Because a rasterizer is where the real three dimensional coordinates get mapped to the integer hardware bitmap we end up converting a lot Also functions like ceil are actual function calls in floating point but fall out of the math almost for free with integer coordinates In addition it s hard to get the math just right for floating point num bers there s a wholefield in mathemat ic
76. ng editor to Game Developer Contact him via e mail at dsieksgarnarb harvard edu or through G ame D eveloper magazine
77. omen wasn t exactly it If you have thoughts and comments pertaining to women s games and alternative gaming strategies contact Barbara Hanscome at 73611 633 compuserve com GAME DEVELOPER JUNE JULY 1995 17 BER IND THE SCREEN Perspective Texture Mapping Part II Rasterization Figure 1 The Fill Convention 0 1 2 3 18 GAME DEVELOPER J UNE J ULY 1995 4 5 6 7 8 9 10 id say I d be doing two columns Silly me meant four or five columns Our topic perspective texture mapping is so huge dont know what was thinking when said we could cover it completely in two columns Luckily the topic has enough variety that it should keep everyone glued to these pages for the duration In Part 1 we covered most of the math behind the perspective projection and triangle gradients those neat num bers that let us interpolate without recalculating at each scanline and we quickly went over polygon fill conven tions and stepping on pixel centers T hat s a lot of information for a single article In fact there s so much material still to cover m not even going to summarize my last article beyond say ing Read it If you haven t read Part 1 you ll still get a lot out of Part I1 but you might have trouble seeing how this information fits in perspective cough This time around we re going to focus on the triangle rasterization stage and we ll expand on the math for the fill conv
78. on with complete performance information about the run time environment GAME DEVELOPER JUNE JULY 1995 39 GRAPHICS BENCHMARKS Conclusion It is very difficult today to choose a platform that runs the latest and great est three dimensional game with any certainty that the game will be playable This is a problem the PC industry must solve Game developers and large companies such as M icrosoft are working on a solution mentioned that the benchmark solution for the PC should result in run time game com plexity adjustment based on a system information accessible to the game In addition the benchmark results for platforms and graphics cards should be published and understood by users Obviously the best benchmark for a game is the actual game itself but that isn t enough Some type of stan dard benchmark criteria must exist that game developers and players can rely on for fair comparison between plat forms The current performance num bers of polygons per second usually only measure the memory subsystem performance It is possible to guess at a 40 GAME DEVELOPER J UNE J ULY 1995 frame per second number from a poly gons per second quote if the area in pixels is also mentioned Thus chip vendors must be encouraged to publish numbers that are fully qualified like 100 000 lighted clipped texture mapped 50 pixel polygons per frame at 65 536 colors per pixel on a PPC 604 processor W ith this quote a game
79. onds Chris Hecker has a lot more to say on the sub ject See page 18 of this issue and look for more in the future SOMEONE ELSE LIKES US TOO Dear Editor just wanted to say like the direction in which Game Developer is going In the April May issue you had not one not two but three great informative articles Chris Hecker s Under the Hood column the first of two parts on texture mapping Perspective Texture Mapping Part Foundations Pro gramming Digitized Sound on the Sound Blaster by Keith Weiner and Erik Lorenzen and Supercharge Your Sprites by Matt Pritchard Congratulations The only thing didn t like were Dean Ois boid s opinions of Andre LaMothe s books Tricks of the Game Programming Gurus SAMS Publishing 1994 and Teach Yourself Game Programming in 21 Days SAMS Publishing 1994 In contradiction to what the cover says think these books do suck But that is just a difference of opinion not the fault of your magazine Robert Zawarski via e mail WE GOT YOUR CODE RIGHT HERE Dear Editor normally do not offer unsolicited opinions but in this case will used to be a game developer I programmed The Last Files of Sherlock Holmes for 3DO You should have it prominently displayed somewhere in your magazine that source is available via ftp learned this from your let ters section This could be my fault might have missed it somewhere But it s a very handy piece of information
80. only one gripe about the interface and it s admittedly a niggling one T he icon buttons are small and the icons themselves rather obscure As your mouse pointer encounters each icon a brief description does appear in the status bar at the bottom of the screen H owever that means you have to keep looking back and forth from the toolbar to the status bar until you become familiar enough with the loca tion and function of each button T hat comes with time but it s a little frus trating for the novice user especially since so much else about the program is speak favorably of its speedy rendering time Robert Riter of M egabyte Indus tries M oravia N Y used trueSpace to create three dimensional animations for the Dark Force Productions title W ormhole and is using it throughout a first person action game of his own cur rently in development A former 3D Studio user his experience is that ren dering tasks that might have run overnight with that program can be completed in a fraction of the time with trueSpace H e also finds trueSpace a far better tool for character creation Indeed its modeling tools are not only powerful flexible and easy to use they re getting better trueSpace for W indows 2 0 was in beta test when wrote this with release expected for the summer of 1995 ve been working with the beta myself for the past week and have been impressed with the fluidity of the mod eling process D eformation t
81. ools have been improved over version 1 0 so that using the mouse you can easily push and pull object faces to alter form C ali gari has also added three dimensional Boolean operations which means that you can sculpt complex shapes as though with a chisel or by fusing three dimensional shapes together like lumps of clay Another coup for Caligari is the addition of real time solid rendering If you ve used a three dimensional pro gram before to create anything more than a simple geometric form you know how confusing it can get at times to work in wireframe W ith trueSpace 2 0 it is possible to work with rendered solid forms onscreen in real time T wo renderers are included 3DR from Intel and Renderware from Criterion wireframe is still also an option and remains most useful for point editing I ve found that 3DR updates the screen much more quickly than does R ender ware though the colors tend to get lurid Y ou can expect even better results if you re using one of the new graphics cards such as the M atrox Impression with built in support for these A PIs Some further improvements to enhance the program s creation of pho torealistic effects are the addition of adjustable depth of field A dobe Photo 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 t
82. or through G ame D eveloper magazine GAME DEVELOPER J UNE J ULY 1995 49 CHOPPING BLOCH Wayne Sikes There are a lot of fighter pilot games out there these days Wayne Sikes navigates through Origin s Wing Commander Ill the third release of the Wing Commander series and it med sures up impressively Wing Commander Ill n this edition of the Chopping Block review Wing Comman der III by Origin Systems Inc This technical review contains minor spoilers Wing Comman der III is the third installment in the Wing Commander series This version is far more techno logically advanced than previous W ing Commander episodes G ame features include SVGA digitized movies using well known actors at the game intro and end as well as in all cutscenes the graphic engine uses polygon based texture mapped VGA and SVGA graphics which result in impressive realistic looking spacecraft the user interface has a clean simple layout and is easy to use and the General MIDI soundtrack and digitized sound effects add a full layer of realism and excite ment to the game W ing Commander III appears to use a combination of O rigin s trademarked R ealSpace tech nology which was used in other Ori gin games such as Privateer Strike Commander and Pacific Strike mixed with advanced polygonal rou tines created specifically for W ing Commander III This Is A Big Game The combined English French and G
83. orithm for the correct divide and mod on any platform we can go back to our original goal which was to implement our fill conven tion with integer forward differences W e can use Equation 5b to manipulate Equation 4 Let n 2dx y yy 1 n nmoddy xm dy IE and 22 GAME DEVELOPER J UNE J ULY 1995 n mod dy 5 4 dy shana W e can take the floor of n dy out of the enclosing floor because it s an inte ger see E quation 3 T his is our initial state W e calcu late n from our starting y value do the flooring divide and mod with our cor rect algorithm if n is negative and use the n mod dy term s numerator as our initial error term for our forward differ ence W e don t actually do the divide t s implicit in the way the DDA func tions Since n mod dy is positive and less than dy we know that the floor of the n mod dy term is 0 and doesn t affect the initial x As y steps by 1 our floor term steps by dx dy calculated by substituting y y 1 in our original equation O ur new x call it x is cal culated from nmoddy qd Xint Xint zem W e use Equation 5b on the dx dy step to get d Xin Xint Ea T nmoddy dxmoddy dy dy 8 Equation 8 says that as y steps by 1 x steps by the floor of dx dy and our error term steps by dx mod dy N ote that mod is always positive so when our error term numerator exceeds our denominator dy we add 1 to the result
84. 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 transfers control to the interrupt handler ere C which processes e selected function VESA_Version get_VESA_version amp VESA_Info amp MajorVer amp MinorVer and returns to the program just as if a normal function call had taken place printf This video card has VBE version d d extensions Wn MajorVer MinorVer The starting place r any VE SA printf The Card Name is Fs n VESA_Info Qem_String_Ptr aware program is determining if there are VESA BIOS Extensions available to if VESA_Version Display List of Available Modes program All VBE function numbers printf nThe Following Modes are supported n have the value 4Fh in the AH register and pta WESAEIn fo Video Moder hts the actual function number in the AL reg E UNS ister The AH and AL registers make up i Cae the AX register printf n n The VBE function to return Super er 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 ae ure ee IM E E eaten nt 256 to 512 bytes but to keep older a get_ version elnTobLoc ar nro in ajorver in jinorver VESA programs from b
85. ound window and WinGRecommendDIBFormat returns the pBits for the buffer Only the Stride remains and it s easily calculated because we know the W inG buffer is actually a stan dard W indows DIB E very scanline of a DIB begins on a 4 byte boundary and since our offscreen buffers are one byte per pixel Stride is just the DWORD aligned Width Listing 4 Windows Declaration include lt wing h gt For WinG stuff Note that this is supposed to be for Win32 so there are no FAR types However it could be adapted easily for 16 bit Windows class COffscreenBuffer public Basic information access char unsigned GetBits void return pBits long GetStride void const return Stride int GetWidth void const return Width int GetHeight void const return Height Displaying the buffer void SwapBuffer void const Pixel access control these are no ops in Windows void Lock void const void Unlock void const Constructor and Destructor COffscreenBuffer void COffscreenBuffer void private Common implementation data char unsigned pBits long Stride int Height int Width Windows implementation data HDC OffscreenDC HBITMAP OffscreenBitmap HBITMAP OriginalMonoBitmap 32 GAME DEVELOPER J UNE J ULY 1995 Mign to the highest 4 byte boundary Stride Width 3 amp 3 If WinG recommends a top down DIB that s all the calculation needed to
86. ped environments animate complex action sequences or present tic tac toe at 30 frames per second T o make those graphics routines work on any plat form all you need is that magical inter face that provides these four elemental pieces of information and a way to dis play completed images on the screen Listing 1 shows the public aspects of this dream interface in a simple C declaration of a class called COffscreen Buffer All operations on the class except GetBits are declared const because they do not allow change to the buffered image or to the size of the buffer I ve added the Lock and Unlock methods which I ll explain Before digging into various imple mentations of COffscreenBuffer let s take a look at how we can use such an inter face Say have a pointer called pBuffer to a COffscreenBuffer object and want to set a single pixel to a given color index From the definition of pBits and Stride can deduce that for any point x y in the buffer such that x gt 0 and y gt 0 and x lt W idth and y H eight the memory loca tion pBits Stride y x holds the corresponding byte of offscreen memory Using this definition can con Struct a SetPixel function using the fol lowing lines of code char unsigned pPixel pBuffer GetBits pBuffer gt GetStride y x pPixel Color Of course this doesn t include any validation or clipping tests and it s also not very useful in the
87. play ers The answer is a standard bench mark that s related to the game rather than the hardware pixel memory rates But a standard benchmark implies a normalized level of understanding In this article we ll explore the technology associated with measuring game play T hree dimensional graphics are the next great graphics hurdle for PCs and console platforms For the past two decades the workstation industry has been building three dimensional graph ics engines for CAD CAM that range in cost from 20 000 up to millions of dollars Suddenly that technology is available in a PC or a game console platform W hen a new technology hits the streets the first things we hear are per formance quotes which are usually exaggerations and downright lies O pen up any gaming magazine and you can read about three dimensional graphics performance F or example a recent arti cle quoted that a certain console box could do 1 million flat shaded polygons per second and 500 000 texture mapped polygons per second W hat do these numbers really mean W hat is flat shad ing and why is it mentioned H ow do these numbers compare to the 100 000 polygons per second that a 20 000 workstation can do Is it actually true that a 300 game console is 10 times faster in three dimensional graphics then a 20 000 workstation O bviously something must be wrong Let s look at the problem by digging a little deeper into three dimensional graphic
88. r ating system T he fact that we ve got applications on W indows 95 as well does not in any way affect our investment in theM acintosh platform Wright sees Silicon Graphics remaining the superior platform for high end digital video and three dimensional animation over W indows NT just as the M acintosh held its position as the superior platform for graphic design when W in dows 3 0 was introduced M acintosh had a very strong posi tion in graphic design W indows came in and everybody thought that it was going to completely take over the market As a result companies like Aldus and Adobe developed their applications first on W in dows and second on M acintosh But they realized over time that the M ac wasn t going to go away W ethink asimi lar thing is going to hap pen in the SGI world W right said Porting Softimage Products to Windows NT U pon acquiring Softimage M icrosoft announced that it would port the compa ny s toolset to Windows NT W right indicated that Softimage products would be available on Windows NT this year but he declined to be more specific fear ing that divulging an estimated date could raise false hopes wanted to know what strengths Windows NT could offer over the SGI platform to game developers A fter all SGI has been targeting this market for years and has optimized its hardware for high end graphics and animation W right responded W e think that the W indows NT platform wil
89. r b and to get the floored value an integer The mathematically defined mod usually behaves differently in subtle ways than the mod in your program ming language of choice and because we re using the math mod in the defi nition of our fill convention we need to make sure we don t let an ill defined programming language muck up the works For example ANSI C and C H defines the mod operator to be the same as the math mod operator when both operands are positive but when either operand is negative the result is implementation dependent 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 where the numerator dx is negative W e saw how the floor function behaved with negative values so if E quation 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 floor of a negative number goes to the next lowest number so the mod term must be positive to bring it back up to the real value of a b Figure 3 shows a graph of x mod 3 H ere s Equation 5a rearranged to make that more clear a e amod p 5b Equation 5b shows a fra
90. ramming techniques are all well and good but how about an article on pro gramming mods using Sound Manager How about Getting the Most Out of CopyMask Also it would be a welcome addition if you d state the platform on which a review or article is based And please try to get Alexander Antoniades to ease up his com ments in the April May issue It s a Sim Sim Sim Sim World By Design suggested that Maxis was losing scads of money by developing on Macintoshes first Maxis s success was probably due to the fact that it did write for the Macintosh thereby avoiding the glut of games already available for the PC and distinguishing itself in a smaller market Many other superior games most notably Myst were developed on the Macin tosh and this platform should be given some consideration by your otherwise excel lent publication Geoffrey Reiss via e mail Larry O Brien responds How about the best of both worlds Macintosh and Windows Jon Blossom shows how starting on page 28 GAME DEVELOPER JUNE JULY 1995 7 IF HAD MY OWN MAGAZINE Dear Editor our magazine needs more mass to be Ys buying There are many things I d like to see in future issues Two or three long interviews per issue 8 10 pages each There are hundreds of people with much to say designers businesspeople and the like I d like to read about Carl Stone s Yoshihide Otomo s Kim Cascone s Mason Jones s and Fumio Kosakai
91. rdering Refer to Listing 2 and examine the hex code that include the mission file name look up table we discussed previously and you will notice that each mission is referenced by a unique record name and data group E ach mission record name is a text number and the data is a text file name For example mission 0014 is stored in file misnd003 T he first mission s record name is L00K0000 file name misna001 and the last mission s record name is 0066 misnp000 T he missions are generally grouped according to the space system in which they are located For example missions 0036 misn1001 through 0039 misn1004 occur in the Alcor System Even though the missions have record names giving a one up order the game engine does not play the missions in the specified order The order in which the missions are played is deter mined by how well or how poorly the player is performing For example assume you the player are doing poorly and you fail to complete mission 0039 misn1004 M ission 0039 requires that you fly down to Alcor V take out all the ground installations and rescue the sci entist who knows how to make the Tembler Bomb T his failure sends you to the Proxima System to play missions 0049 misnr001 and 0050 misnr002 M ission 0050 is the horrid mission where never ending waves of enemy Kilrathi appear the game never ends and you have lost In a different scenario if you are doing well and complete mis
92. re data that doesn t change Width CurrentPort gt portRect right CurrentPort gt portRect left Height CurrentPort gt portRect bottom CurrentPort gt portRect top Release the current PixMap HUnlock Handle CurrentPixMap COffscreenBuffer COffscreenBuffer void Free the allocated GWorld if ffscreenGWorld DisposeGWorld ffscreenGWorld void COffscreenBuffer Lock void const PixMapHandle OffscreenPixMap GetGWorldPixMap ffscreenGWorld if OffscreenPixMap t Lock the PixMap memory and pull some info off the PixMap structure LockPixels ffscreenPixMap Stride ffscreenPixMap rowBytes amp Ox3FFF pBits char unsigned GetPixBaselddr ffscreenPixMap Make sure the MMU is in true 32 bit access mode StoredMMUMode true32b SwapMMUMode amp StoredMMUMode void COffscreenBuffer Unlock void const PixMapHandle OffscreenPixMap GetGWorldPixMap ffscreenGWorld if OffscreenPixMap Unlock the PixMap memory and reset Stride and pBits UnlockPixels OffscreenPixMap Stride 0 pBits 0 Restore the previous MMU mode SwapMMUMode amp StoredMMUMode void COffscreenBuffer SwapBuffer void const Copy all bits from the offscreen GWorld to the active GrafPort Note The offscreen GWorld should be locked CopyBits amp GrafPort 0ffscreenGWorld gt portBits amp GrafPort thePort gt portBits amp ffscreenGWorld
93. re our application can touch the bits of the offscreen buffer the Lock method has to guarantee that the bits won t move during pixel access A pple Listing 2 Macintosh Declaration include lt QD0ffscreen h gt For GWorld stuff class COffscreenBuffer public Basic information access char unsigned GetBits void return pBits long GetStride void const return Stride int GetWidth void const return Width int GetHeight void const return Height Displaying the buffer void SwapBuffer void const Pixel access control void Lock void const void Unlock void const Constructor and Destructor COffscreenBuffer void COffscreenBuffer void private Common implementation data char unsigned pBits long Stride int Height int Width Macintosh implementation data GWorldPtr ffscreenGWorld char StoredMMUMode provides the GetGWorldPixMap and LockPix els functions to handle this and Get PixBaseAddr provides the magic pBits pointer when all the locking is done A pple provides the Stride value in the rowBytes field of the PixMap structure but the system tacks on the two high bits to make things difficult A simple mask of Ox3FFF pulls them off the top In addition to locking the image in memory and masking off the high bit of the scanline offset I ve heard off and on that it s also a good idea to make sure the memory management unit is in true 32 bit access mode
94. reaking 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 J UNE J ULY 19954 Listing 1 VESACHK C Continued from p 44 struct SREGS seg_regs int ver m Prepare VESA info Buffer memset VESA Info 0 512 memcpy VESA Info Vbe Signature VBE2 4 Call Int 10 VBE Function 4F 00h in_regs x ax 0x4F00 seg regs es FP_SEG VESA_Info in_regs x di FP_OFF VESA_Info int86x 0x10 amp in regs amp out regs amp seg_regs Check if VBE Extions present amp Get Revision Level if out_regs x ax 0x004F memcmp VESA_Info gt Vbe_Signature VESA 4 0 return 0 else ver VESA_Info gt Vbe_Version MajorVer ver gt gt 8 bug check Some BIOSes return 0x0102 instead of 0x0120 Check for Minor version in wrong nibble and correct m 7 ver amp OxFF if m 0 amp amp m amp Ox0F 0 MinorVer m 10 else MinorVer m gt gt 4 10 J return ver H J 2 0 specific additional information After calling the Video BIOS if the AX register has the value 004Fh in it then your BIOS has VESA extensions oth erwise it doesn t Listing 1 is a function written in Borland C 3 1 that can tell you what version of VESA extension your card supports if any and what VESA display modes it has Once you know that your video
95. rorTerm X plertices Top X 1 FloorDivMod Width Height XStep Numerator Denominator Height OneOverZ Gradients a ne verZ Top OneOverZStep XStep Gradients d ne verZdX Gradients d ne verZdY OneOverZStepExtra Gradients d ne verZdX U verZ Gradients aUQverZ Top UOverZStep XStep Gradients dU0QverZdX Gradients dUOverZdY U verZStepExtra Gradients dU verZdX VOverZ Gradients aVOverZ Top VOverZStep XStep Gradients dVOverZdX Gradients dVOverZdY VOverZStepExtra Gradients dVOverZdX eee DrauScanLine eeekeebeerdepeer void DrawScanLine BITMAPINFO const pDestInfo BYTE pDestBits gradients const amp Gradients edge pLeft edge pRight BITMAPINF const pTextureInfo BYTE pTextureBits assume dest and texture are top down assert pDestInfo bmiHeader biHeight lt 0 amp amp pTextureInfo bmiHeader biHeight lt 0 int DestWidthBytes pDestInfo bmiHeader biWidth 3 amp 3 int TextureWidthBytes pTextureInfo bmiHeader biWidth 3 amp 3 int XStart pLeft X int Width pRight gt X XStart pDestBits pLeft gt Y DestWidthBytes XStart float OneOverZ pLeft ne verZ float U verZ pLeft U verZ float VOverZ pLeft V verZ while Width gt 0 float Z 1 OneOverZ int U U verZ Z int V VOverZ Z pDestBits pTextureBits U V TextureWidthBytes ne verZ Gra
96. s as well as other 3D vendors are still selling SGI software and we re going to do whatever we can to make sure they continue to do so T hat s our business SORPTRRALL Softimage off the SGI Platform Upon acquiring Softimage last year M icrosoft stated its intention to port the Softimage tools over to Windows NT asked W right whether M icrosoft had plans to pull Softimage products off the SGI platform at a later date and focus exclusively on its own operating system implementation No One of the key reasons M icrosoft bought Softimage is that Soft image had a tremendous presence in the community that was producing the world s best content ILM Industrial Light and M agic Greenberg Rocket Science For those companies the SG I platform is absolutely critical because they need that level of performance W ethink W indows NT and the associated hard ware developments are going to provide a very price attractive alternative But in no way is that going to put SG out of busi ness T hey are going to continue to do very well and we need to be there M icrosoft looks at its partner com petitor relationship with SGI in the same light as its association with Apple W e ll continue to invest in SGI W right stated t s very similar to our situation on the M acintosh M icrosoft makes a lot of money on the M acintosh and it s a very vital platform for us at the application level even though we don t own the ope
97. s dedicated to figuring out how float ing point numbers accumulate error Finally we ll see there are some bene fits to using integer digital differential analyzers DD As when we discuss pixel centers Integers from Floor to Ceiling Before we convert our rasterizer to use integers let s learn a couple of neat tricks for manipulating the ceiling function and its companion the floor T he floor of a value is you guessed it the next lowest integer if the value has a fractional part or the value if it s already an integer Y ou could also think of this as truncating the fractional part for positive values Following are some floor examples i ales tl and E A gain notice the behavior when the value is negative W e can convert from ceiling to floor easily if a and b are integers ple m 5 owe Equation 3 also shows that we can move integers in and out of the floor or ceiling W e obviously can t move fractional values in and out though because they can affect the result Run through a few examples on your own to see why E quation 3 works Now that we have a working knowledge of floors and ceilings let s convert the rasterizer to use integer coordinates Because we are defining Xy yg and x y in Equation 1 to be integers we can manipulate the equa tion to our advantage W e can bring x outside the ceiling function for starters T his means any x generated by our fill convention will be the in
98. s electronic music recording methods e ld like a big report interviews on Ultima 9 Development the Japanese game scene Psygnosis s staff and New World s staff e I d like to know what happened to Bill Hogue Reflections and Wizardry e d like six to ten reviews and dissections of games new and old game structure archi tecture and the like I ve noticed that any thing over two years old is being thrown off the shelves or deleted Maybe you could print code architecture from these discon tinued games e I d like 30 to 40 pages of articles on port ing PC code to game systems how it s done and the troubles and costs of hard ware I d like four to five pages per issue of screen shots from upcoming games works in progress and info on CD ROM pressing and costs Add in this junk and your mag will improve greatly D Godat Fort Wayne In Editor Larry O Brien responds Okay we ll get right on that junk WELL SOMEONE LIKES US Dear Editor hanks for such a great magazine It is to have articles from people who take the theory and put it into real world practice In the April May issue really liked Matt Pritchard s article Supercharging your Sprites and Chris Hecker s column on perspective texture mapping also appreci ate the business articles that talk about the game industry itself Bruce Burkhalter Berkeley Calif 8 GAME DEVELOPER JUNE J ULY 1995 Editor Larry O Brien resp
99. s new write to the device drivers interface and showcased its recent acquisitions R ender M orphics and Softimage Lurking in the shadows other plat form vendors vied for a piece of the home entertainment pie hoping that M icrosoft might stumble in the rocky transition from DOS to Win32 Apple showed Doom and Dark Forces running native on Power M acintoshes and IBM announced an O S 2 W arp game devel oper s kit and help from Argonaut and M acromedia D ave T aylor of Id put the whole platform thing in perspective when he said the fastest version of D oom is the Linux version so maybe there are untapped opportunities after all In an industry with its share of egos and superegos the Freudian slip still crossing most developers lips remains Id T hefolks from M esquite who received a standing ovation from awestruck devel opers last year were out in force this year offering private showings of their next project Q uake to developers deemed worthy For an industry that uses D oom as benchmark Q uake becoming a hit is probably the only prediction that anyone can makefor sure Low Cost Wavetable Sound MD the fourth largest supplier of ICs in the U S was showing its new AM 78C 201 InterW ave audio processor a kick butt single chip audio system At its hospitality suite AMD demonstrated prototype sound boards with component costs as low as 40 implying a sub 100 street price running under popular games such as
100. s pro cessing and benchmarks Graphics Processing Let s define a three dimensional scene that contains objects from the real world A good example would be a room with walls a floor table chair and TV E ach object is broken down into polygons W e ve given the polygons position infor mation in terms of width height and depth which mathematicians and com puter graphics professionals usually refer to as x y and z respectively Application software must turn each polygon in each of the objects in the scene into pixels in the frame buffer for visual consumption by an observer T his process of converting objects into polygons is called tessellation The process of converting polygons into pix els is called the three dimensional graphics pipeline T he pipeline is com plex and difficult to understand without a good understanding of geometry and maybe a little physics M ost of the details aren t necessary for this discus sion but it is necessary to understand that these steps exist and they affect the overall performance measurements of a three dimensional application A sim plified version is shown in Figure 1 where the arrows show the flow of data from one stage to another T he larger the arrow the larger the amount of data flow The greatest amount of data is passed from the rasterization step to the pixels step Suppose the house in our scene is represented by 1 000 polygons W hen these polygons are displayed
101. s the word Caligari prefers in reference to its product trueSpace for W indows Rather than splitting func tions between various modules its so called natural user interface consists of one large work area Features are con tained on a single menu bar of icons with additional controls accessible via pull down menus O bjects are manipu 62 GAME DEVELOPER J UNE J ULY 1995 lated onscreen in real time All this is geared toward making trueSpace more readily understandable on an immedi ate visual level And it is Navigation around the workspace could not be more straight almost immediately comfortable W hile I m griping let me just add my hopes that in future releases C aligari pays more attention to documentation W hile trueSpace does not support networkable functions many users Some users find the trueSpace interface lends itself more readily to character creation than do other three dimensional modelers Here a fighter wielding a body ripper from a game in progress by Megabyte Industries forward You can shift your viewpoint up down and around in relation to the scene or to a selected object or along the Cartesian axes Objects lights and cameras are all manipulated in the same way You can open smaller auxiliary view windows and drag them to any location on the screen to display a camera s viewpoint or to show an almost instantaneous preview of an ani mation or rendered scene have
102. se What s in a Benchmark Traditionally benchmarks comprised small applications that measure the per 38 GAME DEVELOPER J UNE J ULY 1995 Figure 2 3D Pixels Plus Frame Buffer and Z Buffer Frame Buffer Memory formance of a machine D hrystones and W hetstones are perfect examples of this T hese benchmarks contain a vari ety of application like programs that run in a certain period of time on a par ticular platform The time it takes to execute these programs on a particular platform is measured and can be compared on a relatively fair basis to the time it takes to execute them on another platform Usually the time measured is used to compute a standard unit number T he industry as a whole looks over the pro grams in the benchmark and decides in some sense what is fair and what is not fair A similar concept exists in the cur rent PC graphics benchmark area Benchmarks execute a series of graphics instructions using a standard applica tion programmer interface API like the graphics device interface GDI in W indows T he time it takes to perform the operation is measured T he mea sured time is used to determine how many operations the platform can do per second So numbers like 40 million lines per second for a benchmark that measures line rendering using GDI are reasonable Some benchmarks execute real applications in a scripted environment resulting in a time mea
103. sed d that mode VESA Memory Addressing The whole point of using VESA Video BIOS extensions is so that you can write a program that doesn t have to know a thing about the video card in your sys tem yet can still blast data to the screen at full speed M aking a VESA VBE aware pro gram requires some extra work on the part of the programmer especially in the area of graphics memory addressing and pixel data organization T o make one or more megabytes of video memory acces sible VESA allows for one or two win dows into video memory of up to 64K to be mapped into the CPU s address practice this usually means a Jow at segment 4000 but there intee you need to look It s ssible two independent 32K win dows might exist at segments A000 and 4800 Or you might find two overlap ping 64K windows at segment 4000 one for reading data from one part of video memory and another for writing data to a different section of video memory T o access all of video memory VBE function 05h Display Window Control lets you change the position in video memory that the window accesses T his is also known as bank switching O ne thing you can count on varying from card to card is the window granularity W indow granularity is the coarseness GAME DEVELOPER JUNE J ULY 1995 45 GETTING by which the window can be positioned in video memory Some cards can let you move the window address around in 1K increments whi
104. sets and sizes of the D ata Records stored in GAME DEVELOPER JUNE JULY 1995 53 CHOPPING BLOCH the TRE file The offset and size of each Data Record is contained in an eight byte structure T he first four bytes of each structure give the offset of the D ata Record as a long value and the last four bytes contain the long size T he individual D ata R ecords follow these tables T hese D ata R ecords vary in size from just a few bytes to several thousand bytes and contain the actual game data fonts palettes space and vehicle graphics mission data game flow data artificial intelligence informa tion and so on Some of the game data is stored in IFF format which I ll cover in the next section Does the TRE file structure seem a bit confusing Although somewhat difficult to understand this file format is cleanly organized Basically the entries in the three data tables at the top of a TRE file reference or point to all the Data Records found in the TRE file In other words these tables tell the game engine where to find the desired data As an example let s trace the path the game engine follows to find a look up table containing the file names of the Wing Commander II missions T he game engine opens the GAME FLOW TRE file and reads down the list of entries in the Indirect Record Pointer T able until it finds the entry corresponding to our mission file name look up table T he engine reads the hex v
105. simple patterns using the VESA 640 by 480 256 color mode Panning and Page Flipping One of the biggest benefits of VBEs for game programs is that it makes possible page flipping and smooth high resolu tion animation VBE functions are pro vided to let the program change the logi cal width of a scan line and select the position in video memory from which the screen display starts Just like in M ode X these features Tet programs seroll the VBE Revision 12 These functions 12 are simple to use but 12 there are some catches 12 Different video cards 1 2 m 12 have different limits on 12 how small an adjust 1 ment can be made to 12 line widths and screen 2 0 start position For example a card may 2 0 only allow the start position to be on a mid D word 4 byte boundary while another might require paragraph 16 byte boundaries In true color modes the pixel size is usually 3 bytes with no unused bytes So unless the screen start position is a multiple of 4 pixels 12 he display would start in the dle ofa pixel scrambling the color data stream Fortunately page flipping can avoid this easily by starting each page on a large boundary such as 4K Smooth panning on the other hand suffers badly on some cards Palette Functions VESA VBEs also provide palette func tions T wo aspects of the palette func tions make them more desirable than the traditional method of program the VG A card directly
106. sion 0039 successfully you jump to the Freya Sys tem and begin mission 0040 misnm001 If all goes well after a few missions you will be heading to downtown Kilrah with the T embler Bomb during mission 0048 misnp003 N ote that more than one mission file can be played during a mission For example consider mission 0041 misnm002 T he misnm002 file is played during the initial space combat part of the mission Next the misnm02g file plays when the player is doing combat on the surface of a planet L astly file misnm02b plays during space combat at the end of the mission N ow that have explained IFF file formatting and how the mission file names are stored have a little home work for you T ry to find the look up table that contains the names of the space systems H int T he space systems IFF file data is in the GAME FLOW TRE file W hat is the record data that corresponds to the record name L00K0000 in the space systems look up table Undocumented Keystrokes found several undocumented key strokes that are not referenced in the game s literature T hese keystrokes only appear to be active during the flight mode when you are in the cockpit fly ing a mission The Alt V keystroke displays the game version and the file name of the current mission T he dis played file name is found in the mission file name look up table previously dis cussed The Ctrl F keystroke toggles the readout of the current frame rate
107. sitive case C is okay Floor Numerator Denominator Mod Numerator Denominator else Numerator is negative Figure 3 x mod 3 GAME DEVELOPER J UNE JULY 1995 21 do the right thing Floor Numerator Denomina tor Mod Numerator Denominator if Mod there is a remainder Floor Mod Denominator Mod Why L et s take a step back and ask ourselves as you re probably already asking your self W hy do we care People have been rasterizing polygons since shortly after the beginning of time and they never went through all this you say W ell if their polygons don t have dropouts and consistently light the cor rect pixels then they went through all this or its equivalent for another fill convention T he vast majority of rasterizers don t work properly and that s why the vast majority of games have dropouts and overwrites at abutting polygon edges W e re taking the time up front to get the math exactly right so we can implement our rasterizer with total confidence that it will light exactly the right pixels no more no less This is my personal crusade to eliminate dropouts and poor quality rasterizers everywhere and I m hoping you ll help me accomplish it The best part about doing it right is it looks bet ter and isn t any slower at run time than doing it incorrectly there s just more to understand beforehand Vive La Diff rence N ow that we ve got an alg
108. st but it doesn t produce a very good simulation of the real world G ouraud shading pro duces a much better representation of a real world object and it too is fairly fast M ost three dimensional graphics hardware can produce almost exactly the same performance with flat or G ouraud shaded polygons T exture mapping produces very realistic effects but it is much slower than flat or G ouraud shading The 3DO console and D oom use texture mapping in the case of the game the technique makes players feel like they are in a real three dimensional environment U nfortunately for various reasons texture mapping is slow and poor quality texture mapping produces a variety of nasty artifacts unacceptable to players So you can generate a three dimensional pixel using one of these techniques or any combination of them Figure 2 shows a three dimensional pixel which is the depth value and the X y location taken together T hez value is stored into a z buffer A z buffer is a large chunk of memory dedicated to saving the last z or depth value for a particular x y location in the display For every pixel in the display there is a z or depth value For a 1 280 by 1 024 display there exist 1 310 720 pixels in the frame buffer and the same number of depth values The biggest problem with a z buffer is that it increases the amount of memory on the display sub System and this cost is passed onto the consumer by a price increa
109. stantly became a key partner of SGI Eight months later last F ebruary SG merged with Alias and W avefront two companies that compete against Softim age on the SG platform H ow have these developments changed the relationship between Silicon G raphics and M icrosoft M ore importantly how does it affect their customers spoke with Andrew W right group product manager of advanced authoring tools for M icrosoft Softimage and D ave Larson director of marketing for Silicon Studios a wholly owned subsidiary of Sili con Graphics about the actions their companies have taken recently in the digi tal entertainment industry T he most recent event Silicon Graphics merger with Alias and W ave front achieved two objectives for SGI according to L arson W e felt that by merging with Alias and W avefront L arson explained we could get two of the most important groups of engineers together with our engineers and accom plish two things T he first objective is to drive the development of our 3D software environment Second we don t have expertise in entertainment and industrial software markets at the customer level like we do with hardware W e re getting a sales force that knows the customers really well at the application level a sales force that has a much greater depth of knowl edge W hat was W right s reaction to the SG merger Surprise he said From M icrosoft s perspective it act
110. styles neurophysiology and perceptual physiology By understanding these differences Hescox explained we can attempt to design entertainment based on some solid ideas rather than vague and cosmetic guesses like pink interfaces and ponies on a box The conversation quickly jumped from theories to games that are simply fun to play Utter mann who is working on a game with DeMaria that she hopes will have an internal logic that appeals to both genders summed it up nicely in saying Violence is fine in games but what else is there 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 unfold like a novel role playing games safe environments that allow the player to con quer the task at hand comfortably before moving on to the next challenge and networked play were all mentioned as games and elements that would appeal to female as well as male game players By the time we got around to how to convince the big companies in the industry to take some risks with these types of games the hospitality suites were calling our names But think we could have talked all night And also think more people in the lobby would have joined us if they could Perhaps we needed to hold up a big sign if only we had a name for just what it was we were discussing It was obvious by the end of our chat that games for w
111. surement T hese benchmarks often produce a single Z Buffer or Depth Memory magical number that can be used for comparison Benchmarks are not perfect T hey don t actually measure what a particular user is doing on a particular day Instead benchmarks use a standard selection of operations that are sup posed to represent the core activity of the average user T hus the goal of a benchmark is to reduce the potentially infinite combination of operations CPU instructions or graphics primi tives down into a subset that represents a reasonable cross section of application or user activities Presumably the rep resentation of user activity is fair across the variety of platforms available In the workstation arena the three dimensional benchmark is Graphics Performance Criteria GPC It took 10 years and hundreds of engi neers to implement this benchmark The result is a magic number that you can easily translate into frames per sec ond GPC is essentially an application environment with database traversal lighting clipping and rendering On PC platforms there exists a large num ber of G PC style applications that is games M ost of the games in the PC already output frames per second A perfect example of this is Domark s Flight Simulator T oolkit which lets the user display the performance levels whilethe game is running Current Benchmarks In terms of three dimensional graphics benc
112. teger X plus the integer result of the ceiling function for a given y N ow let s use E quation 3 to turn the ceiling function into a floor Let dx x xo and dy y Yo SO xy 0729 1 eres 4 If our initial y value is yo it s easy to see the initial value in the floor is 1 dy The floor of thisis 1 and 1 1 x Xy as we expect W e ll be doing for ward differences to step our edges so after we generate the initial value for x we re going to want to step y by 1 to the next scanline and generate the next x from our previous x value without recalculating it from scratch will assume you are already familiar with forward differences which are covered in any decent computer graphics book so l m just going to point out the inter esting parts of this algorithm Perhaps the most interesting thing about this particular equation is how the floor interacts with the forward differ ences especially when dx is less than 0 Mod Squad To thoroughly analyze E quation 4 s behavior we need another trick for manipulating floors 4 a mod b b b en Y ou re probably familiar with the modu lus operator mod from programming in C or other languages in C is the mod operator As long as two numbers a and b are positive a mod b is the integer remainder after dividing the numerator a by the denominator b E quation 5a says we take the real num ber a b and subtract its remainder ove
113. th BufferInfo Header biHeight Height Grab the color entries from the current palette HDC hdcScreen GetDC ActiveWindow if hdcScreen 1 PALETTEENTRY Palette 256 GetSystemPaletteEntries hdcScreen 0 256 Palette ReleaseDC ActiveWindow hdcScreen Convert the palette entries into RGBQUADs for the color table for int i 0 i lt 256 i BufferInfo ColorTable i rgbRed Palette i peRed BufferInfo ColorTable i rgbGreen Palette i peGreen BufferInfo ColorTable i rgbBlue Palette i peBlue BufferInfo ColorTable i rgbReserved 0 Create the offscreen DC OffscreenDC WinGCreateDC if ffscreenDC Create the offscreen bitmap OffscreenBitmap WinGCreateBitmap ffscreenDC LPBITMAPINFO amp BufferInfo void amp pBits if OffscreenBitmap 1 Adjust pBits and Stride for bottom up DIBs if BufferInfo Header biHeight gt 0 1 pBits pBits Height 1 Stride Stride Stride Prepare the WinGDC WinGBitmap OriginalMonoBitmap HBITMAP Select b ject OffscreenDC Of fscreenBitmap else Cean up in case of error DeleteDC 0ffscreenDC GAME DEVELOPER J UNE J ULY 1995 33 tion Continued on p 34 DOUBLE BUFFERED Wrapping it Up To compile the code presented in this article used M icrosoft Visual C 2 0 on W indows NT version 3 5 and Syman tec C 7 0 on M acintosh System 7 0 ran the applications created on W indows 3
114. the magazine s printing accuracy at least This is because 5 2 is on a left edge and 9 4 is on aright edge A fill con vention lets abutting polygons share an edge without either polygon overwrit ing any pixels of its neighbor or leav ing any unlit holes called dropouts between the two A top left fill convention for a left edge from x0 y0 to x1 y1 is defined mathematically by the ceiling function X Xo Xm Y Yo X a i In my last column I presented this equation without much explanation so this time we ll go into it in more detail First we can derive the equation for the line in Figure 2 by setting the slope of the entire line equal to the slope of any line segment on that line the seg ment from x y to Xg Y is on the line so its slope is equal to the line s and solv ing for x D Y _ Y Yo X X2 X Xo 2 Xp Xo yo x A Yo Xo W e can use E quation 2 to give us the x value for any y value on the line You can see that if y y then x x as you d expect and likewise for the other endpoint This equation generates real as opposed to integer values for x so we need to use our fill convention to tell us how the real x maps to an inte ger pixel This is where the ceiling function comes in T he ceiling function is defined as bumping a real value up to the next highest integer if the value has a frac tional part or leaving it alone if
115. turers rushed in provide their own solutions First c enhanced EGA cards with resoluti 10Fh GRAPHICS 110h GRAPHICS 111h GRAPHICS 112h GRAPHICS 113h GRAPHICS 114h GRAPHICS 115h GRAPHICS 116h GRAPHICS 117h GRAPHICS 118h GRAPHICS 119h GRAPHICS 11Ah GRAPHICS 11Bh GRAPHICS 320x200 16M 640x480 32K 640x480 64K 640x480 16M 800x600 32K 800x600 64K 800x600 16M 1024x768 32K 1024x768 64K 1024x768 16M 1280x1024 32K 1280x1024 64K 1280x1024 16M 32K color modes have 1 unused bit and 5 bits of Reg Green and Blue data 64K color modes have 5 bits of Red and Blue data and 6 Bits ofG reen data 16M color modes true color have 8 bits each of Red Green and Blue VGA compatible cards that took ful data advantage of analog VGA monitors which were rapidly replacing TTL digi 42 GAME DEVELOPER J UNE J ULY 1995 up to 800 by 600 pixels which wer 1 quickly swept away by a new wave NN tal monitors M anufacturers rushed to outdo each other with 256 colors at 640 by 480 then 800 by 600 and 1 024 by Makers added another chips ce jut 16 bit and 24 bit eassert itself with the ptor but it was too little too late Lacking an IBM standard to mimic each video card manufacturer was on its own when it came to implement ing high resolution modes T he result was a complete lack of consistency between video cards in mode numbers extended registers and drivers E ach manufacturer was responsible
116. ually puts us in a stronger position because we feel that for our customers a cross platform solution is important W here they want the performance of SGI we provide it where they want the price to performance ratio and openness of a Windows NT sys tem well provide that to them W e ll be the only high end 3D animation vendor that s effectively able to execute a cross platform strategy sensed no edginess from either W right or Larson about the relationship between M icrosoft and SGI and both 12 GAME DEVELOPER J UNE J ULY 1995 zoe Ss nes played up the positive aspects of their new product lines W right stressed the fact that many of SG l s partners not just M icrosoft were now competitors but that it wouldn t make sense for SG to consider them as such Y es we area competitor to Silicon G raphics but they re also a competitor to a number of their other ISVs independent software vendors C ompanies like Side E ffects D iscreet Logic Avid One thing can say absolutely outright is that if SG loses their third party applications as a result of this merger they re dead in the water think they ve almost got to overcom pensate to make sure that their third party ISVs are treated fairly W right commented D ave Larson adamantly agreed W ere going to treat M icrosoft as we do a whole category of partners who will get early access information and it s based on business parame ters T hese guy
117. ver that is placed in the AUTOEXEC BAT or CONFIG SYS that augments the card s ROM BIOS and provides the VESA VBE specific functions that reside in RAM Or a third party driver such as i ware s UniVBE program organization released the VESA BIOS i S VBE either as a Extension VBE standard version 1 2 i an be directly linked To keep up with evolving video cards and the shift to protected mode pro grams the VBE 2 0 standard was released in N ovember 1994 W ell all this history is nice to know but by now you may be asking W hat s in it for me the game software developer T he answer is simple A sin ethod for using high reso odes on most of the video re today T he rest of this ive you an overview of what extensions can give your otia how they work and how you go about coding them VESA Terms and Features For starters we need to clarify our terms VESA has developed many standards for power management sound hardware and I O bus interfaces and PC Videos BlOSes This article onl Video BIOS dav i BIOS Extensions or VBE f o A video card can T S BIOS extensions in differ S ROM BIOS physically on the video card can support the VESA VBE 1 2 or 2 0 features directly M ost new video cards do this H owever due to limited ROM VP A providing VESA VBE d a le that program is run ning In many cases especially with older video cards some ROM BlOSes and drivers have bugs or are missing features
118. with hardware panning being the biggest culprit In these cases a third party driver usually works better than the manufac turer supplied driver or ROM BIOS T he major features that VESA VBEs provide are A consistent way to identify a video card how much memory it has and what video modes and features it is capable of A consistent way to set high resolu tion super VG A video modes A consistent way to access all of the memory on a video card through a window of memory usually at seg ment A 000 A consistent way to save and restore super VGA M odes A consistent way to set logical screen Sizes and page flip Super VGA modes A consistent way to access video DAC registers including 8 Bit DACs and DACs that are not VGA compatible i J Matt Pritchard VESA was founded to create industry wide open standards for the PC environment By applying these standards develop ers have the benefit of a universal method for using high reso lution video modes GAME DEVELOPER J UNE J ULY 1995 43 GETTING STARTED WITH VESA The VESA VBE 2 0 standard Listing 1 VESACHK C Continued on p added two major features Support for fast direct access to VESA VBE function from protected mode programs Support for direct access to all video cialis Gstaad P memory in the form of a Linear nois bu Frame Buffer accessible from pro tected mode define uchar unsigned char define uint unsign
119. with the wide array of special effects available to 3D Studio users Shown a scene from The Daedelus Encounter a Mechadeus title hree dimensional design is hot and you want it but a high end workstation isn t on your shop ping list just yet W here does that leave you Well hardware improvements are making the PC a more and more viable alterna tive and PC based three dimen sional modeling rendering and animation software is cropping up everywhere to cap italize on that fact T hese products all promise the moon and the ads look swell but do they really deliver A nd how usable are they T his time around I ll give you an artist s view of three packages representing a broad range of features functionality and price 60 GAME DEVELOPER J UNE J ULY 1995 W orking 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 F ortu 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 W hile 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

Download Pdf Manuals

image

Related Search

Related Contents

Massive Top Selection Wall light 34111/17/10  Quattro™ Air Quattro™ Air for Her Quattro™ FX Quattro™ FX for Her  ー故障を自動でお知らせ機能 【ーこ~ ”ー~ ~  SxS Refrigerator Service Manual    User`s Manual - Cleerline Technology Group  Garland SR16 User's Manual  OPPO Digital BDP-80 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file