D3DPRESENT_PARAMETERS troubles
Hello again.
I''m trying to get a basic full screen window up and it is giving me troubles.
Here is the code I am using
BOOL DoInit()
{
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
d3ddm.Width =800;
d3ddm.Height =600;
d3ddm.RefreshRate =0;
d3ddm.Format = D3DFMT_R5G6B5;
//Clear out the structure
ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
d3dpp.Windowed = FALSE; ////////////////////////
d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
d3dpp.BackBufferFormat = d3ddm.Format; //use same mode
if((g_pD3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL)
{
AppError(FALSE, "Somethign is wrong 1");
return FALSE;
}
if(FAILED(g_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
D3DFMT_R5G6B5, D3DFMT_R5G6B5, TRUE)))
{
AppError(FALSE, "Somethign is wrong 2");
return FALSE;
}
if((g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
g_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pD3DDevice)) ==
D3DERR_INVALIDCALL)
{
AppError(FALSE, "Somethign is wrong 3");
return FALSE;
}
The problem is in my call to CreateDevice as it is error 3 which is getting called. I am getting the D3DERR_INVALIDCALL value returned as you can see from the code above.
Running Debug it points up to the line where I do
d3dpp.Windowed = FALSE; ////////////////////////
But I''m not sure.
If I take out the error checking underneath the call the window opens as runs, but it is nevertheless giving me this error. I''m pretty sure it has to be the way I''m using the d3dpp object. I am creating it as a ormal instance of the structure. But I am passing it is as a pointer (as this is how the book i am using shows to do it). Pretty sure this is a typo in the book but as none of the source code on the CD deals with full screen you can see the trouble. Tried passing the struct in as a regular parameter but that also generates errors. I''ve declared the d3dpp as a pointer
D3DPRESENT_PARAMATER *d3dpp but that also doesn''t work as the funtion then gives errors abount not being able to cast it correctly.
Thanks for any help. Sorry if the code looks funky.
Webby
P.S This code is mainly from Programming Role-Playing Games with DirectX Chapter 6 on setting up Direct X for those who have this book and would like to check it out.
Thanks
Defeatist Attitude: It simply cannot be done.
Realist Attitude: It can be done just not today.
These are the two realms of programming.
You must fill in width and height in present parameters if you''re creating a fullscreen device.
For the future, use the debug DX runtime. It will tell you what exactly in your code it doesn''t like.
For the future, use the debug DX runtime. It will tell you what exactly in your code it doesn''t like.
---visit #directxdev on afternet <- not just for directx, despite the name
Thanks:
I just simply filled in all the data to the structure and it worked.
Thought I was using the debug version though. Is there something in the code above that leads you to think otherwise?
Thanks again,
Webby
Defeatist Attitude: It simply cannot be done.
Realist Attitude: It can be done just not today.
These are the two realms of programming.
I just simply filled in all the data to the structure and it worked.
Thought I was using the debug version though. Is there something in the code above that leads you to think otherwise?
Thanks again,
Webby
Defeatist Attitude: It simply cannot be done.
Realist Attitude: It can be done just not today.
These are the two realms of programming.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement