So it turns out, as cool as GLSL is, there's no support for #include directives.
Arse.
Includes are quite handy so they are.
Right, so what we need now is some existing pre-processor to expand the includes in-place.
What about gcc -E ( or g++ -E ) ? Weeelll, they are ok, but they leave place markers everywhere, it doesn't read very nicely. Also you'd have to name all your glsl shader files .c or .cpp or something icky like that.
Turns out you can run "cpp -P" and that will pre-process the includes nicely. It works on any old file name too - so no problem calling them .glsl
How do I automate it though ? A script ? A makefile ?
Well, since you're preprocessing code, its near enough to a compile to use a makefile.
This is where the (un)fun begins... actually lets cut a long story short, i'm already sick of makefiles without recounting blow by blow details.
basically you'd do this:
GLSL_SHADERS := $(wildcard hwshaders/*.glsl)
GLSL_SHADERSOUT:= $(GLSL_SHADERS:.glsl=.glslo)
%.glslo : %.glsl
@echo $< $@
@rm -rf $@ ; cpp -P $< $@
glsl : $(GLSL_SHADERSOUT)
and then run
make glsl
Which would expect the glsl files to be one directory below the makefile in a dir called hwshaders.
Also I found out that if you are using a makefile conditional if, then the @ thingy to silence command echo doesn't really work. What did work for me was using the .SILENT rule.
.SILENT: safepub
safepub:
make clean
make
echo
if test -e /some/path/or/other/my.file; \
then \
echo File Exists \
else \
echo Doesn't Exist \
fi
so let that be a lesson to ye.