Unsolved Shader fails to compile after upgrading to Qt Creator 4.7
-
vertex and fragment shader are used in
ShaderEffect
ShaderEffect { id: effect ... ... vertexShader: "qrc:/MainWindow/Resources/shader/" + getShaderName() + "_vs.glsl" fragmentShader: "qrc:/MainWindow/Resources/shader/" + getShaderName() + "_fs.glsl" }
The error log:
10:15:54: Starting D:\xes\futureslide\build-XESlides-Desktop_Qt_5_11_0_MSVC2017_64bit-Debug\debug\XESlides... QML debugging is enabled. Only use this in a safe environment. QOpenGLShader::compile(Vertex): ERROR: 0:1: ' ' : invalid version directive ERROR: 0:2: 'in' : storage qualifier supported in GLSL ES 3.00 only ERROR: 0:3: 'in' : storage qualifier supported in GLSL ES 3.00 only ERROR: 0:4: 'out' : storage qualifier supported in GLSL ES 3.00 only *** Problematic Vertex shader source code *** #version 410 #line 1 uniform highp mat4 qt_Matrix; in highp vec4 qt_Vertex; in highp vec2 qt_MultiTexCoord0; out highp vec2 coord; void main() { coord = qt_MultiTexCoord0; gl_Position = qt_Matrix * qt_Vertex; } *** QOpenGLShader::compile(Fragment): ERROR: 0:1: ' ' : invalid version directive ERROR: 0:1: 'in' : storage qualifier supported in GLSL ES 3.00 only ERROR: 0:5: 'out' : storage qualifier supported in GLSL ES 3.00 only ERROR: 0:16: 'texture' : no matching overloaded function found ERROR: 0:16: '=' : cannot convert from 'const float' to 'lowp 4-component vector of float' *** Problematic Fragment shader source code *** #version 410 #line 1 in highp vec2 coord; uniform highp float time; uniform sampler2D src; uniform lowp float qt_Opacity; out lowp vec4 outColor; void main() { lowp float modPart = mod(coord.x, 0.2); lowp float solidPart = time * 0.2; if ( modPart > solidPart ) { outColor = vec4(1.0, 1.0, 1.0, 1.0); } else { lowp vec4 tex = texture(src, coord); outColor = tex * qt_Opacity; } } *** QQuickCustomMaterialShader: Shader compilation failed: "ERROR: 0:1: '\n' : invalid version directive \nERROR: 0:1: 'in' : storage qualifier supported in GLSL ES 3.00 only \nERROR: 0:5: 'out' : storage qualifier supported in GLSL ES 3.00 only \nERROR: 0:16: 'texture' : no matching overloaded function found \nERROR: 0:16: '=' : cannot convert from 'const float' to 'lowp 4-component vector of float'\n"
-
Qt creator is only an IDE and supports compiling with tool chains.
What is your compiler?
What is the OS?
Which version of source are you compiling?
Fromwhere did you get this source version? -
OS: Window 10 pro Build 1803
Compiler: vs2017
Qt Creator was Upgraded to 4.7 with online installer -
As noted above, Qt creator is only an IDE supporting you in using tool chains. There is no obvious reason that your program does not compile anymore. You need to check if the update has messed up your tool chain setup.
Go to "Tools"->"Options"->"Build&Run" and check the different tabs special warning signs.
Also you shoulkd do a rerun qmake and a rebuild. For whatever reason,which has nothing to do with the update, your project might be mis-aligned. A complete rebuild after rerun qmake will cure.
-
https://bugreports.qt.io/browse/QTCREATORBUG-20808
Add "QT_OPENGL=desktop" to your global or kit environment variables as a workaround. Apparently the default value was changed to "angle" with the update, which does not support higher opengl versions. -
@Anon723
good found ! -
@Anon723 thank you! Also found my OpenGL wasn't working after update. Alternatively, you can also add the following:
QApplication a(argc, argv); a.setAttribute(Qt::AA_UseDesktopOpenGL);
to make it work again.