Coming from IntelliJ, CLion is my favourite C/C++ IDE. It also has many plugins that extend its functionality beyond C++, and one that I’ve found useful while experimenting with game development is the GLSL plugin that adds syntax highlighting and autocompletion for the GL Shading Language.
I also like to use the Atom editor for tasks like writing shaders because it’s so lightweight - a quality that lends itself to rapid experimentation. Atom already has packages that provide autocompletion and syntax highlighting for GLSL, but it didn’t have one that provided linting. I decided to write one as an exercise in learning how to write and release packages for this editor.
Typically, linting plugins don’t have much logic themselves but instead invoke command line tools which perform the lint process and return a list of errors or warnings with line and column numbers. Recently I learned of the Khronos GLSL Reference compiler which is a useful tool for compiling and linking shaders without having to start up your application which saves time and pain. The simplest form of this is a command line tool called
glslangValidator into which you pass the filenames of the shaders you wish to validate. That ticks the boxes for my requirements.
This means that my glsl linter package does hardly any work at all - it uses
glslangValidator to perform the validation and then uses pre-existing Atom functionality to display the lint messages. It just connects these things together and adds some tests around it. The package is published to Atom’s package repository under linter-glsl.
So if you want to develop GL Shaders in Atom, here is how to do it:
- Get Atom
- Windows and Linux: Binaries
brew install glslang
- Get the language-glsl, autocomplete-glsl and linter-glsl Atom packages either through ‘Install Packages And Themes’ or with apm:
apm install language-glsl autocomplete-glsl linter-glsl
- Edit the settings for linter-glsl and enter the path to
There are two extra features that I want my linter to be capable of:
glslangValidator only accepts shaders named
*.(vert|frag). This convention isn’t used universally and another commonly used convention is
*.(v|f).glsl. I think my way around this will be to create a temporary symlink with the supported filename format.
Secondly, the reference compiler can also link shaders rather than just compile them individually. I would like to use this functionality in the linter, perhaps assuming shaders with the same name but different type extensions should be linked together.
I hope to find time to add these features in soon. In the meantime the source is available on GitHub.