I keep getting D3DERR_INVALIDCALL from my CreateDevice() call. Here it is:


I think the problem is with m_window. Here's its creation:

if((m_window = CreateWindow("WindowClass",m_setup->name,g_deviceEnumeration->IsWindowed() ? WS_OVERLAPPED : WS_POPUP,0,0,800,600,NULL,NULL,m_setup->instance,NULL)) == NULL)
		MessageBox(NULL,"Error creating the window","CreateWindow()",MB_OK | MB_ICONERROR);

It's really weird. I put breakpoints in the code, and somtimes m_window appears to be fine (CreateDevice() still fails) and other times it seems like it wasn't initialized. On both occasions I've never gotten the "Error creating the window" message box I set up. Could something be corrupting the window between the the two functions? This is all the code I have in between those two calls:

	d3dpp.BackBufferWidth = g_deviceEnumeration->GetSelectedDisplayMode()->Width;
	d3dpp.BackBufferHeight = g_deviceEnumeration->GetSelectedDisplayMode()->Height;
	d3dpp.BackBufferFormat = g_deviceEnumeration->GetSelectedDisplayMode()->Format;
	d3dpp.BackBufferCount = m_setup->totalBackBuffers;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.hDeviceWindow = m_window;
	d3dpp.Windowed = g_deviceEnumeration->IsWindowed();
	d3dpp.EnableAutoDepthStencil = true;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.FullScreen_RefreshRateInHz = g_deviceEnumeration->GetSelectedDisplayMode()->RefreshRate;
	if(g_deviceEnumeration->IsVSynced() == true)
		d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
		d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;


basically setting up the presentation parameters. I don't see anything that would cause m_window to become corrupt if it wasn't already. Anyone have any ideas? This is the second day I've been at this.

Thanks a bunch to anyone that helps! :)

Um, seeing as I have around 50 views and no replies (other than myself), I'm thinking this would be better off in the game dev forum. Is is possible for a mod to move it?

This article has been dead for over six months. Start a new discussion instead.