O'Reilly logo

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition by Bill M. Licea-Kane, John M. Kessenich, Graham Sellers, Dave Shreiner

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

Creating Shaders with GLSL

The Starting Point

A shader program, just like a “C” program, starts execution in main(). Every GLSL shader program begins life as follows:

#version 330 corevoid main(){    // Your code goes here}

The // construct is a comment and terminates at the end of the current line, just like in “C”. Additionally, “C”-type, multiline comments—the /* and */ type—are also supported. However, unlike ANSI “C”, main() does not return an integer value; it is declared void. Also, as with “C” and its derivative languages, statements are terminated with a semicolon. While this is a perfectly legal GLSL program that compiles and even runs, its functionality leaves something to be desired. To add a little more excitement to our shaders, ...

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