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

long dev_result = d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_window,D3DCREATE_MIXED_VERTEXPROCESSING,
&d3dpp,&m_device);

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);
		return;
	}

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:

D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp,sizeof(D3DPRESENT_PARAMETERS));
	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;
	else
		d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	SAFE_DELETE(g_deviceEnumeration);

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, anyone? Would this get better results in the GameDev forum?

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?

Ehh.... nevermind. It turns out it's cause my video card is old and weak. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.