Sign in to follow this  

Nvidia's CG settings. edit: It's called "Syntax highlighting"

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, When I drag a file to my visual studio 2005 express edition, for instance "pixelshader.cg", the keywords don't turn blue. I've seen other people who do have that, and I'd like to know how I can turn that on using Nvidia's CG. To be clear, I mean that I want words like "float4 dot distance normalize" ect. to turn some color. Thanks for the help. edit: It's called "Syntax highlighting" [Edited by - Dolf on May 24, 2008 10:13:58 AM]

Share this post


Link to post
Share on other sites
Check the Cg folder in your Cg installation for instructions on how to do enble VS to recognize hlsl syntax. That folder is called: msdev_syntax_highlighting, and on my installation it is in following path:

C:\programs\NVIDIA Corporation\Cg\msdev_syntax_highlighting

Your path might be different, depending on where you installed the Cg.

Below are instructions, but you will need other contents from nvidia.



Want pretty syntax highlighting when editing your CG files in Visual Studio 6? Heres how:

1. Copy the usertype.dat file to the Visual Studio bin directory (typically C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin).

2. Start regedit (Start -> Run -> regedit) and go to HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++

3. Add cg to the end of the FileExtensions key (separated with a semicolon)

4. Restart Visual Studio and your shaders should now have syntax highlighting

NOTE: You can use the install_highlighting.reg file to simplify steps 2-3, just double click on the file and press Ok when prompted.

Share this post


Link to post
Share on other sites
I'm posting here because it doesn't seem to work. I must be doing something wrong.
I am using windows XP with visual studio 2005 express edition.

Share this post


Link to post
Share on other sites
that was USEFULL information; I just followed instructions and everything works fine with visual studio express 2008;

have you checked your tools->options->text editor->file extension

you have to add extensions that will be used with vs (.fx, .cg, .frag, .whatever_you_use_to_call_your_shaders)

You need to LEARN your tool and being able to discover some thing on your own. Nothing is more usefull then clicking on menus and looking around what options you have ...

By the way, I suggest writing shaders with emacs. Generally emacs will autoident and do more for your syntax then visual studio. I have written my own mode for writing shaders in emacs, you can get it here: www.nextpoint.se/cgfx-mode.zip.

For fast viewing of shaders I prefer open emacs since it is much smaller and comes up faster then VS too (it is almost as fast as notepad on my comp).

Share this post


Link to post
Share on other sites
Alright sorry about that. I thought it would be enough.

Anyway, I read the readme.txt.

It said I had to copy the usertype.dat. So I did.


Then I proceeded with "Visual Studio 2005 / 8:". The registry keys it talked about weren't there.
So I figured it has to be the other. "Visual Studio 6:"

The path of the usertype.dat didn't match anything in my folders.

So now I just clicked all .reg files, and it's still not working.

Share this post


Link to post
Share on other sites
"have you checked your tools->options->text editor->file extension

you have to add extensions that will be used with vs (.fx, .cg, .frag, .whatever_you_use_to_call_your_shaders)"

Oh my god! that was it!

Thanks thanks thanks! awesome!

Cheers, thanks for the help

Share this post


Link to post
Share on other sites
edit that file so that id does match your folder, be sure you have opened registry at correct key, and if it isn't there (in correct place) just make one.

I had to make one to get it to work with vs2008.

also add file extensions in opetions dialog as I wrote above.

Share this post


Link to post
Share on other sites
Now that's solved,

How do I properly get the compiler warnings/errors using a custom build step? Now I have something like this in my code:


//works fine, but needs compiler option /subsystem:Console for the output
void CheckShadersForErrors(char* name)
{
printf("\n");
char string[256];
memset(string,256,0);
sprintf(string,"cgc.exe ");
sprintf(string+8,name);
system(string);
printf("\n");
}
void Game::Init()
{
CheckShadersForErrors("shaders\\pixelshader.cg");
//ect






If I integrate custom build step in it, I'll get a "no program defined" error, but I don't want that error to stop me from running because it works perfectly fine without a program.

Edit: Let me just crank up your points on gamedev ;)

Share this post


Link to post
Share on other sites

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this