1, what is DirectXDirectX is a Windows based multimedia application interface APIs for Microsoft. In development, DX is divided into two parts, one is the runtime, the program through DX must have runtime support, the other is the development library, which is often said SDK, which is required in the compilation of DX programs. DirectX is a graphical application interface (API) that is simply a helper software, an accelerated software that improves system performance, and is created by Microsoft. His meaning is not difficult to understand, direct is directly meaning, X is a lot of things, add together is a group of things that have common, this commonality is direct. Microsoft defines it as "hardware-device-independent".
DirectX is the graphics and media acceleration interface developed by Microsoft, only to install it, the system software can be more direct use of hardware acceleration resources (high-speed access to hardware), currently the highest version of the software 9.0c in the Windows operating system architecture, in the kernel and hardware between the layer of abstraction, The hardware is specifically shielded from abstraction, so the user is no longer allowed direct access to the hardware. By doing so, the operating system is greatly improved against disruptive and anti-jamming, but since this has compromised the efficiency of hardware operations, the new features of many new hardware are not directly available, which is clearly an obstacle to the development of multimedia and gaming. DirectX is a set of excellent application programming interfaces (APIs) provided by Microsoft to connect applications and hardware itself, which plays a key role in developing multimedia applications and computer games under the Windows platform. DirectX components include: DirectDraw, DirectSound, DirectPlay, Direct3D, DirectInput, DirectSetup, AutoPlay, and so on.
In summary, the main benefits of DirectX are two: providing software developers with hardware independence, and providing policy for hardware development. To get the latest version, you should install DirectX into your system from the latest Microsoft Platform SDK. The platform SDK can be found on the HTTP://WWW.MICROSOFT.COM/MSDN site or on the MSDN CD. By default, the Microsoft Platform SDK is installed in the \MSSDK directory under the default drive root directory. The header file for DirectX is installed in the \mssdk\include directory, and the Lib file is installed in the \mssdk\lib directory. The Platform SDK contains some very good examples of DirectX and documentation. The earlier version of the DirectX document was very sketchy and somewhat wrong, and now the release has dramatically corrected the problem. It is best to familiarize yourself with these documents. Fortunately, you don't have to deal with all the features of DirectX at once. DirectX is a set of components that you can use separately. In fact, in programming concepts, different parts of DirectX are not related to each other. They simply have the same design style and goal: making Windows game programming easier. Are there any special places for programs that use the DirectX component? Not at all. Programs that use the DirectX component are WIN32 programs that use the common Win32 API set and access to all available operating system tools. In fact, DirectX can be used both for GUI programs and for console programs. Can directly use Petzold-style SDK Programming development program, can also use basic class library, such as MFC. In general, the only requirement is that most DirectX components need an HWND in the program, so at least one window is required.2, all members of the DirectX 9 family DirectX Graphics: Integration of previous DirectDraw and Direct3D technologies. DirectDraw is mainly responsible for 2D acceleration, in order to achieve the graphics card memory and system memory direct operation; Direct3D mainly provides three-dimensional graphics hardware interface, which is the basis for the development of three-dimensional DirectX game.DirectInput: The main support input services (including mouse, keyboard, joystick, etc.), while supporting the output device.DirectPlay: Mainly provide communication and organization function of multiplayer network games.DirectSetup: mainly provides API functionality for automatically installing DirectX components.DirectMusic: Mainly support MIDI music synthesis and playback function.DirectSound: Mainly provide audio capture, playback, sound processing, hardware acceleration, direct device access and other functions.DirectShow: For the Windows platform to handle various formats of media files playback, audio and video collection, such as High-performance multimedia applications, provides a complete solution.DirectX Media Objects: A simplified model of DirectShow Filter, which provides a more convenient flow data processing scheme.3, the role of DirectXThe DirectX Software Development Kit is a programming interface for developing high-performance graphics, sound, input, output, and network games on a Windows operating platform offered by Microsoft. It provides hardware-device-independent sex.4, the origin and introduction of DirectShowDirectShow is developed from DirectX Media in DirectX6.0, which integrates technology from other members of the DirectX family (DirectDraw, DirectSound, etc.). DirectX Media objects is separated from the DirectShow of DirectX8.1 and becomes another efficient solution for streaming data processing. Microsoft DirectShow is a media streaming structure based on the Microsoft Windows platform. It supports various formats, including Advanced streaming mode (ASF), motion image Expert Group (MPEG), Audio Video interleaving (AVI), audio dynamic compression third layer (MP3), and WAV sound files. It supports capture of Windows Driven mode (WDM) devices, as well as video of early widows devices. The DirectShow incorporates other DirectX technologies. When hardware acceleration of video and audio is available, it can be automatically detected and used, while also supporting systems without hardware acceleration. The task of DirectShow media playback, format conversion, and capture becomes simple. At the same time, it provides access to the underlying flow control structure for applications that require a customized solution. You can also create your own DirectShow component to support new formatting or custom effects. Application types that use DirectShow include DVD players, video editing applications, AVI to ASF converters, MP3 players, and digital video capture applications. DirectShow is based on the Component Object Model (COM). To do a DirectShow application, you must understand COM client programming. For most applications, you do not need to implement your own COM objects. The DirectShow provides the components you need. (If you want to write your own component extension DirectShow, you must implement it as a COM object.) ) 5, the program development package selectionThe download connection on the Mirosoft DirectX home page is as follows: What's the difference: L DirectX 9.0 SDK update– (April) L DirectX 9.0 SDK update– (April-i) S Ymbol Files L DirectX 9.0c Redistributable for Software developers– (April) L DirectX 9.0c end-user Runtime ———————— —————————————————— –l DirectX 9.0 SDK update– (April 2005) – is commonly said Dxsdk L DirectX 9.0 SDK update– (April) Symbol F Iles-Symbol files for debugging L DirectX 9.0c Redistributable for Software developers– (April 2005)-Part L DirectX 9.0c end that can be released along with your program -user Runtime-Common user-installed DX6, how to link DirectX to VC. We need to compile the DirectX program must have DirectX SDK library files, this file can be obtained from Microsoft or the site, and then through the VC settings to associate it. The installation methods under VC6 and Vs.net are described below. VC6 (English): Select Menu tools->options, open Options dialog box, select Directions tab, select Include Files item, add the folder path directory of DirectX header file inside, also, Add the folder path directory for the DirectX header file in the library files item. Vs. Net (Chinese version): Select the menu "Tools-> Options", Open the Options dialog box, open the Projects tab, select "Include Files" and "library file" for the appropriate path to add. Note: VC in the compilation, will be based on the order of the library file selection, assuming that there are two of the same name of the library, VC will give priority to the use of listed in front of the library file. The DirectShow application connects at least the library files Strmiids.lib and Quartz.lib. The former defines the CLSID and IID of the Sirectshow standard, which defines the exported function amgeterrortext (if this function is not used in the application, you can not connect to the library). DirectShow applications should contain Dshow.h files, but often replace them with Streams.h files. If Streams.h is included, the generic library files are also connected to Strmbasd.lib, Uuid.lib, and Winmm.lib.7, the DirectShow development environment Configuration (1) Using the VC Wizard to generate a specific project, such as Win32 Dynamic-link (2) contains header file Streams.h, (3) in the VC menu to choose Project| settings| C + +, select the code generation in the category in the pop-up dialog box, then select _stdcall in calling convention, (4) Use the multithreaded language Run-time library, that is, select Project| in the VC menu settings| C + +, select code generation in category in the pop-up dialog box, and then in the Use Run-time Library, the debug version chooses debug multithreaded, Release version select Multithreaded. (5) Configure the necessary link library files, that is, in the VC menu to choose Project| settings| Link, select General in category in the pop-up dialog box, and enter the following code in Object/library modules: Debug version strmbasd.lib, Msvcrtd.lib, Winmm.lib Release version strmbase.lib, MSVCRT.lib, winmm.lib and select Ignore all default libraries. The DirectShow SDK recommends that DirectShow applications connect at least the library files Strmiids.lib and quartz.lib. The former defines the CLSID and IID of the DirectShow Standard, which defines the exported function amgeterrortext (if this function is not used in the application, you can not connect to the library). If the program contains the header file Streams.h, the general library file will also be connected to Strmbasd.lib, Uuid.lib, Winmm.lib. (6) Configure the Include and Lib directories of the DirectX SDK to the VC's system directory and place them before the standard VC directory to ensure that the compiler can get the latest version of the source files. Select tools| options| Directories, select Include files in the show directories for in the pop-up dialog box, configured as follows (assuming that the DirectX SDK is installed in the D:\DXSDK directory, VC is installed under C:\Program files): D:\DXSDK\Include D:\DXSdk\samples\c++\directshow\baseclasses d:\dxsdk\samples\c++\common\include C:\Program Files\Microsoft Visual Studio \vc98\include C:\Program Files\Microsoft Visual Studio\vc98\mfc\include C:\Program Files\Microsoft Visual Studio\vc98\ Atl\include then select the library files in show directories for, configured as follows: D:\DXSDK\Lib d:\dxsdk\samples\c++\directshow\baseclasses\ DEBUG d:\dxsdk\samples\c++\directshow\baseclasses\release C:\PROGRAM Files\Microsoft Sdk\lib C:\Program Files\ Microsoft Visual studio\vc98\lib C:\Program Files\Microsoft Visual Studio\vc98\mfc\lib (7) because the DirectShow application is a COM client program, Therefore, call the CoInitialize () (or CoInitializeEx) function to initialize the COM library before invoking any COM function (typically one at the time the application starts), called when the end COM library is used The CoUninitialize () function is reinitialized (typically called once before the application exits).8, VC What happens when you compile a DX program with "unresolved external symbols". This error often occurs when the novice is compiling the DirectX program, mainly because there is no reference to the DX library file to the project, we need to note that we set the DX SDK path to VC, does not mean that we have set up the DX SDK, in our DX project, We also need to set up the appropriate operation, to add the library files we need (DirectX SDK Library) to our project, there are two ways to set up this library file, one to be added in your project's compilation options, and one to add (recommended) in code. Command line: #pragma comment (lib, "Xxx.lib") This is the VC compiler preprocessing instructions, add it in the code can be. For example: #pragma comment (lib, "ddraw.lib") means that the Ddraw.lib library is added to the project for compilation. Note: This command line does not require a semicolon (";"). )。9. DirectShow SDK base Class libraryIn the DirectShow SDK base Class library, there are a number of tool classes in addition to the filter and PIN classes. With the support of these classes, it is easier to develop the filter component or DirectShow the application. These classes mainly include: Cpullpin, Coutputqueue, csourceseeking, Cenumpins, Cenummedietypes, Cmemallocator, Cmediasample, Cbasereferenceclock, Cmediatype, Cbaseproperypage and so on.10, DirectShow COM Programming Foundation DirectX uses COM standards, and DirectShow is a fully COM-based application system. The DirectShow application is actually a client of a COM component, just a "use" problem for COM components. These issues include how to create COM components, how to get the vents on component objects, how to invoke interface methods, how to manage component objects (that is, the reference counting mechanism that requires familiarity with COM), and so on. And for the filter developers, need to master a little more COM knowledge. Because filter itself is a COM component, the development of filter involves the "implementation" of COM components. COM itself is just a specification, not an implementation. But when implemented using C + +, COM components are a C + + class, and interfaces are pure virtual classes. The COM specification stipulates that any component or interface must inherit from the IUnknown interface, each component must implement a class factory (class Factory) corresponding to the branch, and the class factory is also a COM component that implements the IClassFactory interface. In the IClassFactory interface function CreateInstance, you can use the new operation to generate an instance of the COM Component class object corresponding to it. There are 3 types of COM components: in-process components, local process components, and remote components. Filter is typically an in-process component that provides services in the form of a DLL. Each COM component uses a GUID to uniquely identify it. When a COM component is created, the CoGetClassObject is always invoked first through this GUID to obtain the class factory that created the Component object. It then invokes the interface method IClassFactory::CreateInstance of the class factory to actually create the component object that the GUID identifies. A typical 5 functions required to register a COM component dll are as follows: L Dllmain:dll's entry function (DirectShow is dllentrypoint); l DllGetClassObject: Used to obtain the class factory pointer; l DllCanUnloadNow: This function is called when the system is idle to determine whether the DLL can be unloaded; DllRegisterServer: Register the COM component in the registry; DllUnregisterServer: Deletes registration information for the COM component in the registry.