advertisement

Find Code  Advanced Search   

browse free vb code
Submit Code
ASP,  HTML, and XML
Database
Dates  and Math
Files  and Directories
Forms  and Controls
Lists,  Collections, and Arrays
Miscellaneous
Multimedia/Games
Office/VBA
Network/Internet
Registry
Screen/Graphics
String  Manipulation
System/API
Windows  2000/XP
VB.NET/ASP.NET



advertisement
Introduction to Direct Draw (Tutorial)

Author: Jack Hoxley
Category: Multimedia/Games
Difficulty: Beginning

Version Compatibility:  Visual Basic 5   Visual Basic 6

This code has been viewed 91174 times.

Note: To use Direct Draw or any other component of DirectX, get the library if you haven't already. You can download it from Microsoft. You should end up with a .Zip file on your hard disk. Use a program like winzip to extract the file. Place the file (dx7vb.dll) in your windows\system\ folder, normally C:\windows\system\dx7vb.dll, then add a reference to it in your VB project.

Theory

It is important that you understand the theory behind DirectDraw before attempting to make any programs using it.


DirectDraw is the 2D component of directX, it is best used in multimedia (where intense drawing is needed) applications or platformer games. DirectDraw allows you to gain direct access to the memory on the video card, where you can compose scenes and frames, or store bitmaps. There are certain things that you should know about before I launch into things:

Term Meaning
Buffer A buffer is used to store graphical information, ie: a bitmap.
Primary Buffer Represents the screen. Anything that goes in here appears on the screen.
Blitting Blitting is the process of copying from one surface to another, similiar to the bitblt API call.
Display Mode The resolution that your program runs at. In fullscreen mode it represents the size of the screen. 640x480 is a display mode.
Colour Depth This is the number of colours that are displayed on the screen. fewer colours will take less memory, and look a lot worse. 8bit=256 colours 16bit=65536 colours 24bit=16million & 32bit=16.7million. This is set at the same time as the Display Mode.
Frames Per Second (FPS) This is the number of times the screen is being updated every second. The human eye cannot see above 33FPS, for optimal quality try to keep close to or above this speed.

˙

Every DirectDraw application follows a similiar pattern:
Create Everything
Start Loop
Blt to screen
End Loop
Destroy Everything

Surfaces
Surfaces are one of the most important things to understand. A surface is used like a picturebox control in a normal visual basic application, it holds graphical data. For example: you are making a game, you have a level, some graphics and a sprite. You can load your sprite bitmap into one surface, your level graphics into another, then compose the level onto the backbuffer; which then appears on the screen. The primary buffer and back buffer are special types of surfaces.

¸2000 Jack Hoxley -˙All rights reserved.

The material on this page may be reproduced as long as credit is˙given to myself "Jack˙Hoxley"

The author can be e-mailed at jollyjeffers@greenonions.netscapeonline.co.uk. His web site is http://members.dencity.com/dx4vb/

Sponsored Links


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers