views:

35

answers:

2

I've started working with OpenGL and writing shaders. My app checks for errors after loading and compiling shader programs, and if there is a problem it prints out the info log. This is great for catching errors (and I'm a newbie so I'm making a lot), but what I'd really like is to catch these errors at build time.

If I had a lint tool that could simply check a vertex or fragment shader for syntax errors, I could add it to my build process and have it stop the build.

I haven't been able to find such a tool. I started to try to write one, but I'm working on OpenGL ES and had trouble trying to write a desktop program that links against the ES libraries.

Maybe I missed it somewhere. Does such a tool exist?

A: 

You can build shaders on the command line, the same way as you compile your c or c++ program or whatever you are using. If you are using Makefile, just add the compilation of the shaders.

You can use Cg compiler to compile both Cg and GLGL shaders. It should be available on all platforms.

VJo
The Cg compiler will spit out errors for you, so you can handle them in your build scripts. Or, you could tie the Cg compiler into a custom C++ app and watch for it to return any errors, which you can then handle as necessary.
peachykeen
Looks promising, but doesn't seem to support OpenGL ES 2.0, which is the version that I need.
benzado
You just need to install the cg compiler on your PC, and compile shaders. The Cg compiler can be used as a command line tool.
VJo
A: 

You could adapt the Shader Toy for this use. It compiles the shader code against WebGL (which is based on OpenGL ES) and reports errors (and also runs the shader so you can check the output).

You'd need a prerelease build of Firefox (Minefield) or Chrome (Canary) to run it in.

I'm not sure how you'd harness the compilation status result to stop the build process... There are ways to write results to a local file from javascript but they're somewhat hairy...

However, it may still be an improvement to your development process to test your shader code changes interactively in Shader Toy before compiling your desktop app. Since you sound like you're developing on a desktop for mobile devices (right?), this would be a win.

On the other hand, if you managed to get your desktop app to work that links against the ES libraries, that would seem to be a tool lots of developers would benefit from.

LarsH
There's an OpenGL Shader Builder as part of Apple's developer tools, so I'm mostly set for interactive testing. I want syntax checking to catch dumb mistakes when I make small changes, or when I try to use nonexistent global variables (because so much has been removed in ES 2.0, but so many tutorials assume desktop GLSL).
benzado