Jump to content
  • Advertisement
Sign in to follow this  
megatron242

OpenGL using nvidia cg

This topic is 3255 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

Hi, I have a fairly good experience with OpenGL, but I'm completely new to shaders. My graphics card (on my laptop) doesn't support GLSL, so this is out of the question. I've started learning a bit on ARB_vertex_program and ARB_fregment_program, but it seems to be that there is very little online resources and examples. I came across Nvidia's cg compiler. It seems like the best choice to make. What I would be glad to know, is how popular cg is, and if it's really a good idea to invest time in learning it. Also, since I want the size of my project to be as small as possible, is it mandaotry to distribute also the cg.dll and cgGL.dll, or can I compile a cg program into an ARB vertex/fragment program, which I would be able to load without the additional DLL's. Thanks, Vince

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by daviangel
I'd look into OpenCL. It's supposed to be the future and it's cross-platform to boot!


Em, *what*? THAT'S A GPGPU SPEC. That's like suggesting PhysX to someone looking for an audio library; useless.

Anyway, I would certainly suggest it, and though I'm not 100% sure how it works I do know that the compiler is capable of spitting out ARB assembly. On the DLL front, I'm also pretty sure you could hypothetically do it but at the same time I think most end users would find it a pain in the butt. YMMV.

Share this post


Link to post
Share on other sites
Quote:
Original post by megatron242
Also, since I want the size of my project to be as small as possible, is it mandaotry to distribute also the cg.dll and cgGL.dll, or can I compile a cg program into an ARB vertex/fragment program, which I would be able to load without the additional DLL's.

If you intent to compile the shaders into ARB_vp/fp, i would suggest go with GLSL instead. The Nvidia Cg compiler can take input in number of formats including GLSL or Cg and output ARB shaders assembler code which you can then use without any libraries.

Share this post


Link to post
Share on other sites
the cgGL.dll can handle all the loading of the shaders and setting uniforms etc. with the OpenGL API for you.

the cg.dll can compile shaders at runtime and give you usefull information about the shaders (uniform register offsets, sampler numbers, ...).

Of course you can use cg without these two dlls. If you drop cgGL.dll you will have to manage the shaders and all their parameters yourself. If you drop cg.dll you will have to parse the comment lines written at the top of the cg shader output to find out which uniform parameter and sampler goes to which location (or hardcode it in your shader and program).

Hardcodeing the samplers and uniform registers is not possible in GLSL, because the language does not support (or allow) it.

If you learn Cg and will later stop using it, its not a complete waste of time. Cg is almost identical to the Direct3D9 HLSL language. And once you know how to use Cg its also not too complicated to write GLSL or Direct3D910 HLSL code. Learning the concept of shaders and their (correct) interaction with your program was the larger problem for me (and that is almost the same for all languages).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!