View Full Version : Compiling CG to GLSL

05-26-2011, 08:28 AM

Dark Photon posted how to compile code to glsl. I was hoping that there was a way to convert cg to glsl automatically.

05-26-2011, 09:33 AM
you can probably do with with the nvidia CG compiler. It can convert GLSL to arb assembly and other such wonderful things.

05-26-2011, 11:55 AM
so, how do I convert from CG to GLSL ?
I will keep searching how. But you are saying that this is possible...great!

Alfonse Reinheart
05-26-2011, 12:02 PM
Dark Photon posted a full command line for doing it. So use that. It's not going to get more "automatic" than that.

05-26-2011, 12:49 PM
that command is to compile glsl
not to convert CG to GLSL. I tried that already.

Dark Photon
05-27-2011, 05:44 PM
Hadn't actually done that. But IIRC you can cross-compile Cg to GLSL with cgc as well. Something like:

cgc -profile glslv vert.cg

Just tried it on this vertex shader:
* Cg (programming language)#A sample Cg vertex shader (Wikipedia) (http://en.wikipedia.org/wiki/Cg_%28programming_language%29#A_sample_Cg_vertex_s hader)
and it seemed to work. The output is kind of assembly-GLSL, but it is GLSL.

05-30-2011, 07:50 AM
you are right. thanks!