/// <summary> /// The forms resize handler get called whenever the form is resized. /// When the form resizes we have to redefine the projection matrix /// as well as the viewport matrix. /// </summary> private void frmHelloCube_Resize(object sender, EventArgs e) { float aspect = (float)ClientRectangle.Width / (float)ClientRectangle.Height; m_projectionMatrix.Perspective(50, aspect, 1.0f, 3.0f); m_viewportMatrix.Viewport(0, 0, ClientRectangle.Width, ClientRectangle.Height, 0, 1); this.Invalidate(); }
/// <summary> /// The forms resize handler get called whenever the form is resized. /// When the form resizes we have to redefine the projection matrix /// as well as the viewport matrix. /// </summary> private void frmHelloCube_Resize(object sender, EventArgs e) { float aspect = (float)ClientRectangle.Width / (float)ClientRectangle.Height; m_projectionMatrix.Perspective(50, aspect, 1.0f, 3.0f); m_viewportMatrix.Viewport(0, 0, ClientRectangle.Width, ClientRectangle.Height, 0, 1); // set up zBuffer with the size of the window, near and far settup zBuffer = new ZBuffer(ClientRectangle.Width, ClientRectangle.Height, 1.0f, 1.4f); controlBox.Update(); this.Invalidate(); }