- vector<GLenum> color_bufs;
- color_bufs.reserve(attachments.size());
- for(unsigned i=0; i<attachments.size(); ++i)
- {
- const Attachment &attch = attachments[i];
- if(dirty&(1<<i))
- {
- if(attch.type==GL_RENDERBUFFER)
- {
- if(ARB_direct_state_access)
- glNamedFramebufferRenderbuffer(id, attch.attachment, GL_RENDERBUFFER, attch.rbuf->get_id());
- else
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, attch.attachment, GL_RENDERBUFFER, attch.rbuf->get_id());
- }
- else if(attch.type)
- {
- if(ARB_direct_state_access)
- {
- if(attch.type==GL_TEXTURE_2D || attch.layer<0)
- glNamedFramebufferTexture(id, attch.attachment, attch.tex->get_id(), attch.level);
- else
- glNamedFramebufferTextureLayer(id, attch.attachment, attch.tex->get_id(), attch.level, attch.layer);
- }
- else if(attch.type==GL_TEXTURE_2D)
- glFramebufferTexture2D(GL_FRAMEBUFFER, attch.attachment, attch.type, attch.tex->get_id(), attch.level);
- else if(attch.layer<0)
- glFramebufferTexture(GL_FRAMEBUFFER, attch.attachment, attch.tex->get_id(), attch.level);
- else if(attch.type==GL_TEXTURE_2D_ARRAY)
- glFramebufferTextureLayer(GL_FRAMEBUFFER, attch.attachment, attch.tex->get_id(), attch.level, attch.layer);
- else if(attch.type==GL_TEXTURE_3D)
- glFramebufferTexture3D(GL_FRAMEBUFFER, attch.attachment, attch.type, attch.tex->get_id(), attch.level, attch.layer);
- else if(attch.type==GL_TEXTURE_CUBE_MAP)
- glFramebufferTexture2D(GL_FRAMEBUFFER, attch.attachment, TextureCube::enumerate_faces(attch.layer), attch.tex->get_id(), attch.level);
- }
- else if(ARB_direct_state_access)
- glNamedFramebufferRenderbuffer(id, attch.attachment, 0, 0);
- else
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, attch.attachment, 0, 0);
- }
-
- if(attch.attachment>=COLOR_ATTACHMENT0 && attch.attachment<=COLOR_ATTACHMENT3)
- color_bufs.push_back(attch.attachment);
- }