/// <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();
    }
Example #2
0
    /// <summary>
    /// OnResize is called whenever the window resizes
    /// </summary>
    /// <param name="e"></param>
    protected override void OnResize(EventArgs e)
    {
        base.OnResize(e);

        float w = (float)this.Width;
        float h = (float)this.Height;

        // define the projection matrix
        _projectionMatrix.Perspective(45, w / h, 0.01f, 10.0f);

        // define the viewport
        gl.Viewport(0, 0, (int)w, (int)h);

        glUtils.GetGLError("OnResize", true);
    }
Example #3
0
    /// <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();
    }