PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Cg

Cg

Cg, aka C for Graphics, is a pl created in 2003.

#473on PLDB 19Years Old 965Users
5Books 0Papers

Cg (short for C for Graphics) is a high-level shading language developed by Nvidia in close collaboration with Microsoft for programming vertex and pixel shaders. Cg is based on the C programming language and although they share the same syntax, some features of C were modified and new data types were added to make Cg more suitable for programming graphics processing units. This language is only suitable for GPU programming and is not a general programming language. Read more on Wikipedia...


Example from Wikipedia:
// input vertex struct VertIn { float4 pos : POSITION; float4 color : COLOR0; }; // output vertex struct VertOut { float4 pos : POSITION; float4 color : COLOR0; }; // vertex shader main entry VertOut main(VertIn IN, uniform float4x4 modelViewProj) { VertOut OUT; OUT.pos = mul(modelViewProj, IN.pos); // calculate output coords OUT.color = IN.color; // copy input color to output OUT.color.z = 1.0f; // blue component of color = 1.0f return OUT; }

Language features

Feature Supported Example Token
Comments
// A comment
Line Comments
// A comment
//
Semantic Indentation ϴ

Books about Cg from ISBNdb

title authors year publisher
The CG Tutorial: The Definitive Guide to Programmable Real-Time Graphics Fernando, Randima and Kilgard, Mark J. 2003 Addison-Wesley Professional
Computers and Games: 4th International Conference, CG 2004, Ramat-Gan, Israel, July 5-7, 2004. Revised Papers (Lecture Notes in Computer Science, 3846) 2006 Springer
Computers and Games: 6th International Conference, CG 2008 Beijing, China, September 29 - October 1, 2008. Proceedings (Lecture Notes in Computer Science, 5131) 2008 Springer
Cg (programming Language) Frederic P. Miller 2011
Essential CG Lighting Techniques with 3ds Max Darren Brooker 20121212 Taylor & Francis
imba.html · cg.html · kml.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com