The rest of Cg
![NVIDIA's Cg technology [ NVIDIA's robot @ 569 x 648 ] > View Full-Size in another window.](images/03-s.jpg) NVIDIA's robot
|
|
![NVIDIA's Cg technology [ Nuts and bolts behind robot @ 1059 x 782 ] > View Full-Size in another window.](images/04-s.jpg) Nuts and bolts behind robot
|
|
The compiler
If the language itself is the nuts and bolts of the Cg programming environment, the Cg compiler is the heart and soul that makes it all happen. Once the program is written, the compiler can output code for DirectX or OpenGL. Since Cg is designed specifically for vertex and pixel shader programs, DirectX versions 8 and 9 are supported as well as OpenGL 1.4. The compiler itself is cross platform; in particular programs written for Windows, Linux, Macintosh, and Xbox are supported. And if all that isn’t enough, the compiler can create code for all GPUs that support DirectX 8 (or above) and/or OpenGL 1.4, making it very universal. In keeping with Linux tradition, NVIDIA has open-sourced certain components of the compiler, allowing content developers to add their own customizations as well.
![NVIDIA's Cg technology [ API interfaces the hardware directly @ 640 x 477 ] > View Full-Size in another window.](images/05-s.jpg) API interfaces the hardware directly
|
|
![NVIDIA's Cg technology [ Cg works with both APIs, which work with all hardware @ 539 x 480 ] > View Full-Size in another window.](images/06-s.jpg) Cg works with both APIs, which work with all hardware
|
|
Like NVIDIA’s unified driver architecture, the Cg compiler employs a unified compiler architecture that is forward and backward compatible with today’s current and tomorrow’s next generation of graphics cores. As a result, once the program is written, the compiler will automatically optimize the program for multiple generations of graphics chips with no intervention from the programmer – the days of optimizing for one particular graphics core (future or present) are gone.
![NVIDIA's Cg technology [ The Cg compiler is universal @ 800 x 523 ] > View Full-Size in another window.](images/07-s.jpg) The Cg compiler is universal
|
|
![NVIDIA's Cg technology [ Face sample @ 1024 x 294 ] > View Full-Size in another window.](images/08-s.jpg) Face sample
|
|
The final components of the Cg toolkit are the Cg browser (a graphics interface for creating and modifying objects), the Cg standard library (a set of built-in functions dedicated to help the programmer with common computations), and a collection of pre-written Cg shaders that can be used for development as well as training.