[DirectX] The meaning of the parameters of the basic graphics drawing function in D3D (summary)

1. Let me briefly explain the role of the function and the meaning of the formal parameters. In fact, these functions are all available in the C++ documentation of DierctX. In fact, you can understand it through the documentation. Of course, the default document is in English. If you feel complicated, it is recommended to try to read the document through a translation software. The documentation can tell us a lot.

IDirect3D* WINAPI Direct3DCreate9(
 UINT SDKVersion         //版本号
);                              //创建Direct3D9接口对象

Parameters: D3D_SDK_VERSION The parameter is the SDK version number of D3D.
Return value type: If successful, this function returns a pointer to the IDirect3D9 interface; otherwise, it returns a null pointer.

HRESULT IDirect3D::GetDeviceCaps(
 UINT Adapter,           //显卡号(一般为D3DADAPTER_DEFAULT)
 D3DDEVTYPE DeviceType,  //设备类型(一般为D3DDEVTYPE_HAL)
 D3DCAPS9* pCaps         //返回设备功能信息
);                              //本机显示卡功能检测

Parameters: Adapter: Display the serial number of the adapter. D3DADAPTER_DEFAULT is always the main display adapter
parameter: DeviceType: Device type
parameter: pCaps: Pointer to a D3DCAPS9 structure, used to fill in information describing the capabilities of the device.

HRESULT IDirect3D::GetAdapterDisplayMode(
 UINT Adapter,           //显卡号
 D3DDISPLAYMODE* pMode   //显示模式
);                              //获得显卡的显示模式

Parameters: Adapter: Display the serial number of the adapter. D3DADAPTER_DEFAULT is always the main display adapter
parameter: pMode: pointer to the D3DDISPLAYMODE structure, used to fill in the information describing the current adapter mode.
Return value type:
If the method succeeds, the return value is D3D_OK.
If the adapter is out of range or pMode is invalid, this method returns D3DERR_INVALIDCALL.

typedef struct _D3DDISPLAYMODE{
    
    
 UINT Width;             //屏幕像素宽度
 UINT Height;            //屏幕像素高度
 UINT RefreshRate;       //刷新率
 D3DFORMAT Format;       //显卡使用的各种绘图表面格式
}D3DDISPLAYMODE;                //显示模式结构体
typedef struct _D3DPRESENT_PARAMETERS_ {
    
    
 UINT BackBufferWidth,BackBufferHeight;         //后绘图表面的像素宽高
 D3DFORMAT BackBufferFormat;                    //后绘图表面的各种数据格式(如像素颜色格式)
 UINT BackBufferCount;                          //后绘图表面的数目
 D3DMULTISAMPLE_TYPE MultiSampleType;           //多重采样类型
 DWORD MultiSampleQuality;                      //多重采样品质
 D3DSWAPEFFECT SwapEffect;                      //前后绘图表面的交换方式
 HWND hDeviceWindow;                            //所在的窗口句柄
 BOOL Windowed;                                 //true表示使用窗口;false表示使用全屏
 BOOL EnableAutoDepthStencil;                   //使能自动深度蒙板
 D3DFORMAT AutoDepthStencilFormat;              //自动深度蒙版格式
 DWORD Flags;                                   //后绘图表面可否锁定等标志
 UINT FullScreen_RefreshRateInHz;               //屏幕刷新率(如果使用窗口,则必须设置为0)
 UINT PresentationInterval;                     //前、后绘图表面的最大交换频率
} D3DPRESENT_PARAMETERS;                               //设备显示属性结构体
HRESULT IDirect3D::CreateDevice(
 UINT Adapter,                        //显示卡编号
 D3DDEVTYPE DeviceType,               //设备类型
 HWND hFocusWindow,                   //所属窗口句柄
 DWORD BehaviorFlags,                 //设备行为标志
 D3DPRESENT_PARAMETERS* pPresentationParameters,    //显示属性参数
 IDirect3DDevice9** ppReturnedDeviceInterface       //返回的设备接口指针
);                                           //创建渲染设备

Parameters: Adapter: Display the serial number of the adapter. D3DADAPTER_DEFAULT is always the main display adapter
parameter: DeviceType: device type, D3DDEVTYPE member
parameter indicating the enumeration type of the required device type : hFocusWindow: window handle
parameter: BehaviorFlags: device behavior flag
parameter: pPresentationParameters: display attribute parameter
parameter: ppReturnedDeviceInterface: The returned device interface pointer
**Return value type:
If the method succeeds, the return value is D3D_OK.
If the method fails, the return value can be one of the following values:
**
Insert picture description here


HRESULT IDirect3DDevice9::CreateVertexBuffer(
 UINT Length,             //顶点缓冲区的大小
 DWORD Usage,             //顶点缓冲区的用法
 DWORD FVF,               //可变的顶点格式
 D3DPOOL Pool,            //顶点缓冲区所使用的内存池类型
 IDirect3DVertexBuffer9** ppVertexBuffer,   //顶点缓冲区的指针
 HANDLE* pSharedHandle    //保留字,设置为NULL
);                               //创建顶点缓冲区
HRESULT IDirect3DVertexBuffer9::Lock(
 UINT OffsetToLock,       //锁定的起始字节位置
 UINT SizeToLock,         //锁定字节的大小
 VOID** ppbData,          //返回的顶点缓冲区指针
 DWORD Flags              //锁定标志
);                               //内存锁定,返回顶点缓冲区指针
HRESULT IDirect3DDevice9::Clear(
 DWORD Count,               //要清除的绘图表面的矩形区域个数
 const D3DRECT* pRects,     //所清除的绘图表面的区域
 DWORD Flags,               //清除标志
 D3DCOLOR Color,            //清除后的新颜色值
 float Z,                   //所清除的Z-Buffer缓冲区的新Z值(0--1之间)
 DWORD Stencil              //所清除的Stencil缓冲区的新值
);                                 //清除设备缓冲区数据
HRESULT IDirect3DDevice9::BeginScene(VOID);          //启动设备管道流水线
HRESULT IDirect3DDevice9::EndScene(VOID);            //停止设备管道流水线
                                                     //以上两个函数必须成对出现,且3D场景渲染代码必须放到他们中间
HRESULT IDirect3DDevice9::SetStreamSource(
 UINT StreamNumber,        //管道流水线编号
 IDirect3DVertexBuffer9* pStreamData,    //顶点缓冲区指针
 UINT OffsetInBytes,       //缓冲区数据的偏移字节位置
 UINT Stride               //顶点带宽,一般为顶点结构体的字节大小
);                                //顶点缓冲区数据装入管道流水线
HRESULT IDirect3DDevice9::SetFVF(
 DWORD FVF                 //可变顶点格式
);                                //设置顶点格式
HRESULT IDirect3DDevice9::DrawPrimitive(
 D3DPRIMITIVETYPE PrimitiveType,   //所采用的3D原始类型
 UINT StartVertex,                 //起始顶点的索引
 UINT PrimitiveCount               //绘制图元个数
);                                        //绘制基本图元(三角形)
HRESULT IDirect3DDevice9::Present(
 CONST RECT* pSourceRect,          //一般说明为NULL
 CONST RECT* pDestRect,            //一般说明为NULL
 HWND hDestWindowOverride,         //一般说明为NULL
 CONST RGNDATA* pDirtyRegion       //一般说明为NULL
);                                        //交换前后绘图表面

Two, DirectX will provide default C++ reading documents.

as the picture shows:

Insert picture description here
Insert picture description here

All the function prototypes in DX are there, and the document explains the functions. If you feel that the English is not good, you can use the next translation software. The translation software can translate the content you selected to help understand. When reading documents, bloggers usually use translation software, as shown in the figure. The following is a simple and useful document view function for bloggers and a legend of the function explanation.

Example picture 1:Insert picture description here
Example picture 2:

Open the translation software:Insert picture description here

Insert picture description here
: : ProMer_Wang

Link: https://blog.csdn.net/qq_43801020/article/details/106959597

This article is the original article of ProMer_Wang, the copyright belongs to the author, please indicate the source of the original text for reprinting, welcome to reprint!

Guess you like

Origin blog.csdn.net/qq_43801020/article/details/106959597