Note that there are some explanatory texts on larger screens.

plurals
  1. POGLSL Shader Program Randomly Fails to Compile
    primarykey
    data
    text
    <p>I'm experiencing a strange behaviour in my OpenGL application. I generate a number of GLSL programs during the initialization of the program. The shader programs are read from text files and the programs are compiled and linked. However, I randomly encounter compilation errors for one of the shader programs (a pass-through vertex shader). I cannot understand why the program loads perfectly fine and the shader program successfully compiles several times but fails to do in other times!</p> <p>Here is the shader code:</p> <pre><code>#version 330 // vertex position in the model space layout(location = 0) in vec3 inPosition; layout(location = 1) in vec2 inTexCoord; // will be interporlated for each fragment smooth out vec2 vTexCoord; // uniforms uniform mat4 projectionMatrix; uniform mat4 modelViewMatrix; void main(void) { gl_Position = projectionMatrix * modelViewMatrix * vec4(inPosition, 1.0); vTexCoord = inTexCoord; } </code></pre> <p>And here is the code for compiling the shader (passThroughVertShader is a QString):</p> <pre><code>this-&gt;passThroughVertShader = glCreateShader(GL_VERTEX_SHADER); const char *passThroughVertShaderCodeC = passThroughVertShaderCode.toStdString().c_str(); sourceCode = passThroughVertShaderCodeC; glShaderSource(this-&gt;passThroughVertShader, 1, &amp;sourceCode, NULL); glCompileShader(this-&gt;passThroughVertShader); glGetShaderiv(this-&gt;passThroughVertShader, GL_COMPILE_STATUS, &amp;isCompiled); if(isCompiled == GL_FALSE) { qDebug("ERROR compiling pass-through vertex shader.."); exit(-1); } glAttachShader(this-&gt;shaderProgram, this-&gt;passThroughVertShader); </code></pre> <p>And the function that loads it:</p> <pre><code>QString MyClass::readShaderFile(const QString &amp;filename) { QString content; QFile file(filename); if (file.open(QIODevice::ReadOnly)) { QTextStream tStream(&amp;file); content = tStream.readAll(); } return content; } </code></pre> <p><strong>Update:</strong></p> <p>Following Andon's suggestion, I double checked and I wasn't checking the log after failure. Here is what the log says:</p> <pre><code>Error: 0(17) : error C0000: syntax error, unexpected '!', expecting "::" at token "!" </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload