DirectX Overview
DirectX itself is a set of SDK developed for the game, which itself is only used to compete with OPENGL,3DFX for a set of SDK for video game development. Microsoft has now released its version 8.1. By DirectX7, DirectX has become a full-featured multimedia development SDK. Because of its ease of use (relative to the GDI API) efficient also become a video playback, 3D graphics and other high-quality multimedia programs (high-performance multimedia applications) a good platform for development. Because of Microsoft's dominance in the software industry, DirectX has been widely supported by many graphics vendors. In other words, using DirectX to program the brand and model of the video card completely without having to deal with DirectX, and the rest is resolved by DirectX and Windows Exchange.
The DirectDraw for DirectX is used for 2D drawings, and DirectDraw is more secure than the Windows API, and there are some practical ways to transform and modify graphics. DirectInput provides a way to manage input devices, where all joystick can be treated in a manner that greatly simplifies the use of joystick. DirectMusic and DirectSound not to mention that we can also think of music and harmony effect of control, although many games now use MP3 play background music, but DirectMusic convenient and powerful or worth watching. As for the Direct3D and DirectPlay is used for 3D drawing and networking games, although the game is booming, but because the D3D is more complex, only left D3D and Dplay later specifically introduced. Because DirectX itself is a set of low-level (low-level) program interfaces, which means that it is a set of APIs, DirectX programming requires a large number of pointers for direct manipulation of the system's video memory and system memory in exchange for faster execution efficiency. So at first DirectX made it only for C + +. From the beginning of DirectX7, DirectX has VB runtime, those complex pointer operations are all converted into ordinary variable operation, which is why the use of C # to develop DirectX program reasons.
Since I got the DirectX8.1 SDK today, the programs here are developed using the DIRCTX7VB runtime. DirectX has a complex structure, a lot of functions, and it's not as clear as database development, so I'm simply introducing its basic features here. But there's no need to be afraid. The basic methods of using the many functional interfaces below DirectX are the same, and the necessary steps to achieve basic functionality are as follows:
1. Create Interface directx7.directxxxcreate ();(XXX on behalf of Input&music&draw ...)
such as: Ddraw=dx. Directdrawcreate ("");
2. Environment setting
Such as:
ddraw.SetCooperativeLevel(frm.Handle.ToInt32(),
DxVBLib.CONST_DDSCLFLAGS.DDSCL_FULLSCREEN|
DxVBLib.CONST_DDSCLFLAGS.DDSCL_ALLOWMODEX|
DxVBLib.CONST_DDSCLFLAGS.DDSCL_EXCLUSIVE);
Environment settings sometimes require enumerations (enumerate) to get the correct settings available.
3. Create an Action entity
such as: Ddsurface=ddraw. Createsurface (ref DDDESC);
4. Operations on Entities
such as: Ddsurfacespt.setcolorkey (dxvblib.const_ddckeyflags. Ddckey_srcblt,ref Ddcolorkey);
With these 4 steps, you will basically understand the idea of DirectX programming, the following needs is to find the specific steps to achieve the solution. Let's start with DDraw and do a role that can be moved on the background (spriter) first. And then let him make a sound when he walks (Dsound), finally with the background music (dmusic), such a game of the basic elements are almost complete, the rest should let him do something, it depends on your likeness force, before the imagination, or write code!
Building a project requires a form (form), reference Direct7, do not want to cite DirectX8 instead of directx7,directx8 DirectDraw I do not know why not, may be in the D3D surface can also draw 2D reasons! Then we can get rid of the extra references and leave system.,system.windows.forms and Dxvblib (it's the protagonist OH). DirectX is a drawing, so ... System.Drawing is useless, but still leave the System.Drawing, after access to the form location, or use it.
Then define the DirectX7 interface
Private dxvblib.directx7 dx=new dxvblib.directx7 ();
All right, the preparations have been completed, the following is officially started DirectDraw part;