D3DPRESENT_PARAMETERS parameter description

Source: Internet
Author: User
Struct D3DPRESENT_PARAMETERS {
UINT BackBufferWidth;
UINT BackBufferHeight;
D3DFORMAT BackBufferFormat;
UINT BackBufferCount;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
D3DSWAPEFFECT SwapEffect;
HWND hDeviceWindow;
BOOL implements wed;
BOOL enableautodepthstencel;
D3DFORMAT AutoDepthStencilFormat;
DWORD Flags;
UINT FullScreen_RefreshRateInHz;
UINT PresentationInterval;
};

BackBufferWidth and BackBufferHeight: the width and height of the backup buffer. In full screen mode, the two values must match the resolution supported by the video card. For example (800,600), (640,480 ).
BackBufferFormat: the format of the backup buffer. This parameter is a D3DFORMAT Enumeration type and has many types of values. For example, D3DFMT_R5G6B5 and D3DFMT_X8R8G8B8 are commonly used game backup buffer formats. This indicates that the backup buffer format is 16 bits per pixel, in fact, red (R) occupies 5 places, green (G) occupies 6 places, and blue (B) occupies 5 places. Why does green have one more place? It is said that human eyes are sensitive to green. DX9 supports only 16-bit and 32-bit backup buffer formats, but not 24-bit. If you are not familiar with the D3DFORMAT, you can set it to D3DFMT_UNKNOWN. At this time, it will use the desktop format.

BackBufferCount: the number of buffer backups, ranging from 0 to 3. If it is 0, it is treated as 1. In most cases, we only use one backup buffer. Using multiple backup buffers can make the screen smooth, but it will slow the response of the input device and consume a lot of memory.
MultiSampleType and MultiSampleQuality: The former refers to the full-screen anti-sawtooth type, and the latter refers to the full-screen anti-sawtooth quality grade. These two parameters can make your Rendering scenario look better, but consume a lot of your memory resources, and not all graphics cards support the set functions of both. Here we set them to D3DMULTISAMPLE_NONE and 0 respectively.
CheckDeviceMultiSampleType can be used to check whether the current device supports a certain anti-tooth type.
Typedef enum _ D3DMULTISAMPLE_TYPE
{
D3DMULTISAMPLE_NONE = 0,
D3DMULTISAMPLE_2_SAMPLES = 2,
D3DMULTISAMPLE_3_SAMPLES = 3,
D3DMULTISAMPLE_4_SAMPLES = 4,
D3DMULTISAMPLE_5_SAMPLES = 5,
D3DMULTISAMPLE_6_SAMPLES = 6,
D3DMULTISAMPLE_7_SAMPLES = 7,
D3DMULTISAMPLE_8_SAMPLES = 8,
D3DMULTISAMPLE_9_SAMPLES = 9,
D3DMULTISAMPLE_10_SAMPLES = 10,
D3DMULTISAMPLE_11_SAMPLES = 11,
D3DMULTISAMPLE_12_SAMPLES = 12,
D3DMULTISAMPLE_13_SAMPLES = 13,
D3DMULTISAMPLE_14_SAMPLES = 14,
D3DMULTISAMPLE_15_SAMPLES = 15,
D3DMULTISAMPLE_16_SAMPLES = 16, D3DMULTISAMPLE_FORCE_DWORD = 0x7fffffff
} D3DMULTISAMPLE_TYPE;
// Type is the above enumerated Value
D3DMULTISAMPLE_TYPE;
Int quality; // obtain the maximum quality level relative to type (when setting the type resistance value type, the set quality level can only be smaller than this number)
// M_d3dBackFmt is the backup buffer format, and m_b1_wed is the window mode,
M_pD3D9-> CheckDeviceMultiSampleType (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_d3dBackFmt, m_b1_wed, type, & quality );

SwapEffect: the type of effect supported by SwapEffect, which specifies how the surface is exchanged in the switching chain. It is of the D3DSWAPEFFECT Enumeration type and can be set to one of the following three types: D3DSWAPEFFECT_DISCARD, D3DSWAPEFFECT_FLIP, and D3DSWAPEFFECT_COPY.
If it is set to D3DSWAPEFFECT_DISCARD, after the backup buffer is copied to the screen, the backup buffer is useless and can be discarded (whether or not the discard is discarded depends on the video card, but does not wait).
If it is set to D3DSWAPEFFECT_FLIP, the backup buffer is copied to the front-end buffer to keep the backup buffer content unchanged. Used when there are more than one backup Buffer
If D3DSWAPEFFECT_COPY is set, the backup buffer is copied to the front-end buffer to keep the backup buffer content unchanged. Used when the backup buffer is equal to one
Generally, we set this parameter to D3DSWAPEFFECT_DISCARD. If you want to use GetBackBuffer to obtain the backup buffer content, print the screen. DISCARD cannot be used.
I doubt that DISCARD is efficient. On my 8600GT, _ COPY is much better than DISCARD. the discard method is to use a new buffer when the backup buffer is used again, and the old buffer content is discarded. If the old buffer is used, the new content will not be affected, for example, the anti-aliasing feature must be DISCARD. In this way, you do not have to wait for hardware synchronization. However, most of them are Present operations. Using COPY on a new machine is more efficient. After all, a new 1440*900 background buffer also consumes. (The practice of DISCARD is just speculation. Different video cards may be different .)
HDeviceWindow: display the handle of the device output window
Required wed: If it is FALSE, the full screen will be rendered. If it is TRUE, the window is to be rendered. When rendering full screen, the values of BackBufferWidth and BackBufferHeight must match the value set in the display mode.
Enableautodepthstenpencil: If you want to use the Z buffer or template buffer, set it to TRUE.
AutoDepthStencilFormat: If deep buffering is not used, this parameter is useless. If the depth buffer is enabled, this parameter sets the buffer format for the depth buffer. Common Values: D3DFMT_24S8 (24 depth buffer, 8 template buffer), D3DFMT_24X8 (24 depth buffer), D3DFMT_16 (16 depth buffer), and so on. // The pixel format of the deep cache and template cache, such as D3DFMT_D24S8. The 24-bit format indicates the depth, and the 8-bit format indicates the template cache. Generally, the 32-bit depth is not used: D3DFMT_32 // note that if you set the template buffer in the Clear () function, the template buffer should also be Clear: Set the parameter D3DCLEAR_ZBUFFER | d3dclear_stenpencil
Flags: usually 0 or D3DPRESENTFLAG_LOCKABLE_BACKBUFFER. I am not quite sure what it is used for. It seems to be a mark of whether the backup buffer can be locked. D3dpresentflag_discard_depthstencel discard template Buffer
FullScreen_RefreshRateInHz: Display update rate, in HZ. If a display does not support the update rate, you cannot create a device or issue a warning message. For convenience, set D3DPRESENT_RATE_DEFAULT.
PresentationInterval: if it is set to D3DPRENSENT_INTERVAL_DEFAULT, it indicates that you must wait for the display to finish refreshing the screen when a rendering screen is displayed. For example, if your display refresh rate is set to 80Hz, you can display up to 80 rendered images in one second. In addition, you can set to display one to four screens within the time when the screen is refreshed by the monitor. If it is set to D3DPRENSENT_INTERVAL_IMMEDIATE, the rendering screen can be displayed in real time. Although this can increase the frame rate (FPS), if the speed is too fast, the image will be torn, however, when the game is completed, the frame speed is generally not too fast.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.