• Advertisement
Sign in to follow this  

How can I build several ViewPorts in one window

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

I wanna build a application which with three viewports

... ...

m_pd3dDevice->GetViewport(&m_ViewPort);
	m_ViewPort.Width = 600;
	m_ViewPort.Height = 480;
	m_pd3dDevice->SetViewport(&m_ViewPort);

... ...

void CPPPDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(NULL==m_pd3dDevice)
		return;

	D3DRECT ViewRect = {0, 0, 600, 480};
	m_pd3dDevice->Clear(0, &ViewRect, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);

	D3DXMATRIXA16 matProj;
	D3DXMatrixOrthoLH(&matProj, 600, 480, 0.0f, 1000.0f);
	m_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);

	ShowFrontFace();
	ShowTopFace();
	ShowLeftFace();

	RECT destRect = {180, 20, 780, 500};
	m_pd3dDevice->Present(0, &destRect, 0, 0);
	
	CDialog::OnTimer(nIDEvent);
}

void CPPPDlg::ShowFrontFace()
{
	if(SUCCEEDED(m_pd3dDevice->BeginScene()))
	{		
		D3DXMATRIXA16 matView;
		D3DXVECTOR3 vEyePt(0.0f, 0.0f, -100.0f);
		D3DXVECTOR3	vLookatPt(0.0f, 0.0f, 0.0f);
		D3DXVECTOR3	vUpVec(0.0f, 1.0f, 0.0f);
		D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
		m_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);

		m_ViewPort.X = 0;
		m_ViewPort.Y = 0;
		m_ViewPort.Width = 300;
		m_ViewPort.Height = 240;
		m_pd3dDevice->SetViewport(&m_ViewPort);
		
		m_pd3dDevice->SetStreamSource(0, m_pCoord, 0, sizeof(Vertex));
		m_pd3dDevice->SetFVF(Vertex::FVF);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 0, 1);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 2, 1);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 4, 1);
				
		m_pd3dDevice->EndScene();
	}
}

void CPPPDlg::ShowTopFace()
{
	if(SUCCEEDED(m_pd3dDevice->BeginScene()))
	{
		D3DXMATRIXA16 matView;
		D3DXVECTOR3 vEyePt(0.0f, 100.0f, 0.0f);
		D3DXVECTOR3	vLookatPt(0.0f, 0.0f, 0.0f);
		D3DXVECTOR3	vUpVec(0.0f, 0.0f, 1.0f);
		D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
		m_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
		
		m_ViewPort.X = 300;
		m_ViewPort.Y = 0;
		m_ViewPort.Width = 300;
		m_ViewPort.Height = 240;
		m_pd3dDevice->SetViewport(&m_ViewPort);
		
		m_pd3dDevice->SetStreamSource(0, m_pCoord, 0, sizeof(Vertex));
		m_pd3dDevice->SetFVF(Vertex::FVF);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 0, 1);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 2, 1);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 4, 1);
				
		m_pd3dDevice->EndScene();
	}
}

void CPPPDlg::ShowLeftFace()
{
	if(SUCCEEDED(m_pd3dDevice->BeginScene()))
	{
		D3DXMATRIXA16 matView;
		D3DXVECTOR3 vEyePt(100.0f, 0.0f, 0.0f);
		D3DXVECTOR3	vLookatPt(0.0f, 0.0f, 0.0f);
		D3DXVECTOR3	vUpVec(0.0f, 1.0f, 0.0f);
		D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
		m_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
		
		m_ViewPort.X = 0;
		m_ViewPort.Y = 240;
		m_ViewPort.Width = 300;
		m_ViewPort.Height = 240;
		m_pd3dDevice->SetViewport(&m_ViewPort);
		
		m_pd3dDevice->SetStreamSource(0, m_pCoord, 0, sizeof(Vertex));
		m_pd3dDevice->SetFVF(Vertex::FVF);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 0, 1);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 2, 1);
		m_pd3dDevice->DrawPrimitive(D3DPT_LINELIST, 4, 1);
				
		m_pd3dDevice->EndScene();
	}
}



but, it doesn't run accurately.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement