where has built-in variable "gl_FragColor" gone in OpenGL 4.4?
The book "Interactive Computer Graphics, A Top Down Approach with Shader Based OpenGL, 6th Edition" shows a minimum snippet of fragment shader in page 86 as follows:
But another book "OpenGL Programming Guide, the official guide to learning OpenGL, version 4.3" says in page 675 that in modern version of OpenGL (at least 4.3), the following are all built-in variables we have in a fragment shader:
I can not find any variable named "gl_FragColor" appearing in the list. So, does the second book miss anything, or the first book is out-of-date (although it's the latest version of the book)? If the latter is true, i.e., the "gl_FragColor" is obsolete, what is the new name of the variable corresponding to "gl_FragColor" in OpenGL version 4.4 that can set the pixel color to red using the code similar to that in the first image? Thank you.
Since a fragment shader can have multiple outputs gl_FragColor at first was replaced by gl_FragData[i] where i was sent to the i-th enabled draw buffer and these days fragment shader outputs are simply declared as "out" variables, see also wiki.
gl_FragColor is deprecated in GLSL 1.3 (OpenGL 3.0), so about 6 years ago.
P.S. Interestingly, "Interactive Computer Graphics, A Top Down Approach with Shader Based OpenGL, 6th Edition" was released in 2011, and was written against OpenGL 3.1. The code on the pg.86 is probably remainder of some previous revision of the book. Nope, there is another at page 92, and 246, 293, 296, 380, 396, etc. So, the error is more serious than I thought.
Last edited by Aleksandar; 06-08-2014 at 08:44 AM.