Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const GLenum attachments[] = {GL_COLOR_ATTACHMENT1};
- glDrawBuffers(1, attachments);
- // Assuming the FBO and the 2 requried textures were correctly generated
- glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _fbo_tex[0], 0);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, _fbo_tex[1], 0);
- // glCheckFramebufferStatus(GL_FRAMEBUFFER) returns GL_FRAMEBUFFER_COMPLETE
- #version 300 es
- uniform mat4 modelviewProjectionMatrix;
- in vec4 position;
- void main() {
- gl_Position = modelviewProjectionMatrix * position;
- }
- #version 300 es
- uniform lowp vec4 colorIn;
- layout(location = 0) out lowp vec4 colorOut;
- void main() {
- colorOut = colorIn;
- }
- // Assuming the correct program and vertex array is bound
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);
- {
- const GLenum attachments[] = {GL_COLOR_ATTACHMENT0};
- glDrawBuffers(1, attachments); // OK
- glClear(GL_COLOR_BUFFER_BIT);
- // Draw red quad to GL_COLOR_ATTACHMENT0
- }
- {
- const GLenum attachments[] = {GL_COLOR_ATTACHMENT1};
- glDrawBuffers(1, attachments); // GL_INVALID_OPERATION Error
- glClear(GL_COLOR_BUFFER_BIT);
- // Draw green quad to GL_COLOR_ATTACHMENT1
- }
- const GLenum attachments[] = {GL_NONE, GL_COLOR_ATTACHMENT1};
- glDrawBuffers(2, attachments); // OK
- glClear(GL_COLOR_BUFFER_BIT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement