Vertex shader not compiling due to a non-Ascii character?

不羁岁月 提交于 2019-12-02 01:34:28

I had exactly the same error. This is almost certainly due to Unicode Byte Order Marks, or similar unprinted characters generated by text editors.

These are common in the first characters of a unicode file, but can occur anywhere.

You can programmatically strip these from your shader source strings before compiling, but this could be costly if you are compiling many shaders. See the above link for the data to strip if you go this route.

An alternative is simply to keep the files in ANSI/ASCII format. I am sure most text editors have the facility to set/convert formats, but I will give Notepad++ as an example since it's what I use to edit GLSL:

  1. Open the GLSL file.
  2. Encoding -> Convert to ANSI. (Note that merely hitting "Encode in ANSI" will not strip the characters)
  3. Save the file.

The above should also strip other characters prone to confusing GLSL parsers (and C/C++ in general).

You could inform the user(/developer) the files are in an incorrect format on load in debug builds.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!