How To Compile CG Files         How to check for errors in CG code

If you are a beginner trying to get into .cg you will quickly learn that it is pretty finicky; Much more picky than fixed function.
If you are running around in the dark trying to figure out what the hell is wrong with your .cg code, following these instructions will put an end to all that.

Step 1 - Install the compiler from Nvidia

Install the appropriate CG Toolkit from NVidia
(download is near the bottom of the page)

Step 2 - Using the CG Compiler (cgc.exe)

When you first go through the installed files you find a file called
cgc.exe
inside the directory:
C:\Program Files\NVIDIA Corporation\Cg\bin

Open your command shell (in Windows you can do it by typing 'cmd' inside Run...)

You can then use the following command lines to point it to whatever .cg files you want:

cgc -entry yourMainFP -profile ps_2_0 yourFile.cg
or
cgc -entry yourMainVP -profile vs_1_1 yourFile.cg

Step 3 - Set local working directory

Next, you will probably find that either cgc.exe or your .cg file can't be located. That's because you need to set your current working directory.

I recommend setting the current directory to the location of your .cg file. If you are new to this you do it with the 'cd' command:

cd "C:\Path\to\my\cg\file"

After that, now we are ready to run real commandlines, here is my final commandline:

"C:\Program Files\NVIDIA Corporation\Cg\bin\cgc.exe" -entry myVPentryPoint -profile vs_1_1 myFile.cg

If you would like to see the assembler generated when the cg is compiled use the '-l' command. Here's an example:

cgc -entry yourMainVP -profile vs_1_1 yourFile.cg -l assembler_output.txt


Alias: How_To_Compile_CG_Files