level 8
红枫夕阳才
楼主
跟着网上的demo绘制一个三角形,但是抄完后报错
定点着色器代码
#version 330 core
in vec3 aPos;
in vec3 aColor;
out vec3 ourColor;
void main(){
ourColor = aColor;
gl_Position =vec4(aPos, 1.0);
}
片段着色器代码
#version 330 core
in vec3 ourColor;
void main(){
gl_FragColor = vec4(ourColor,1.0);
}
报错:
QOpenGLShader::compile(Vertex): 0(2) : error C0204: version directive must be first statement and may not be repeated
0(7) : error C5060: out can't be used with non-varying ourColor
*** Problematic Vertex shader source code ***
#define lowp
#define mediump
#define highp
#line 1
???#version 330 core
in vec3 aPos;
in vec3 aColor;
out vec3 ourColor;
void main()
{
ourColor = aColor;
gl_Position =vec4(aPos, 1.0);
}
***
"0(2) : error C0204: version directive must be first statement and may not be repeated\n0(7) : error C5060: out can't be used with non-varying ourColor\n"
2021年08月04日 10点08分
1
定点着色器代码
#version 330 core
in vec3 aPos;
in vec3 aColor;
out vec3 ourColor;
void main(){
ourColor = aColor;
gl_Position =vec4(aPos, 1.0);
}
片段着色器代码
#version 330 core
in vec3 ourColor;
void main(){
gl_FragColor = vec4(ourColor,1.0);
}
报错:
QOpenGLShader::compile(Vertex): 0(2) : error C0204: version directive must be first statement and may not be repeated
0(7) : error C5060: out can't be used with non-varying ourColor
*** Problematic Vertex shader source code ***
#define lowp
#define mediump
#define highp
#line 1
???#version 330 core
in vec3 aPos;
in vec3 aColor;
out vec3 ourColor;
void main()
{
ourColor = aColor;
gl_Position =vec4(aPos, 1.0);
}
***
"0(2) : error C0204: version directive must be first statement and may not be repeated\n0(7) : error C5060: out can't be used with non-varying ourColor\n"