Passing uniform 4x4 matrix to vertex shader program

前端 未结 2 900
南笙
南笙 2021-02-14 00:58

I am trying to learn OpenGL and following this: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/

Up until the point where they started passing mat

相关标签:
2条回答
  • 2021-02-14 01:27

    Consider using value_ptr rather then &MVP[0][0]

    glUniformMatrix4fv(MatrixID, 1, GL_FALSE, glm::value_ptr(MVP));
    

    genType::value_type const* glm::value_ptr (genType const & vec)

    Return the constant address to the data of the input parameter

    0 讨论(0)
  • 2021-02-14 01:34

    glUniform*() calls set values for the current program. You need to call glUseProgram() before the glUniform*() call. In this example:

    glUseProgram(programID);
    glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
    
    0 讨论(0)
提交回复
热议问题