DirectX5.0 Latest Game Programming Guide DirectDraw 2, DirectDraw system

zhaozj2021-02-11  246

Second, DirectDraw system multimedia software requires high performance image. Through DirectDraw, Microsoft makes the procedures for image sensitivity are greatly improved in speed and efficiency, while maintaining device-independence, DirectDRAW provides tools to complete the following key tasks:. Operate more Display surface. Access video memory directly. Page flip. Background buffer. Management of palette. Cutting additionally, DirectDraw allows you to query the display hardware's performance and then provide the optimal performance that the display device can support. DirectDraw provides a COM-based service interface that uses the most iDirectDraw2, IDirectdrawSurface3, iDirectdrawPalette, IDirectDrawClipper, and IDirectDrawVideoport. In addition to these interfaces, DirectDraw continues to support previous versions of interfaces. The DirectDRAW object is characterized to display the adapter, reveal its method through the iDirectdraw and the iDirectDraw2 interface. In most cases, you can use the DirectDrawCreate function to create a DirectDRAW object, or you can use COM functions CocreateInstance. Once you have created a DirectDraw object, you can call the IDirectDraw2 :: createSurface method to create a surface for that object. The surface characterizes the memory on the hardware, or both video memory, or system memory. DirectDraw expands support for palette, shear, and video ports through other interfaces.

1. DirectDraw object type DirectDRAW object can be a separate object or a combination of several objects. The latest version of DirectDraw has the following types of objects: 1.1, DirectDraw object DirectDraw object is the core of the DirectDraw application, which is the first object you created. Once you have created a DirectDraw object, you can create all other relevant objects on it based on it. Creating a DirectDraw object is DirectDrawCreate. 1.2, the DirectDrawSurface object DirectDrawSurface object characterizes a memory area, and the data of the area will be displayed on the screen or moved to other surfaces as an image. Creating a DirectDrawSurface object is iDirectdraw2 :: createSurface, other related methods can be obtained by interface IDirectdrawSurface, IDirectdrawSurface2, and IDirectDrawSurface3. 1.3, the DirectDrawPalette object DirectDrawPalette object (sometimes "Palette") characterizes a 16-color or 256 colored index palette for the surface, which contains a series of RGB color index values ​​that describe the same surface. The method for creating a DirectDrawPalette object is iDirectdraw2 :: CreatePalette. Other methods can be obtained from the interface IDirectDrawPalette. 1.4, DirectDrawClipper object DirectDrawClipper object (sometimes "clipper") Help you write data from a location or exceeding the surface, creating DirectDraw2 :: CreateClipper, other related methods can be from interface IdirectDrawClipper is obtained. 1.5, DirectDrawVideoPort Object DirectDrawVideoPort object characterizes only video port hardware with only one system, which allows the frame buffer to access the frame buffer without having to access the CPU or use the PCI bus. You can first specify the IDDVIDEOPORTCONTAINER flag, then call the QueryInterface method to create a DirectDrawVideoPort object. Other related methods can be obtained from interface IDDVideoPortContainer and IDirectDrawVideoport. 2, hardware abstraction layer HAL (Hardware Abstract Layer) DirectDRAW provides devices independent by hardware abstraction layer HAL. HAL is a special equipment interface and is provided by equipment manufacturers. DirectDRAW operates directly on the display device with HAL. Applications and different HAL interactions. Equipment manufacturers provide HAL in the form of 16 or 32-bit code under Windows95. Under WindowsNT, HAL is 32-bit code. HAL can be part of the display driver, or a dynamic link DLL that displays the driver communication with the private interface defined by the manufacturer. DirectDraw HAL is provided by a chip, a board or OEM (Original Equipment Manufacture). HAL only provides device-related code, not simulated when executed. If a function is not supported by hardware, HAL will not treat this function as part of hardware performance. In addition, HAL does not confirm the parameters, and DirectDRAW will work in the call to complete the parameters prior to calling HAL.

3. Software Emulation When the hardware Hal does not support a certain feature, DirectDRAW tries to simulate this feature. The simulation function is provided by the hardware emulation layer HEL (Hardware-emulation waiting. Obviously, software simulation is not equivalent to the characteristics of hardware itself. You can use the iDirectdraw2 :: getCaps method to query the features supported by the hardware. Sometimes, the inherent characteristics of hardware and the combination of both software simulation are slower than the software simulation alone. For example, if the display device driver supports DirectDraw but does not support the pull-out block write, it will generate loss of performance when stretched from the video memory surface or bit block transmission. Because video memory is usually slower than the speed of the system memory, the CPU must wait. Therefore, if your application uses hardware unable to provide features, it is best to create a surface in system memory to avoid performance losses that occur when the CPU accesses the video memory. 4. System Integration The following figure shows the relationship between DirectDraw, graphics device interface GDI, hardware abstraction layer HAL, hardware simulation layer HEL, and hardware. As shown in the figure, a DirectDRAW object is a parallel relationship with GDI, both through the device-related abstract layer access hardware. Different from GDI, DirectDRAW will make full use of unique features provided by hardware. If the hardware does not support a feature, DirectDraw will try to simulate it with HEL. DirectDraw can also provide surface memory in the form of device context, which can use GDI functions to handle surface objects.

转载请注明原文地址:https://www.9cbs.com/read-4920.html

New Post(0)