Introduction to DirectX and Direct Draw
Made By Arsalan Aslam
Webmaster of Code Master
This tutorial assumes that you are using DirectX 7
DirectX is the a set of libraries which was
developed by Microsoft for the game/graphic programmers. I will not go into further
detail of how it works or blah blah.
Now if you want to program DirectX based games in VB you must remember few
essential things.
- First you must reference the DirectX library
in your VB project.
- All the DirectX components such as Direct Draw (DDraw),
Direct 3D (D3D), etc are created from DirectX 7 object
This tutorial covers basic concept of DDraw.
DirectDraw is a software interface that provides direct access to display
devices while maintaining compatibility with the Windows graphics device
interface.
DDraw is mainly used to draw 2D graphics such as tiles, 2D sprites, etc.
- All DDraw objects are created from DirectX7
object
- It can have different number of surfaces in
which pictures are drawn
- All the surface must be defined before
creation
Usually primary surface is the main surface on
which the picture is displayed. For smoother drawing the picture is first drawn
in the back buffer, then copied to the primary surface.
Why Use DirectDraw ? (From
DirectX 7 SDK)
The DirectDraw component brings many powerful
features to you, the Windows graphics programmer:
- The hardware abstraction layer (HAL) of
DirectDraw provides a consistent interface through which to work directly
with the display hardware, getting maximum performance.
- DirectDraw assesses the video hardware's
capabilities, making use of special hardware features whenever possible. For
example, if your video card supports hardware blitting, DirectDraw delegates
blits to the video card, greatly increasing performance. Additionally,
DirectDraw provides a hardware emulation layer (HEL) to support features
when the hardware does not.
- DirectDraw exists under Windows, gaining the
advantage of 32-bit memory addressing and a flat memory model that the
operating system provides. DirectDraw presents video and system memory as
large blocks of storage, not as small segments. If you've ever used
segment:offset addressing, you will quickly begin to appreciate this
"flat" memory model.
- DirectDraw makes it easy for you to
implement page flipping with multiple back buffers in full-screen
applications. For more information, see Page Flipping and Back Buffering.
- Support for clipping in windowed or
full-screen applications.
- Support for 3-D z-buffers.
- Support for hardware-assisted overlays with
z-ordering.
- Access to image-stretching hardware.
- Simultaneous access to standard and enhanced
display-device memory areas.
- Other features include custom and dynamic
palettes, exclusive hardware access, and resolution switching.
These features combine to make it possible for
you to write applications that easily outperform standard Windows GDI-based
applications and even MS-DOS applications.
Now examine the included source
code for full details