Hello, I am trying to pass an int from my vertex shader to my fragment shader but :
- when I dont use flat the value stay as 0 in my fragment shader but I get no error
- when I use flat I get this error :unrecognized profile specifier “flat”
Here is my shaders :
static const char *vertexShaderSourceCore =
"#version 330 core\n"
"uniform mat4 transform[10];\n"
"uniform bool isQuad;\n"
"flat varying out int instanceID;\n"
"in vec3 aPos;\n"
"void main()\n"
"{\n"
"instanceID = gl_InstanceID+isQuad*5;\n"
" gl_Position = transform[instanceID]* vec4(aPos, 1.0);\n"
"}\0";
static const char *fragmentShaderSourceCore =
"#version 330 core\n"
"varying out vec4 FragColor;\n"
"uniform vec4 color[10];\n"
"flat in int instanceID;\n"
"void main()\n"
"{\n"
" FragColor = color[instanceID];\n"
"}\n\0";
by the way I’m using opengl in qt so maybe I lack a header but it’s unlikly…
Any idea why I get this error ?
Thanks
Full debug output :
QOpenGLShader::compile(Vertex): 0(4) : warning C7022: unrecognized profile specifier "flat"
0(4) : error C0502: syntax error at token "flat"
0(4) : warning C7514: OpenGL does not allow varying of type int
0(8) : warning C7532: global variable gl_InstanceID requires "#version 140" or later
0(8) : warning C0000: ... or #extension GL_EXT_draw_instanced : enable
0(8) : warning C0000: ... or #extension GL_EXT_gpu_shader4 : enable
0(8) : warning C7011: implicit cast from "bool" to "int"
*** Problematic Vertex shader source code ***
#define lowp
#define mediump
#define highp
#line 1
uniform mat4 transform[10];
uniform bool isQuad;
flat varying out int instanceID;
in vec3 aPos;
void main()
{
instanceID = gl_InstanceID+isQuad*5;
gl_Position = transform[instanceID]* vec4(aPos, 1.0);
}
***
QOpenGLShader::compile(Fragment): 0(4) : warning C7022: unrecognized profile specifier "flat"
0(4) : error C0502: syntax error at token "flat"
*** Problematic Fragment shader source code ***
#define lowp
#define mediump
#define highp
#line 1
varying out vec4 FragColor;
uniform vec4 color[10];
flat in int instanceID;
void main()
{
FragColor = color[instanceID];
}
***
QOpenGLShaderProgram::uniformLocation(isQuad): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[0]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[0]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[1]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[1]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[2]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[2]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[3]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[3]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[4]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[4]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[5]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[5]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[6]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[6]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[7]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[7]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[8]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[8]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(transform[9]): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color[9]): shader program is not linked
QOpenGLShaderProgram::attributeLocation(aPos): shader program is not linked
QOpenGLShaderProgram::attributeLocation(aPos): shader program is not linked