Jump to content
  • Advertisement

Archived

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

Hippokrates

Reacting to WM_SIZE

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

Well how do I react to WM_SIZE when using D3D8 ? I tried to set a viewport and to reset the projection matrix but it did not exactly work because the graphics were not clipped but messed up. Here is the code:
case WM_SIZE:
		D3DVIEWPORT8 ViewPort;
		RECT Rect;
		GetClientRect(g_pApplication->GetHandle(), &Rect);
		ViewPort.X = 0;
		ViewPort.Y = 0;
		ViewPort.Width = Rect.right - Rect.left;
		ViewPort.Height = Rect.bottom - Rect.top;
		ViewPort.MinZ = 0.0f;
		ViewPort.MaxZ = 1.0f;
		if(SAFE_CHECK(g_pGraphics)) {
			g_pGraphics->GetDevice()->SetViewport(&ViewPort);
			g_pGraphics->SetPerspective(D3DX_PI / 4, 1.0f, 1000.0f);
		}
		break;
 
And the code of the SetPerspective method:
bool CGraphics3D::SetPerspective(float fFOV, float fNear, float fFar) {
	//Lokale Variablen
	D3DXMATRIX MatrixProjection;
	HRESULT hr;
	D3DVIEWPORT8 Viewport;

	hr = m_lpD3DDevice->GetViewport(&Viewport);
	if(FAILED(hr)) {
		return ReportError(NULL, &hr, "Fehler beim Auslesen des Viewports (CGraphics3D::SetPerspective)");
	}
	float fAspect = ((float)Viewport.Width) / ((float)Viewport.Height);
	D3DXMatrixPerspectiveFovLH(&MatrixProjection, fFOV, fAspect, fNear, fFar);
	hr = m_lpD3DDevice->SetTransform(D3DTS_PROJECTION, &MatrixProjection);
	if(FAILED(hr)) {
		return ReportError(NULL, &hr, "Fehler beim Setzen der Projektions Matrix (CGraphics3D::SetPerspective)");
	}
	return true;
}
 

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!