]> git.tdb.fi Git - libs/gl.git/commitdiff
Check for empty attachments array instead of zero id in Framebuffer
authorMikko Rasa <tdb@tdb.fi>
Tue, 9 Nov 2021 23:43:06 +0000 (01:43 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 9 Nov 2021 23:43:59 +0000 (01:43 +0200)
The id is an OpenGL implementation detail and shouldn't be used in the
common part.

source/core/framebuffer.cpp

index cc8dec4f5358346fbf53f33c002a745420fb098b..01fd626598c676a7417f2772f8d72c3b4ae5b700 100644 (file)
@@ -47,7 +47,7 @@ Framebuffer::Framebuffer(const FrameFormat &f):
 
 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");
@@ -107,7 +107,7 @@ void Framebuffer::check_size()
 
 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))
@@ -163,7 +163,7 @@ void Framebuffer::attach_layered(FrameAttachment attch, TextureCube &tex, unsign
 
 void Framebuffer::detach(FrameAttachment attch)
 {
-       if(!id)
+       if(attachments.empty())
                throw invalid_operation("Framebuffer::detach");
 
        int i = format.index(attch);
@@ -177,7 +177,7 @@ void Framebuffer::detach(FrameAttachment attch)
 
 void Framebuffer::resize(const WindowView &view)
 {
-       if(id)
+       if(attachments.empty())
                throw invalid_operation("Framebuffer::resize");
 
        width = view.get_width();
@@ -186,9 +186,6 @@ void Framebuffer::resize(const WindowView &view)
 
 void Framebuffer::require_complete() const
 {
-       if(!id)
-               return;
-
        bool layered = (!attachments.empty() && attachments.front().layer<0);
        for(const Attachment &a: attachments)
        {