Framebuffer::Framebuffer(bool s):
- FramebufferBackend(s),
- dirty(0)
-{
- if(s)
- {
- format = get_system_format();
- get_system_size(width, height);
- }
-}
+ FramebufferBackend(s)
+{ }
Framebuffer::Framebuffer():
FramebufferBackend(false)
-{
- init();
-}
+{ }
Framebuffer::Framebuffer(FrameAttachment fa):
- FramebufferBackend(false)
+ Framebuffer()
{
- init();
set_format(fa);
}
Framebuffer::Framebuffer(const FrameFormat &f):
- FramebufferBackend(false)
+ Framebuffer()
{
- init();
set_format(f);
}
-void Framebuffer::init()
-{
- width = 0;
- height = 0;
- dirty = 0;
-}
-
void Framebuffer::set_format(const FrameFormat &fmt)
{
- if(!format.empty() || !id)
+ if(!format.empty())
throw invalid_operation("Framebuffer::set_format");
if(fmt.empty() || !is_format_supported(fmt))
throw invalid_argument("Framebuffer::set_format");
void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, unsigned level, int layer, unsigned samples)
{
- if(format.empty() || !id)
+ if(format.empty() || attachments.empty())
throw invalid_operation("Framebuffer::attach");
if((format.get_samples()>1 && samples!=format.get_samples()) || (format.get_samples()==1 && samples))
void Framebuffer::detach(FrameAttachment attch)
{
- if(!id)
+ if(attachments.empty())
throw invalid_operation("Framebuffer::detach");
int i = format.index(attch);
}
}
-void Framebuffer::resize(const WindowView &view)
-{
- if(id)
- throw invalid_operation("Framebuffer::resize");
-
- width = view.get_width();
- height = view.get_height();
-}
-
void Framebuffer::require_complete() const
{
- if(!id)
- return;
-
bool layered = (!attachments.empty() && attachments.front().layer<0);
for(const Attachment &a: attachments)
{
FramebufferBackend::require_complete();
}
-Framebuffer &Framebuffer::system()
-{
- static Framebuffer sys_framebuf(true);
- return sys_framebuf;
-}
-
-
-Framebuffer::Attachment::Attachment():
- tex(0),
- level(0),
- layer(0)
-{ }
void Framebuffer::Attachment::set(Texture &t, unsigned l, int z)
{