MVP stands for: Model View project matrices [pipeline]
View matrix主要负责摄像机视角的转动,project matrix主要负责转换,在OpenGL中,规定:(倒序)Model 负责模拟物体
glm::mat4 mvp = proj * view * model;
通过是3个4x4的矩阵实现三变二
float positions[] = {//后两个是texCoord
100.0f, 100.0f, 0.0f, 0.0f, //0, 左下
200.0f, 100.0f, 1.0f, 0.0f, //1
200.0f, 200.0f, 1.0f, 1.0f, //2 右上
100.0f, 200.0f, 0.0f, 1.0f, //3
};
glm::mat4 proj = glm::ortho(0.0f, 960.0f, 0.0f, 540.0f, -1.0f, 1.0f); // 设置显示的大小
glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(-100, 0, 0));
glm::mat4 mvp = proj * view; // right to left
Shader shader("res/shaders/Basic.shader");
shader.Bind();
shader.SetUniform4f("u_Color", 0.8f, 0.3f, 0.8f, 1.0f);
shader.SetUniformMat4f("u_MVP", mvp);