5
$\begingroup$

After updating my graphics driver and trying to run this example from John Chapman's blog I got this error

Vertex shader failed to compile with the following errors:
ERROR: 0:8: error(#105) #version must occur before any other program statement

The way that the version is defined is by including a file containing this code

#ifndef DEF_GLSL_
#define DEF_GLSL_

#version 420

...

So inside all other shader files one can see that the first line is as follows

#include "common/def.glsl"
...

I remember this working perfectly a few months ago. So what exactly has changed and the #include command is no longer valid?

$\endgroup$
  • $\begingroup$ There are a lot of code snippets on the linked page, but none of them appear to have the character "#". Could you show a minimal example of code that you know gives this error message? $\endgroup$ – trichoplax May 29 '16 at 14:26
  • $\begingroup$ @trichoplax my bad. I should have explained that there is an executable provided in order for you to run it. I will update the question with a minimal example. $\endgroup$ – ealiaj May 29 '16 at 14:50
4
$\begingroup$

The error message gives a clue in the wording:

#version must occur before any other program statement

Is there a reason that the previous 2 lines need to appear before the #version line? If not, you can avoid the error by moving this line to the beginning, since the actions of the lines are independent of their order in this instance.

The #version needing to be at the beginning of the file is not a new requirement. I don't know why you were able to run this code previously.

$\endgroup$
  • 1
    $\begingroup$ Yet as you can see by yourself Chapman's unedited algorithm is given in this exact form, and I do guarantee that it could run perfectly on this but also another computer (both having ATI graphics cards). I think it could have something to do with Vulkan and a more strict set of rules, but I have not been able to verify it yet. $\endgroup$ – ealiaj May 29 '16 at 20:56
  • $\begingroup$ @green_leaf oh yes I'm not doubting that it did work - I just don't have an explanation for why. I guess the change was a "correction" even though it hasn't turned out to be helpful for you... $\endgroup$ – trichoplax May 29 '16 at 22:10
  • $\begingroup$ that's very classic with ATI $\endgroup$ – v.oddou May 30 '16 at 1:04
  • $\begingroup$ @v.oddou indeed now that you mention it. It seems that they do that quite often. $\endgroup$ – ealiaj May 30 '16 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.