Skip to main content

History: How To Compile CG Files

Preview of version: 4

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

History

Information Version
Fri 06 of Apr, 2012 18:38 GMT-0000 uzik added -l parameter explanation 6
Mon 28 of Jun, 2010 18:05 GMT-0000 jacmoe 5
Fri 30 of Apr, 2010 17:50 GMT-0000 jacmoe 4
Sat 02 of Jan, 2010 07:18 GMT-0000 jacmoe 3
Thu 24 of Dec, 2009 18:55 GMT-0000 jacmoe 2
Thu 16 of Oct, 2008 20:30 GMT-0000 Spacegaier 1