vector<GLenum> color_bufs;
color_bufs.reserve(format.size());
unsigned i = 0;
- for(const uint16_t *j=format.begin(); j!=format.end(); ++j, ++i)
+ for(FrameAttachment a: format)
{
- GLenum gl_attach_point = get_gl_attachment(static_cast<FrameAttachment>(*j));
+ GLenum gl_attach_point = get_gl_attachment(a);
if(dirty&(1<<i))
{
const Attachment &attch = attachments[i];
else if(type==GL_TEXTURE_3D)
glFramebufferTexture3D(GL_FRAMEBUFFER, gl_attach_point, type, attch.tex->get_id(), attch.level, attch.layer);
else if(type==GL_TEXTURE_CUBE_MAP)
- glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, TextureCube::enumerate_faces(attch.layer), attch.tex->get_id(), attch.level);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, get_gl_cube_face(static_cast<TextureCubeFace>(attch.layer)), attch.tex->get_id(), attch.level);
}
else if(ARB_direct_state_access)
glNamedFramebufferTexture(id, gl_attach_point, 0, 0);
if(gl_attach_point!=GL_DEPTH_ATTACHMENT && gl_attach_point!=GL_STENCIL_ATTACHMENT)
color_bufs.push_back(gl_attach_point);
+
+ ++i;
}
if(color_bufs.size()>1)
throw incompatible_data("Framebuffer::attach");
unsigned i = 0;
- for(const uint16_t *j=format.begin(); j!=format.end(); ++j, ++i)
- if(*j==attch)
+ for(FrameAttachment a: format)
+ {
+ if(a==attch)
{
attachments[i].set(tex, level, layer);
dirty |= 1<<i;
check_size();
return;
}
+ ++i;
+ }
throw incompatible_data("Framebuffer::attach");
}
void Framebuffer::attach(FrameAttachment attch, Texture2D &tex, unsigned level)
{
- tex.allocate(level);
set_attachment(make_typed_attachment(attch, tex.get_format()), tex, level, 0, 0);
}
void Framebuffer::attach(FrameAttachment attch, Texture3D &tex, unsigned layer, unsigned level)
{
- tex.allocate(level);
set_attachment(make_typed_attachment(attch, tex.get_format()), tex, level, layer, 0);
}
void Framebuffer::attach(FrameAttachment attch, TextureCube &tex, TextureCubeFace face, unsigned level)
{
- tex.allocate(level);
- set_attachment(make_typed_attachment(attch, tex.get_format()), tex, level, TextureCube::get_face_index(face), 0);
+ set_attachment(make_typed_attachment(attch, tex.get_format()), tex, level, face, 0);
}
void Framebuffer::attach_layered(FrameAttachment attch, Texture3D &tex, unsigned level)
{
static Require _req(ARB_geometry_shader4);
- tex.allocate(level);
set_attachment(make_typed_attachment(attch, tex.get_format()), tex, level, -1, 0);
}
void Framebuffer::attach_layered(FrameAttachment attch, TextureCube &tex, unsigned level)
{
static Require _req(ARB_geometry_shader4);
- tex.allocate(level);
set_attachment(make_typed_attachment(attch, tex.get_format()), tex, level, -1, 0);
}