From: Mikko Rasa Date: Tue, 29 Oct 2019 00:04:37 +0000 (+0200) Subject: Add sanity checks to bind functions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=67f22642d636861f90a016077c9387b7b8397414;p=libs%2Fgl.git Add sanity checks to bind functions --- diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index cf478ce2..f402b643 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -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); diff --git a/source/vertexsetup.cpp b/source/vertexsetup.cpp index 8465ab06..53f82569 100644 --- a/source/vertexsetup.cpp +++ b/source/vertexsetup.cpp @@ -6,6 +6,7 @@ #include #include #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);