Trouble with GLSL, gl_FragData, and GL_AUXi

Hello,
I am trying to use the auxiliary color buffers to store information for deferred shading but they always just end up filled with black. Here are the relevant code snippets…

// in the renderer
GLenum rt[] = { GL_BACK, GL_AUX0, GL_AUX1, GL_AUX2 };
glDrawBuffers(4, rt);

// when i read the buffers into textures…
glReadBuffer(glrt); // ← I’ve confirmed these are GL_AUX0… GL… etc
glCopyTexImage2D(GL_TEXTURE_2D,
0,
_component,
0, 0,
_uwidth, _uheight,
0);

// in the shader
gl_FragData[0].rgb =
sun_contribution
+ moon_contribution
+ ambient_contribution;
gl_FragData[0].a = 1.0;
gl_FragData[1] = vec4(0.0, 1.0, 0.0, 0.0);
gl_FragData[2] = vec4(0.0, 1.0, 0.0, 0.0);
gl_FragData[3] = vec4(0.0, 1.0, 0.0, 0.0);

Is there some kind of setup I am missing to use these buffers? Any tips would be appreciated.

Are you sure those Aux buffers exist?

I looked in gl.h and it turns out GL_BACK isn’t defined as a valid render target, so I changed it to GL_BACK_LEFT and it seems to be working. So strange.

lol…

AUX buffers are deprecated, if it’s any constellation to you.

To Ilian’s point, let’s see your window creation code. Include how you’re choosing an visual for your window, and (if Linux/UNIX) the glxinfo output for your card.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.