O'Reilly logo

OpenGL Shading Language, Third Edition by Mike Weiblen, Hugh Malan, Barthold Lichtenbelt, John M. Kessenich, Dan Ginsburg, Bill Licea-Kane, Randi J. Rost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Language Definition

by John Kessenich

In this chapter, we present the language features of the OpenGL Shading Language. We start with a simple example of a working pair of vertex and fragment shaders to show their basic structure and interfaces. Each aspect of the language is then discussed in turn.

The OpenGL Shading Language syntax comes from the C family of programming languages. Tokens, identifiers, semicolons, nesting with curly braces, control-flow, and many keywords look like C. Both comment styles, // ... and /* ... */, are accepted. Much is also different, though, and all important differences from C are discussed.

Each shader example is presented as it might appear in a file or onscreen. However, as explained in Chapter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required