Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: where has built-in variable "gl_FragColor" gone in OpenGL 4.4?

  1. #1
    Junior Member Newbie
    Join Date
    May 2014
    Posts
    14

    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.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Untitled1.jpg 
Views:	34 
Size:	20.0 KB 
ID:	1337   Click image for larger version. 

Name:	Untitled2.png 
Views:	28 
Size:	17.6 KB 
ID:	1338  

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    757
    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.

  3. #3
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,146
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •