]> git.tdb.fi Git - libs/gl.git/commitdiff
Add sanity checks to bind functions
authorMikko Rasa <tdb@tdb.fi>
Tue, 29 Oct 2019 00:04:37 +0000 (02:04 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 29 Oct 2019 22:03:21 +0000 (00:03 +0200)
source/framebuffer.cpp
source/vertexsetup.cpp

index cf478ce29b686d842ce2074078952633b2e47b02..f402b64366e98e4d1cc44e56fb446d14a495d4bf 100644 (file)
@@ -355,6 +355,9 @@ void Framebuffer::blit_from(const Framebuffer &other, BufferBits bits, bool filt
 
 void Framebuffer::bind() const
 {
+       if(attachments.empty())
+               throw invalid_operation("Framebuffer::bind");
+
        if(set_current(this))
        {
                glBindFramebuffer(GL_FRAMEBUFFER, id);
index 8465ab060d54fe77041106a2c3c67a342102116e..53f825697b34b16444e783cfb32262361d10fc4f 100644 (file)
@@ -6,6 +6,7 @@
 #include <msp/gl/extensions/arb_vertex_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include "buffer.h"
+#include "error.h"
 #include "gl.h"
 #include "vertexarray.h"
 #include "vertexsetup.h"
@@ -124,6 +125,9 @@ void VertexSetup::update_vertex_array(const VertexArray &array, unsigned binding
 
 void VertexSetup::bind() const
 {
+       if(!vertex_array || !index_buffer)
+               throw invalid_operation("VertexSetup::bind");
+
        if(set_current(this))
        {
                glBindVertexArray(id);