Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesQuenching a Thirst for Sprites


July 1996 / Reviews / Forging a New Medium / Quenching a Thirst for Sprites

With Windows 3.1, the Graphical Device Interface (GDI) could not produce smooth, interactive sprites. You built images in the GDI and blted ("blitted") them from conventional memory to display memory, but this process could not support complex sprites. Enter DirectDraw, the graphical architecture of Windows 95 that lets developers bypass the GDI and access video hardware through a hardware abstraction layer (HAL). You first create a DirectDraw object for your application (using the DirectDrawCreate API) and then configure a primary and secondary surface of video memory with the CreateSurfa ce method. You also need to build your palette with the CreatePalette call, but since DirectDraw can, in effect, take over the Windows environment, you don't have to share the 256 palette colors with other applications. You apply the full palette to the primary video surface and forget about it.

Developers must create a series of bit-mapped sprites to match the different poses of a character. To create a sprite, you reserve the video surface for it, specify the palette entry that represents your transparent color, then fill in the bits to draw your character.

DirectDraw performs warp-speed blts by working entirely in video memory. While your program is displaying one frame of graphics, the next frame is being rendered on the secondary surface. The secondary surface is then flipped onto the primary surface. The blts are occurring from video RAM to video RAM, bypassing the CPU and conventional memory. For even faster performance you can use the BltFast method, but you give up some features such as automatic clipping. Your sprites will now run and jump and mutilate legions of m utant space demons. Ah, sweet justice.


How Direct Draw Draws

illustration_link (22 Kbytes)

DirectDraw speeds blts by working in video memory. After an image is rendered in the secondary DirectDraw surface, it is "flipped" onto the primary surface and onto the screen.


Up to the Reviews section contentsGo to previous article: Quenching a Thirst for SpritesSearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network