如果你是一个学习CG的新手,你会很快的发现CG语言是非常讲究的,比其他语言要挑剔的多.
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.
如果你正在为找CG中的一个错误费尽苦心,以下的方法会让你轻松很多.
Table of contents
- Step 1 - Install the compiler from Nvidia
- 步骤1:安装Nvidia的编译器
- Step 2 - Using the CG Compiler (cgc.exe)
- 步骤2:用cgc.exe编译
- Step 3 - Set local working directory
- 步骤3:设置本地工作目录
Step 1 - Install the compiler from Nvidia
Install the appropriate CG Toolkit from NVidia![(external link) (external link)](http://www.ogre3d.org/tikiwiki/styles/ogre/img/icons/external_link.gif)
(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当你第一次去浏览安装文件时候你会在C:\Program Files\NVIDIA Corporation\Cg\bin中找到cgc.exe
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:
你可以用以下命令你可以编译任何的cg文件
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:
我推荐设置当前的目录为你的cg的本地目录.如果你想用自己的目录,请使用cd命令.
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:
如果你想看看生成过程,使用"-i"
cgc -entry yourMainVP -profile vs_1_1 yourFile.cg -l assembler_output.txt