関数 | 解説 |
---|---|
CDeviceInformation | コンストラクタ |
~CDeviceInformation | デコンストラクタ |
getAdapters | 全ての情報の取り出し |
getCurrentAdapter | 使用が推奨されるビデオボードをあらわす番号 |
getNumAdapters | 使用可能なビデオボードの枚数を返す |
lpd3d | 有効なLPDIRECT3D8 型ポインタ |
useD | Zバッファが必要か?true: 必要 false: 不要 |
minD | Zバッファに要求するbit幅。大きい程精度が高い。 |
minS | ステンシルバッファに要求するbit幅。不要なら0を渡す。 |
cb | モード確認用コールバック。不要ならNULLを渡す。 |
caps | D3DCAPS型のポインタ、判断に必要な情報が格納されている。 |
behavior | デバイスの動作に関する以下のフラグのうち一つ以上の組み合わせ D3DCREATE_HARDWARE_VERTEXPROCESSING D3DCREATE_MIXED_VERTEXPROCESSING D3DCREATE_PUREDEVICE D3DCREATE_SOFTWARE_VERTEXPROCESSING |
fmt | フレームバッファのフォーマット。 |
S_OK | このデバイスでOKである。 |
E_FAIL | このデバイスは使用できない。 |
struct D3DAdapterInfo { D3DADAPTER_IDENTIFIER8 d3dAdapterIdentifier; D3DDISPLAYMODE d3ddmDesktop; DWORD dwNumDevices; D3DDeviceInfo *devices; DWORD dwCurrentDevice; };
メンバ名 | データ型 | 説明 |
---|---|---|
d3dAdapterIdentifier | D3DADAPTER_IDENTIFIER8 | ビデオボードに関するシステム情報(DirectX SDK のドキュメント参照のこと) |
d3ddmDesktop | D3DDISPLAYMODE | アプリケーション起動時点でのグラフィックモード |
dwNumDevices | DWORD | デバイス数 |
devices | D3DDeviceInfo | デバイス情報配列 |
dwCurrentDevice | DWORD | 推奨デバイス番号 |
struct D3DDeviceInfo { D3DDEVTYPE DeviceType; // Reference, HAL, etc. D3DCAPS8 d3dCaps; // Capabilities of this device DWORD dwNumModes; BOOL bCanDoWindowed; // Whether this device can work in windowed mode D3DModeInfo *modes; DWORD dwCurrentMode; BOOL bWindowed; D3DMULTISAMPLE_TYPE MultiSampleType; };
メンバ名 | データ型 | 説明 |
---|---|---|
DeviceType | D3DDEVTYPE | 描画デバイスの種類(D3DDEVTYPE_HAL/D3DDEVTYPE_REF) |
d3dCaps | D3DCAPS8 | このデバイスの能力をあらわすシステム情報(DirectX8 SDK 参照) |
bCanDoWindowed | BOOL | ウインドウにレンダリング可能か。true:可能 false:フルスクリーンのみ |
dwNumModes | DWORD | 使用可能なモード数 |
modes | D3DModeInfo | モード情報 |
dwCurrentMode | DWORD | 推奨モード番号 |
bWindowed | BOOL | 現在の動作モード。true:ウインドウモード false:フルスクリーンモード |
MultiSampleType | D3DMULTISAMPLE_TYPE | 現在常に D3DMULTISAMPLE_NONE |
struct D3DModeInfo { DWORD Width; // Screen width in this mode DWORD Height; // Screen height in this mode D3DFORMAT Format; // Pixel format in this mode DWORD dwBehavior; // Hardware / Software / Mixed vertex processing D3DFORMAT DepthStencilFormat; // Which depth/stencil format to use with this mode };
メンバ名 | データ型 | 説明 |
---|---|---|
Width | DWORD | スクリーンのX方向解像度 |
Height | DWORD | スクリーンのY方向解像度 |
Format | D3DFORMAT | ピクセルフォーマット(詳細は、DirectX3 SDK を参照のこと) |
dwBehavior | DWORD | 頂点処理の種類。以下のフラグのうち一つ以上の組み合わせ D3DCREATE_HARDWARE_VERTEXPROCESSING D3DCREATE_MIXED_VERTEXPROCESSING D3DCREATE_PUREDEVICE D3DCREATE_SOFTWARE_VERTEXPROCESSING |
DepthStencilFormat | D3DFORMAT | Zバッファ・ステンシルバッファフォーマット |
#define kUseDepthBuffer true LPDIRECT3D8 pD3D; LPDIRECT3DDEVICE8 pD3DDEV; CDeviceInformation* pDevices; D3DAdapterInfo* pAdapters; D3DAdapterInfo* pAdapterInfo; D3DDeviceInfo* pDeviceInfo; D3DModeInfo* pModeInfo; DWORD dwAdapter; D3DPRESENT_PARAMETERS d3dprm; pD3D = Direct3DCreate8(D3D_SDK_VERSION); pDevices = new CDeviceInformation(pD3D,kUseDepthBuffer,16,0,NULL); pAdapters = pDevices->getAdapters(); dwAdapter = pDevices->getCurrentAdapter(); pAdapterInfo = &pAdapters[dwAdapter]; pDeviceInfo = &pAdapterInfo->devices[pAdapterInfo->dwCurrentDevice]; pModeInfo = &pDeviceInfo->modes[pDeviceInfo->dwCurrentMode]; ZeroMemory( &d3dprm, sizeof(d3dprm) ); d3dprm.Windowed = pDeviceInfo->bWindowed; d3dprm.BackBufferCount = 1; d3dprm.MultiSampleType = pDeviceInfo->MultiSampleType; d3dprm.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dprm.EnableAutoDepthStencil = kUseDepthBuffer; d3dprm.AutoDepthStencilFormat = pModeInfo->DepthStencilFormat; d3dprm.hDeviceWindow = hWnd; /* アプリケーションのHWND が必要 */ if( d3dprm.Windowed ) { RECT rc; GetClientRect(hWnd, &rc); d3dprm.BackBufferWidth = rc.right - rc.left; d3dprm.BackBufferHeight = rc.bottom - rc.top; d3dprm.BackBufferFormat = pAdapterInfo->d3ddmDesktop.Format; }else{ d3dprm.BackBufferWidth = pModeInfo->Width; d3dprm.BackBufferHeight = pModeInfo->Height; d3dprm.BackBufferFormat = pModeInfo->Format; } pD3D->CreateDevice( dwAdapter, pDeviceInfo->DeviceType, hWnd, pModeInfo->dwBehavior, &d3dprm, &pD3DDEV );