Fragment shaders: output variables

The global output variable gl_FragColor is deprecated after GLSL version 120. Now you have to give it a name and type by yourself, as in your example. Regarding several outputs, this link gives you information about the mapping: http://www.opengl.org/wiki/GLSL_Objects#Program_linking

(And I found that link at: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=270999 )

Hope this helps! :D

Ooops! I see that kvark gave the relevant information. Anyway, maybe you got something out of my text too.


Your example has 2 outputs. They have corresponding FBO slots associated after GLSL program linking. You can redirect them using glBindFragDataLocation.

Once you activated the shader and bound FBO, it all depends on a draw mask, set by glDrawBuffers. For example, if you passed GL_COLOR_ATTACHMENT0 and GL_COLOR_ATTACHMENT2 there, that would mean that output index 0 will go to the attachment 0, and output index 1 would go to the color attachment 2.