2011-01-02 4 views
1

pcでvgasaveモードを使用している場合、device/directxアプリケーションを作成することはできますか?
これは私のinit関数である:D3Dデバイス(vgasave)

d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface 

    D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information 

    ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use 
    d3dpp.Windowed = TRUE; // program windowed, not fullscreen 
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames 
    d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D 


    // create a device class using this information and the info from the d3dpp stuct 
    d3d->CreateDevice(D3DADAPTER_DEFAULT, 
         D3DDEVTYPE_HAL, 
         hWnd, 
         D3DCREATE_SOFTWARE_VERTEXPROCESSING, 
         &d3dpp, 
         &d3ddev); 

しかし、私は未処理の違反について報告し、

d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0); 

プログラムがクラッシュした後に呼び出すとき。それとも、それはvgaについてではない、ちょうど私が何か間違っている?


CreateDeviceあなたはD3DPRESENT_PARAMETERSにあまりにもいくつかのパラメータを記入してきましたD3DERR_NOTAVAILABLE

+0

奇妙な質問です。エラーリターンは、「とにかくポインタを使用する」という意味ではありません。 –

答えて

2

返します。あなたは間違いなくバックバッファーとそのようなものの設定が間違っています。 CreateDeviceがD3DERR_NOTAVAILABLEを返した場合、d3ddevポインタはNULLになり、デバイスがないため、バックバッファをクリアしようとするとアクセス違反が発生します。

D3DDeviceParameters.Windowed = true; 
D3DDeviceParameters.BackBufferHeight = 0; 
D3DDeviceParameters.BackBufferWidth = 0; 
D3DDeviceParameters.BackBufferCount = 1; 
D3DDeviceParameters.BackBufferFormat = D3DFMT_X8R8G8B8; 
D3DDeviceParameters.MultiSampleQuality = 0; 
D3DDeviceParameters.MultiSampleType = D3DMULTISAMPLE_NONE; 
D3DDeviceParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; 
D3DDeviceParameters.hDeviceWindow = OS->GetHWND(); 
D3DDeviceParameters.EnableAutoDepthStencil = true; 
D3DDeviceParameters.AutoDepthStencilFormat = D3DFMT_D24S8; 
D3DDeviceParameters.Flags = 0; 
D3DDeviceParameters.FullScreen_RefreshRateInHz = 0; 
D3DDeviceParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Vsync. 

これは私のD3DPRESENT_PARAMETERSです。

+0

上記と同様に、まだ使用できません。 – Neomex

+1

@Neomex:次に、どのデバイスが利用可能であるかを調べる必要があります。 D3D9は非常に面倒なことがあります。たとえば、デバイスはすべてのバックバッファフォーマットをサポートする必要はありません。使用可能なデバイスを検出するには、IDirect3D9インターフェイスの他のメソッドを使用する必要があります。 – Puppy

+0

D3DDEVTYPE_REFで動作します。ありがとう! – Neomex