4.1.4 Change Mesh::draw() contents

You need to change this in both Mesh.h and Mesh.cpp

Then, change from our previous orthographic projection to the new projeciton matrix

void Mesh::draw(glm::mat4 matModel, glm::mat4 matView, glm::mat4 matProj)
{
    // 1. Bind the correct shader program
    glUseProgram(shaderId);

    // 2. Set the appropriate uniforms for each shader
    // set model view transforms
    glm::mat4 mat_modelview = matView * matModel;
    
    GLuint modelview_loc = glGetUniformLocation(shaderId, "modelview" );
    glUniformMatrix4fv(modelview_loc, 1, GL_FALSE, &mat_modelview[0][0]);

    // set projection transforms
    glm::mat4 mat_projection = matProj;
    GLuint projection_loc = glGetUniformLocation( shaderId, "projection" );
    glUniformMatrix4fv(projection_loc, 1, GL_FALSE, &mat_projection[0][0]);

    // 3. Bind the corresponding model's VAO
    glBindVertexArray(buffers[0]);

    // 4. Draw the model
    glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
}

Last updated