AtomLinter / linter-glsl

Atom package that lints GLSL shaders on the fly.
https://atom.io/packages/linter-glsl
MIT License
15 stars 6 forks source link

Configuration file #8

Closed dustContributor closed 8 years ago

dustContributor commented 8 years ago

Hi! First let me say this is pure awesome, so thanks a lot for this!

To the point, its very common for people to do different kinds of preprocessing for GLSL files (say, replacing values on load, or in my case, create the final shader source from a bunch of different files).

So straight linting of a single file usually doesn't yields good results. For example, I put my #define and #version directives on a single file, which I append to the GLSL sources on load. This results in a bunch of errors of the "XY thing not supported in GLSL 1.10" kind when I edit files with this linter.

It would be useful if I could define a configuration file (JSON, YAML, something like that) for the folder and all the GLSL files in it (much like the JavaScript linter for Atom where you can define a bunch of things in a JSON config file, like the ECMAScript version).

That way I can set, for example, "This folder contains GLSL 330 shaders, with #extension GL_ARB_shading_language_420pack required".

This could be as simple as just a setting to let me define a file that will be "injected" in the GLSL source I'm seeing before its sent to the validator.

Example:

I define a file named "mydefines.glsl" like this:

#version 330
#extension GL_ARB_shading_language_420pack : required
#define ATTRIB_NAME inPosition

And my shader is like this:

in vec3 ATTRIB_NAME;
void main ()
{
  // Stuff.
}

Both reside in a folder called "shaders".

And you could have a JSON/YAML configuration file, say, called ".linterglslcfg" where I can specify something like:

preffix_source: mydefines.glsl

Or maybe even combine a few (order of the files should be respected).

preffix_sources: [mydefines.glsl, myfunctions.glsl, somethingelse.glsl]

And I place it in the "shaders" folder, along the defines and other shaders. These will be preffixed to all the shaders I open in that folder (except the preffix sources themselves of course).

So the linter reads the file in the folder, and can send to the validatior the combined source like this:

#version 330
#extension GL_ARB_shading_language_420pack : required
#define ATTRIB_NAME inPosition

in vec3 ATTRIB_NAME;
void main ()
{
  // Stuff.
}

Sounds reasonable?