Cg Language

Status of Cg?

The Cg Toolkit is a legacy NVIDIA toolkit no longer under active development or support. Cg 3.1 is our last release and while we continue to make it available to developers, we do not recommend using it in new development projects because future hardware features may not be supported.

NVIDIA was proud to introduce programmable shading with Cg, which supported dozens of different OpenGL and DirectX profile targets. It allowed developers to incorporate interactive effects within 3D applications and share them among other Cg applications, across graphics APIs, and most operating systems (Windows XP, Vista and Windows 7, Mac OS X for Leopard, Snow Leopard & Lion, Linux 32-bit & 64-bit) as well as balance effect complexities with client GPU capabilities.

Going forward, we recommend new development with GLSL, or HLSL for Windows applications, rather than Cg.

What is Cg?

C for Graphics. Cg is the high-level GPU shader authoring language designed, developed and implemented by NVIDIA.

Is Cg Proprietary?

The Cg Language Specification is published and open in the sense that other vendors may implement products based on it.

Does Cg replace OpenGL or Direct3D?

Cg layers on top of OpenGL, DirectX 9, 10 or 11.

The Cg compiler outputs assembly, GLSL or HLSL code in various formats supported by OpenGL or DirectX.

Does Cg replace C/C++?

Cg is a GPU shading language. A shading language is a type of programming language that tells the GPU how to shade pixels. The main program will still be written in C, C++, C#, Java, Python or other CPU programming language.

What's the difference between the Cg language and a Cg compiler?

The Cg language has a syntax and grammar suitable for real-time programmable GPUs.

A Cg compiler is an application that accepts Cg language input, and produces output in one of the assembly language, GLSL or HLSL formats that are accepted by modern GPUs.


What platforms are supported by the NVIDIA Cg Toolkit?

  • Windows 32-bit, 64-bit
  • Linux 32-bit, 64-bit
  • Mac OS X ppc, i386 and x86_64
  • Solaris 32-bit, 64-bit

What is NVIDIA providing to developers?

NVIDIA provides developers with the NVIDIA Cg Toolkit, comprising of:

  • Compiler
  • Runtime Libraries
  • Language Specification
  • Standard Library
  • Reference Manual
  • User's Manual
  • Example programs, shaders and effects for OpenGL and Direct3D

Does the Cg Compiler perform platform specific optimizations?

Yes, the NVIDIA Cg Compiler aggressively optimizes shaders for multiple target GPU architectures.

How do I get started with Cg?

Download the current release of the Cg Toolkit.