• Advertisement


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

Reacting to WM_SIZE

This topic is 5682 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->SetPerspective(D3DX_PI / 4, 1.0f, 1000.0f);
And the code of the SetPerspective method:
bool CGraphics3D::SetPerspective(float fFOV, float fNear, float fFar) {
	//Lokale Variablen
	D3DXMATRIX MatrixProjection;
	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