Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

shakazed

D3D Device scope

This topic is 5548 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

Hi! I´m poking around with some code for mesh rendereing (both static and skinned). So what I´m doing is splitting the code up into classes. One class for terrain, one for meshloading, one for physics and so on. The app ran smoothly until I added support for dinput. Then I get an error in my terrain class when setting up the fvf before rendering. I´ll give you the code I added for dinput first.
HRESULT CCamera::SetInputDevices(HINSTANCE hInstance, HWND hWnd)
{
	hResult = DirectInput8Create(hInstance, DIRECTINPUT_VERSION,
		IID_IDirectInput8, (void**)&p_iDInput8,NULL);
	DX_ERROR_CHK(hResult, "Failed to create input object");

	hResult = p_iDInput8->CreateDevice(GUID_SysKeyboard,&p_iDInputDevice8,NULL);
	DX_ERROR_CHK(hResult,"Failed to create input device");
	
	hResult = p_iDInputDevice8->SetDataFormat(&c_dfDIKeyboard);
	DX_ERROR_CHK(hResult, "Failed to set keyboard data format");

	hResult = p_iDInputDevice8->SetCooperativeLevel(hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND);
	DX_ERROR_CHK(hResult, "Failed to set cooperative lever (keyboard)");

	return hResult;

}
And this is the code I use for rendering the terrain. This code is the called on by the main class "CGraphics".
HRESULT CTerrain::RenderTerrain(IDirect3DDevice9 *p_iD3DDevice9)
{
	hResult = p_iD3DDevice9->SetStreamSource(0,p_iD3DVertexBuffer9,0, sizeof(CUSTOMVERTEX));
	DX_ERROR_CHK(hResult, "Failed to set stream source (terrain)");
	
	hResult = 	p_iD3DDevice9->SetFVF(CUSTOMVERTEX_FVF);
	DX_ERROR_CHK(hResult, "Failed to set flexible vertex format (terrain)");

	hResult = 	p_iD3DDevice9->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
	DX_ERROR_CHK(hResult, "Failed to draw primitve (terrain)");

	return hResult;
}
[source]

It almost seems as the d3d device gets lost or something. As I said the code worked fine until I added dinput support. Would greatly appreciate any help.



Bad Monkey Productions

Share this post


Link to post
Share on other sites
Advertisement

  • 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!