|
修改代码试试:
// 创建顶点着色器
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
const char *vsrc =
"#version 330\n"
"in vec4 vPosition; \n"
"in vec2 vTexCoord; \n"
"out vec2 texCoord; \n"
"uniform mat4 matrix; \n"
"void main() { \n"
" texCoord = vTexCoord; \n"
" gl_Position = matrix * vPosition; \n"
"} \n";
vshader->compileSourceCode(vsrc);
// 创建片段着色器
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
const char *fsrc =
"#version 330\n"
"uniform sampler2D tex; \n"
"in vec2 texCoord; \n"
"out vec4 fColor; \n"
"void main() { \n"
" fColor = texture(tex, texCoord); \n"
"} \n";
fshader->compileSourceCode(fsrc); |
|