{
if(ARB_direct_state_access)
{
- if(attch.type==GL_TEXTURE_2D)
+ 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)
set_texture_attachment(attch, tex, level, TextureCube::get_face_index(face));
}
+void Framebuffer::attach_layered(FramebufferAttachment attch, Texture3D &tex, unsigned level)
+{
+ static Require _req(ARB_geometry_shader4);
+ tex.allocate(level);
+ set_texture_attachment(attch, tex, level, -1);
+}
+
+void Framebuffer::attach_layered(FramebufferAttachment attch, TextureCube &tex, unsigned level)
+{
+ static Require _req(ARB_geometry_shader4);
+ tex.allocate(level);
+ set_texture_attachment(attch, tex, level, -1);
+}
+
void Framebuffer::detach(FramebufferAttachment attch)
{
if(!id)
layer = 0;
}
-void Framebuffer::Attachment::set(Texture &t, unsigned l, unsigned z)
+void Framebuffer::Attachment::set(Texture &t, unsigned l, int z)
{
type = t.get_target();
tex = &t;
Texture *tex;
};
unsigned level;
- unsigned layer;
+ int layer;
Attachment(FramebufferAttachment);
void set(Renderbuffer &);
- void set(Texture &, unsigned, unsigned);
+ void set(Texture &, unsigned, int);
void clear();
};
void attach(FramebufferAttachment attch, Texture2D &tex, unsigned level = 0);
void attach(FramebufferAttachment attch, Texture3D &tex, unsigned layer, unsigned level = 0);
void attach(FramebufferAttachment attch, TextureCube &tex, TextureCubeFace face, unsigned level = 0);
+ void attach_layered(FramebufferAttachment attch, Texture3D &tex, unsigned level = 0);
+ void attach_layered(FramebufferAttachment attch, TextureCube &tex, unsigned level = 0);
void detach(FramebufferAttachment attch);
/** Checks the completeness of the framebuffer. Returns