GLSL Overview

Disclaimer

This page presents an initial guide to several common features and other aspects of the GLSL language. It is meant to be a quick start guide, and is not even close to being "complete". The reference texts shown on the Home page of this web site should be consulted for additional details. Each program in the series of "Sample Program Sets" on this web site include increasingly complex shader program examples for you to study. You should also consult the official specifications document for the version of GLSL you are targeting with your "#version" directive:

[ GLSL 4.50 ; GLSL 4.40 ; GLSL 4.30 ; GLSL 4.20 ; GLSL 4.10 ; GLSL 4.00 ]

GLSL

GLSL is basically a subset of C/C++ with extensions. The next section enumerates the main parts of C/C++ that are not in GLSL. The remaining sections cover extensions and various other differences.

The Major Missing Pieces

Extensions and Other Language Differences

Execution Environment Differences

A "shader program" might actually be best imagined as a cooperating collection of programs with a DAG-like organizational structure. The output of some programs are gathered and used to generate the input to others. For example, a "GLSL program" that executes when a single triangle is rendered via glDrawArrays will consist of exactly three vertex shader executions and probably hundreds or even thousands (or even more) fragment shader executions. All shader program executions of a given type conceptually execute simultaneously. Depending on the GPU hardware, hundreds or even thousands will actually execute simultaneously.

Recall that shader programs in general are required to set certain out variables (either implicitly declared built-in variables, or explicitly declared variables) so that they can be collected, interpolated (if necessary), and passed into other shader programs.

The main function of each shader program must have the prototype: void main( ).