9

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.

1
  • 1
    GLSL is close enough to C and C++ that a sufficiently non-smart formatter (one that doesn't actually parse C/C++) should be able to do the job. And any tool that can handle byte encoding stuff should be able to deal with GLSL text. Commented Jan 26, 2020 at 14:38

2 Answers 2

6

clang-format seems to handle GLSL fine:

 $ clang-format -i myshader.glsl

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

3

GLSLX, a GLSL type checker, formatter, and minifier:

http://evanw.github.io/glslx/

Not the answer you're looking for? Browse other questions tagged or ask your own question.