opengl 矩阵变换
opengl 坐标系的变换如下图:
我们给我们的图形,设置好顶点坐标后,通过Model Matrix 变换为世界坐标,然后 view Matrix相机坐标,Projection Matrix 屏幕坐标x,y ∈(-1,1)。
矩阵变换的结果是把三维的世界最终裁剪为二维的屏幕,数学的说法就是从一个集合到另一个集合的映射。
#include "glew.h"
#include <glfw3.h>
#include "common/loadShader.h"
#include "glm.hpp"
#include "ext.hpp"
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(480, 320, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
// Needed in core profile
if( glewInit() != GLEW_OK)
{
glfwTerminate();
return -