glslcode-formattingclang-format

What formatting tools are available for GLSL?


I've recently been needing to review GLSL code, and I'm looking to enforce formatting conventions. Are there any tools like clang-format for GLSL where I can specify a config file and have it auto-format? Or, since GLSL is C-like, should I just use clang-format itself and hope for the best?

I need to enforce things like spacing, brace style, and indentation.


Solution

  • clang-format seems to handle GLSL fine:

     $ clang-format -i myshader.glsl
    

    https://clang.llvm.org/docs/ClangFormat.html