JavaScript EditorFree JavaScript Editor     Ajax Editor 



Main Page
Previous Page
Next Page

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 7, the OpenGL API passes shaders as strings, not files, because OpenGL does not consider shaders file based.


Previous Page
Next Page




JavaScript EditorAjax Editor     JavaScript Editor