Sign in to follow this  
MakavelianKode

D3D Error: "Failed to initialize primary swapchain"

Recommended Posts

Alright, so I'm new to DX - so what? :-P Anyway, I'm just trying my hand at DX. So far, I've succeeded at creating a DX window... when it's windowed =\. It doesn't work when it's fullscreen. I've looked everywhere I can look to help see what the problem is (MSDN, google, gamedev forum search, etc.) but I can't seem to find a solution. So here's what I got so far... My application fails at the call to IDirect3D9::CreateDevice(). The return value is D3DERR_INVALIDCALL which according to msdn means that "The method call is invalid. For example, a method's parameter may have an invalid value." The last time this happened to me, I altered the D3DPRESENT_PARAMETERS structure that I sent to the function. However, I'm not even sure why it was wrong then either. To fix the problem, I just changed the multisampling member as you'll see below. Anyway, here's the code for my filling in of the members of the D3DPRESENT_PARAMETERS structure.
void TestGame::GetD3DParams( D3DPRESENT_PARAMETERS ¶ms )
{
   // Fill in the paramaters
   params.BackBufferHeight = 640;
   params.BackBufferWidth = 480;
   if(windowed) params.BackBufferFormat=D3DDisplayMode.Format; 
   else params.BackBufferFormat = D3DFMT_X8R8G8B8;
   params.hDeviceWindow = myWnd.hWnd;
   params.Windowed = windowed;
   params.BackBufferCount = 1;
   params.SwapEffect = D3DSWAPEFFECT_DISCARD;
   
   // This is the portion that was giving me problems the first time
   /*if( FAILED(pD3D9->CheckDeviceMultiSampleType(
                 D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
                 params.BackBufferFormat,
                 windowed, D3DMULTISAMPLE_2_SAMPLES, NULL)))
   {
      params.MultiSampleType=D3DMULTISAMPLE_NONE;
   }
   else
   {
      params.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
   }*/
   
   // I changed it to the next line
   params.MultiSampleType = D3DMULTISAMPLE_NONE;
   params.EnableAutoDepthStencil = TRUE;		
   params.AutoDepthStencilFormat = D3DFMT_D16;	
   params.FullScreen_RefreshRateInHz = 0;
   if(windowed) params.PresentationInterval = 0;
   else params.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
   params.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
}
So yeah, after changing what I commented out above, I no longer have the problem in windowed mode, but I still have the problem in fullscreen mode. The debug spew says: Direct3D9: (ERROR) :The specified mode is unsupported. CreateDevice/Reset Fails Direct3D9: (ERROR) :Unable to set the new mode. CreateDevice/Reset Fails Direct3D9: (ERROR) :Failed to initialize primary swapchain Direct3D9: (ERROR) :Failed to initialize Framework Device. CreateDevice Failed. I can't imagine what could be the problem. Can anyone help me? - Mak

Share this post


Link to post
Share on other sites
The problem persists. Same debug spew too. First I tried comenting it out and then I just set it to zero. Neither solution worked. Out of curiosity - if it did work, don't I need to be able to lock the buffer in order to alter it and render stuff on it?

- Mak

Share this post


Link to post
Share on other sites
Just for shits and giggles, try setting AutoDepthStencil to FALSE. Also, are you sure D3DDisplayMode.Format is initialized? set a breakpoint on that line in the debugger and check to make sure it is what you think it is.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kibble
Just for shits and giggles, try setting AutoDepthStencil to FALSE. Also, are you sure D3DDisplayMode.Format is initialized? set a breakpoint on that line in the debugger and check to make sure it is what you think it is.


Hm. Not working. The .Format is what I expect it to be and it's not what is being assigned when it's fullscreen(which is where the problem occurs). *Sigh*, hehe. Thanks very much for your help though!

_mak_lives

Edit: Fixed typos

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this