Trying to get D3DDEVTYPE_REF going, backbufferformat error
I can run a bunch directX samples on my laptop. It gives me that little warning about using REF in the upper left corner. So I've been trying to create a d3d device with D3DDEVTYPE_REF. But I keep getting "Invalid value for BackBufferFormat. ValidatePresentParameters fails". Heres the code. Thanks for any help.
HWND hwnd = AfxGetMainWnd()->GetSafeHwnd();
if( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
AfxMessageBox("fail1");
D3DDISPLAYMODE d3ddm;
if(FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
AfxMessageBox("fail2");
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;//D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.hDeviceWindow = hwnd;
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice ) ) )
AfxMessageBox("CreateDevice error");
whats your adaptor display format set to at the moment? Does it work if you change
d3dpp.BackBufferFormat = d3ddm.Format;//D3DFMT_UNKNOWN;
to
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
Is there any reason why you need to use the same back buffer format as your current display mode?
Sorry if i have misunderstood. hope this helps
EDIT:
sorry just noticed you havent set the back buffer resolution:
d3dpp.BackBufferWidth = 800;
d3dpp.BackBufferHeight = 600;
d3dpp.BackBufferFormat = d3ddm.Format;//D3DFMT_UNKNOWN;
to
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
Is there any reason why you need to use the same back buffer format as your current display mode?
Sorry if i have misunderstood. hope this helps
EDIT:
sorry just noticed you havent set the back buffer resolution:
d3dpp.BackBufferWidth = 800;
d3dpp.BackBufferHeight = 600;
I changed d3dpp.BackBufferFormat to
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
And added backbuffer Height & Width
The part where it is failing is:
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice ) ) )
AfxMessageBox("CreateDevice error");
The error message box pops up and output window shows:
Loaded 'C:\...d3dref.dll', No symbold loaded
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
And added backbuffer Height & Width
The part where it is failing is:
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice ) ) )
AfxMessageBox("CreateDevice error");
The error message box pops up and output window shows:
Loaded 'C:\...d3dref.dll', No symbold loaded
What's the value of d3ddm.Format after the GetAdapterDisplayMode() call? And what happens if you use a format of D3DFMT_UNKNOWN? That's valid for windowed mode.
jrmcv: In windowed mode, the backbuffer format has to match the display adater format.
Everything else looks correct to me (Apart from the width and height as jrmcv said). Does that code work with the HAL device, or do neither work?
jrmcv: In windowed mode, the backbuffer format has to match the display adater format.
Everything else looks correct to me (Apart from the width and height as jrmcv said). Does that code work with the HAL device, or do neither work?
d3ddm.Format = D3DFMT_R8G8B8
If I use D3DFMT_UNKNOWN then I'll get "Invalid value for BackBufferFormat. ValidatePresentParameters fails" error.
If I try _HAL, i get same BackBufferFormat error.
Height and Width same as current display.
I've been going thru DirectX samples code since they work. But the beginner ones I've look at seems waaay out.
If I use D3DFMT_UNKNOWN then I'll get "Invalid value for BackBufferFormat. ValidatePresentParameters fails" error.
If I try _HAL, i get same BackBufferFormat error.
Height and Width same as current display.
I've been going thru DirectX samples code since they work. But the beginner ones I've look at seems waaay out.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement