From 67f22642d636861f90a016077c9387b7b8397414 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 29 Oct 2019 02:04:37 +0200 Subject: [PATCH] Add sanity checks to bind functions --- source/framebuffer.cpp | 3 +++ source/vertexsetup.cpp | 4 ++++ 2 files changed, 7 insertions(+) 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); -- 2.45.2