9

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?

4

3 回答 3

5

您可以在命令行上构建着色器,就像编译 c 或 c++ 程序或您正在使用的任何程序一样。如果您使用的是 Makefile,只需添加着色器的编译。

您可以使用 Cg 编译器来编译 Cg 和 GLGL 着色器。它应该在所有平台上都可用。

于 2010-10-25T10:19:36.013 回答
2

此外,还有参考 GLSL 编译器(处理 OpenGL 和 OpenGL ES)

http://www.khronos.org/opengles/sdk/tools/Reference-Compiler/

于 2014-09-25T15:32:39.783 回答
1

您可以针对此用途调整着色器玩具。它针对 WebGL(基于 OpenGL ES)编译着色器代码并报告错误(并且还运行着色器,以便您检查输出)。

您需要Firefox (Minefield) 或 Chrome (Canary) 的预发布版本来运行它。

我不确定您将如何利用编译状态结果来停止构建过程......有一些方法可以将结果从 javascript 写入本地文件, 但它们有点毛茸茸......

但是,在编译桌面应用程序之前,在 Shader Toy 中以交互方式测试着色器代码更改可能仍然是对您的开发过程的改进。由于您听起来像是在为移动设备开发桌面(对吗?),这将是一个胜利。

另一方面,如果您设法让您的桌面应用程序能够与 ES 库链接,那么这似乎是许多开发人员将从中受益的工具。

于 2010-10-25T17:17:07.897 回答