user2990829
user2990829

Reputation: 5

What is the use of glMatrixMode(GL_MODELVIEW) in resize()?

static void resize(int width, int height)
{
   const float ar = (float) width / (float) height;

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;

}

viewport and projection matrix got resized,when we change the window size ,but what is the use of calling GL_MODELVIEW inside resize function.

Upvotes: 0

Views: 819

Answers (1)

keltar
keltar

Reputation: 18409

glMatrixMode sets current matrix type. All matrix-modifying operations (glLoadIdentity, glLoadMatrix, glTranslatef, ...) using current matrix.

Given code sets current matrix type to projection, modifies it, then sets current matrix to modelview so subsequent code (outside of this function) will modify modelview and not projection, and resets it to identity matrix (which is probably unnecessary, depending on draw function).

Upvotes: 1

Related Questions