glDrawBuffers(N, {GL_NONE, GL_COLOR_ATTACHMENT...}

Hi,

I have a draw buffers related question. Lets say I want to draw to one (or more) frame buffer attachments with user defined output names in the fragment shader. I attach my buffers to my FBO and define frag data locations for my user defined fragment shader outputs to start from 1 (not from 0!). To ‘bend’ this frag data locations to my attachments, I set glDrawBuffers( 8, {GL_NONE, GL_COLOR_ATTACHMENT0, GL_NONE, …} ) (in case of one attachment).
As far as I understand the specs, this should work as I connected the output of the shader to “1”, while the entry “1” in the array I gave glDrawBuffers points to GL_COLOR_ATTACHMENT0 and the first texture I attached to my FBO is the one I want to draw to.

So let’s not debate why I start not with 0 in this case.

The problem I have is, that this setup works fine on Windows and Linux (NVidia and ATI) but fails to draw anything to the texture on MacOS X (glClear works in this setup and my queries tell me the correct number of fragments being created, but nothing from rendering happens to go into the texture unless I change the glDrawBuffers call). So I’m wondering wether I missed something in the spec (maybe a core vs. compatibility nuance?) or if this might be just another MacOS bug.

Any input is welcome.

As I read it, glDrawBuffers() associates COLOR_ATTACHMENT_i at position n in the array with color number n as long as n is smaller than GL_MAX_DRAW_BUFFERS. Your constants are definitely legal and I don’t assume you try to exceed the above limit.

I don’t see anything illegal and having it work for NVidia and AMD seems to me like it’s a rotten Apple. By the way, the core spec seems wrong in this section:

Yeah, gl_FragColor and gl_FragData … Ironically the API reference doesn’t include this section whereas the legacy reference does.

This now has a Bug ID#11826727.

Are you sure you linked the program after calling glBindFragDataLocation?

Thanks for the hint arekkusu, I actually forgot to link the program in my example I build for Apple (need to fix that). However, in my original app and the fixed example the bug exists even if I correctly link the program after changing the frag data location.