Since GLSL doesn't have an include-file option I'm trying to add this by using a "#pragma include" parser.
(I want this because I have some generic methods I'd like to implement only once but might use in many different shaders)
Parsing the shader files to get the included files works fine.
But when setting the ShaderSource with the multiple source files I always run into problems; since my main shader normally starts with "#version 330" and the #version-line always has to be the first line in the shader,
I can only add my main file as the first in the list[string] passed to Shadersource, and after that all the included files.
But then my main file can't use any functions implemented in those included files, since they'll essentially be concatenated *after* my main file so the compiler complains that it doesn't know the functions my main file is using.
The only way I can think of to get it to work is to read the main file, parse the include pragma, and then *replace* that pragma line with the file-contents of the file to be included (recursively applying this same method to all included files that might include other files themselves) - but that would mean the linenumbers in compilation-errors would not match the real linenumbers of the main file anymore.
Has anybody set up some sort of "include" functionality that works and keeps the linenumbers ? And if so - how ?