OpenGL Shader Compilation Errors: unexpected $undefined at token “

前端 未结 4 1055
萌比男神i
萌比男神i 2020-12-30 07:03

I saw this question and it really shedded some light. Despite this, I can\'t seem to figure out how I\'m \"improperly\" loading my shader, because this has executed

4条回答
  •  遥遥无期
    2020-12-30 07:40

    That error message means that the shader compiler is seeing a garbage character (something other than a printable ASCII character, a space, a tab, or a newline) on the first line of the shader. Which most likely means that the string you're passing to glShaderSource is garbage -- probably a dangling pointer that once pointed at your shader code but no longer does due to something getting destructed.

    edit

    I see from your link you have code that looks like:

    s.Source = shader.toStdString().c_str();
    

    That will set s.Source pointing at the internal buffer of a temporary std::string object that will be destroyed shortly after this line, leaving s.Source a dangling pointer...

提交回复
热议问题