用可编程管线绘制一个三角形
1.以上一节window为基准,进行绘制。
2.下载编译glew,并在.pro添加动态链接,并在头文件中引用。
LIBS +=-L/usr/lib64 -lGLEW
可能根据安装路径不同,修改动态链接库的路径,-L是路径的索引 -l是名称索引,去掉lib或so.
3.下载编译安装glm,并在头文件中引用。这个不需要添加动态链接库。
4.按照如下编写代码。
#include<GL/glew.h> #include <GLFW/glfw3.h> #include <stdio.h> #include<iostream> #include<glm/glm.hpp> #include<glm/ext.hpp> using namespace std; struct Vertex { float pos[3]; float color[4]; }; char *LoadFileContent(const char*path)//加载shader { FILE*pFile = fopen(path, "rb"); if (pFile) { fseek(pFile, 0, SEEK_END); int nLen = ftell(pFile); char*buffer = new char[nLen+1]; rewind(pFile); fread(buffer, nLen , 1, pFile); buffer[nLen]='