Process and Implementation Principles.
Win32 Application -> Direct3D -> HEL -> HAL -> Graphics hardware
HAL (Hardware Abstraction Layer) hardware abstraction layer provides a simple device driver interface that can directly communicate with graphics hardware through directx.
HEL (Hardware Simulation Layer) hardware simulation layer. When a computer does not support certain features of Directx3D, HEL will simulate hardware functions through software calculations.
Directx program development does not require concern for the hardware devices used.
Basic configuration code and annotations.
The process is: IDrectx3D9 pointer acquisition -> Equipment Performance Check -> D3DPRESENT_ Parameters structure instance initialization -> IDirectDDevice9 object creation
class D3DGraphics
{
private:
IDirect3D9* pDirect3D; //D3D object
IDirect3DDevice9* pDevice; //obtain the device's functionality through the hardware device object constructor version its version has been specified
public:
D3DGraphics( HWND hWnd );
~D3DGraphics();
};
D3DGraphics::D3DGraphics( HWND hWnd )
{
pDirect3D = Direct3DCreate9( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS d3dpp; //used to specify the upcoming creation IDirect3DDevice characteristics of
ZeroMemory( &d3dpp,sizeof( d3dpp ) );
d3dpp.Windowed = TRUE; //bool display mode true representative window mode false represents full screen mode
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //the page replacement method for caching in the exchange chain, with a value of DDSWAPEFFECT one of the enumerations
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; //background cache pixel format
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; //D3DPRESENT collection members, _IMMEDIATE indicates immediate update, _Default indicating presence D3D select, usually refresh rate
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
pDirect3D->CreateDevice( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd, //by instantiating D3DPRESENT_PARAMETERS establish IDirectDDevice 9 interface objects
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,&d3dpp,&pDevice );
}
D3DGraphics::~D3DGraphics()
{
if( pDevice )
{
pDevice->Release();
pDevice = NULL;
}
if( pDirect3D )
{
pDirect3D->Release();
pDirect3D = NULL;
}
}