"DirectX 9.0 3D game Development Programming Basics" Learning Note # #

Source: Internet
Author: User

Haven't written for a long time, now make up

Bloggers Use the DirectX SDK version of June 2010, following this version as an example, recorded in the second part of Dragon book on the first chapter of the initialization of the Direct3D API.

Idirect3d9 pointer acquisition, DIRECT3DCREATE9 function prototype:

/* DLL Function for creating a Direct3D9 object. This object supports * enumeration and allows the creation of Direct3ddevice9 objects. * Pass The value of the constant d3d_sdk_version to this function, so * The run-time can validate that your Applicati On is compiled * against the right headers. */idirect3d9 * WINAPI direct3dcreate9 (UINT sdkversion);

Get Idirect3d9 Object Pointer General code:

idirect3d9* _d3d9 = Direct3dcreate9 (d3d_sdk_version);

The DIRECT3DCREATE9 function fails to return a null pointer and should be used with exception handling.

Get device Capability interface Idirect3d9::getdevicecaps, function prototypes:

STDMETHOD (GetDeviceCaps) (This_ UINT adapter,d3ddevtype devicetype,d3dcaps9* pcaps) PURE;

Note: PURE stdmethod These are Microsoft's own defined macros.

The function parameter adapter specifies which graphics card characteristics need to be obtained, which can be specified as the current video card using the macro D3dadapter_default, D3ddevtype is an enumeration variable, the hardware device (D3ddevtype_hal) is typically specified, and the software device ( D3DDEVTYPE_REF);D 3DCAPS9 is the structure of the external desired property, and when called GetDeviceCaps, the result is placed in the structure that the pointer refers to.

Create IDirect3DDevice9 Object interface Idirect3d9::createdevice, function prototype:

STDMETHOD (CreateDevice) (This_ UINT adapter,d3ddevtype devicetype,hwnd Hfocuswindow,dword BehaviorFlags,D3DPRESENT_ parameters* ppresentationparameters,idirect3ddevice9** ppreturneddeviceinterface) PURE;

One of the more important parameters is d3dpresent_parameters* ppresentationparameters, which specifies some of the properties of the Deivce object that is created.

So general Direct3D initialization includes Idirect3d9 object creation, graphics capability checking, IDirect3DDevice9 object creation, general initialization code roughly:

BOOL Initd3d (HWND hwnd) {IDIRECT3D9 * D3D = Direct3dcreate9 (d3d_sdk_version);D 3dcaps9 d3dcaps;d3d->getdevicecaps ( D3dadapter_default, D3ddevtype_hal, &d3dcaps);//Check Caps
D3dpresent_parameters d3dparam;//D3dparam Assignmentidirect3ddevice9 * D3ddevice;d3d->createdevice (D3DADAPTER_ DEFAULT, D3ddevtype_hal, HWnd, d3dcreate_hardware_vertexprocessing, &d3dparam, &d3ddevice);}

  

"DirectX 9.0 3D game Development Programming Basics" Learning Note # #

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.