Sign in to follow this  

DirectX8 Present function error

This topic is 3378 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 have a problem with IDirect3DDevice8::Present(). This function returns: D3DERR_INVALIDCALL I have done this:
BOOL aeGraphics::Init()
{
	if (m_hWnd==NULL)
	{
		return FALSE;
	}
	if(FAILED( m_pD3D = Direct3DCreate8(D3D_SDK_VERSION) ))
	{
		return FALSE;
	}

	m_d3dpp.BackBufferCount = 1;
	m_d3dpp.Windowed = m_Windowed;
	m_d3dpp.hDeviceWindow = m_hWnd;

	if(m_Windowed)
	{
		if(FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&m_d3ddm)))
			MessageError("Error video mode.");
		
		m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;

		m_d3dpp.BackBufferFormat = m_d3ddm.Format;
	
		m_d3dpp.EnableAutoDepthStencil = TRUE;
		m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	}
	else//Pantalla completa
	{
		m_d3dpp.BackBufferWidth   = m_Width;
		m_d3dpp.BackBufferHeight  = m_Height;

		for(int i=0;i<GetNumDisplayModes()-1;i++)
		{
			m_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT,i,&m_d3ddm);
			if(CheckFormat(m_d3ddm.Format ,FALSE,m_HAL))
			{
				m_d3dpp.BackBufferFormat = m_d3ddm.Format;
				break;
			}
		}

		m_d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
		m_d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
		m_d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
	}

	if(FAILED( m_pD3D->CreateDevice(D3DADAPTER_DEFAULT,		((m_HAL)?D3DDEVTYPE_HAL:D3DDEVTYPE_REF),m_hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,						&m_d3dpp,&m_pD3DDevice)))
	{
		MessageError("dvide error");
		return FALSE;
	}

	return TRUE;
}

BOOL aeGraphics::Display()
{
	HRESULT hr;
	hr = m_pD3DDevice->Present(NULL,NULL,m_hWnd,NULL);
	if(FAILED(hr))
	{
		switch(hr)
		{
		case D3DERR_INVALIDCALL:
			MessageError("Display: D3DERR_INVALIDCALL");
			break;
		case D3DERR_DEVICELOST:
			MessageError("Display: D3DERR_DEVICELOST");
			break;
		default:
			MessageError("Display: Error");
		}
		return FALSE;
	}
	else
		return TRUE;
}

and when I testing...
		pGraph->ClearDisplay(D3DCOLOR_RGBA(0,100,0,255));

		if(pGraph->BeginScene())
		{
			
			pGraph->EndScene();
		}
		

		pGraph->Display();//Error here

The GetLastError() Funtion return 1400 error :/ ClearDisplay works good when I try to draw a font is ok as well, but when i draw vertex it doesnt work :S

Share this post


Link to post
Share on other sites

This topic is 3378 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.

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