Jump to content
  • Advertisement
Sign in to follow this  
TheUmpteenth

DirextX Initialisation Problem

This topic is 4146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, Firstly, Hi, I'm new here. I'm not a C++ noob, or a DirectX noob, but I'm having a noob problem :) the problem is that if I set the D3DPRESENT_PARAMETERS' Windowed flag to FALSE, CreateDevice() fails. I can't see why. I'm not too great at posting on a forum, so here's the code as best as i can manage... D3DPRESENT_PARAMETERS dx_PresParams; ZeroMemory( &dx_PresParams, sizeof(dx_PresParams) ); dx_PresParams.Windowed = FALSE; dx_PresParams.FullScreen_RefreshRateInHz= D3DPRESENT_RATE_DEFAULT; dx_PresParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; dx_PresParams.BackBufferCount = 1; dx_PresParams.BackBufferFormat = D3DFMT_UNKNOWN; dx_PresParams.BackBufferHeight = Wind.GetHeight(); dx_PresParams.BackBufferWidth = Wind.GetWidth(); dx_PresParams.SwapEffect = D3DSWAPEFFECT_DISCARD; if (FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Wind.GetHWnd(), D3DCREATE_HARDWARE_VERTEXPROCESSING, &dx_PresParams, &m_pDxDev))) { if (FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, Wind.GetHWnd(), D3DCREATE_SOFTWARE_VERTEXPROCESSING, &dx_PresParams, &m_pDxDev))) { MessageBox(Wind.GetHWnd(),"Failed to create even the reference device!", "FATAL ERROR!",MB_OK|MB_ICONEXCLAMATION); }else{ MessageBox(Wind.GetHWnd(),"working with the reference device!", "Problems",MB_OK); } } btw, it's the "Failed to create even the reference device!" message I get

Share this post


Link to post
Share on other sites
Advertisement
First, instead of using if FAILED(D3DSomeFunction)), you should assign the return code to a variable and do your if FAILED(variable). That way, you can display the value of the return code. It will tell you why the function failed.

In this case, it is failing because D3DFMT_UNKNOWN isn't a valid backbuffer format (at least not in fullscreen mode). You need to specify a valid backbuffer format for the device creation to succeed.

Share this post


Link to post
Share on other sites
"instead of using if FAILED(D3DSomeFunction)), you should assign the return code to a variable and do your if FAILED(variable)"

OK, I never heard that before, I'll take it on board.

"D3DFMT_UNKNOWN isn't a valid backbuffer format (at least not in fullscreen mode)"

yup, here's how i fixed it:

D3DDISPLAYMODE d3ddm;
m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);

D3DPRESENT_PARAMETERS dx_PresParams;

ZeroMemory( &dx_PresParams, sizeof(dx_PresParams) );

dx_PresParams.Windowed = FALSE;
dx_PresParams.FullScreen_RefreshRateInHz = d3ddm.RefreshRate;
dx_PresParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
dx_PresParams.BackBufferCount = 1;
dx_PresParams.BackBufferFormat = d3ddm.Format;
dx_PresParams.BackBufferHeight = Wind.GetHeight();
dx_PresParams.BackBufferWidth = Wind.GetWidth();
dx_PresParams.SwapEffect = D3DSWAPEFFECT_DISCARD;



Thanks Dave!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!