PDA

View Full Version : Compiling CG to GLSL



Iblues76
05-26-2011, 09:28 AM
Hi,

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

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

Iblues76
05-26-2011, 12:55 PM
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, 01: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.

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

Dark Photon
05-27-2011, 06: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.

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