I have multiple fragment shader output variables
, and I want to use them as attached-images
in the framebuffer, so that I could read them out and store as images in the disk
.
But I am not sure how to do it with or without
off-screen rendering.
What happens when I call glDrawArray
? when should I use glReadBuffer
and glReadPixel
? Assume I have 3 outputs variables, that is
layout (location = 0) out vec3 a;
layout (location = 1) out float b;
layout (location = 2) out vec4 c;
Assume I create the 3 draw buffers:
const GLenum imagebuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2};
glDrawBuffers(3, imagebuffers);
Could anyone give me a code, how should I order these commands?