]> git.tdb.fi Git - libs/gl.git/commitdiff
Require vertex arrays to have a buffer when adding them to VertexSetup
authorMikko Rasa <tdb@tdb.fi>
Tue, 29 Oct 2019 22:02:51 +0000 (00:02 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 29 Oct 2019 22:03:21 +0000 (00:03 +0200)
source/vertexsetup.cpp

index 2a3b2f1a7d920aa5a5a1200dd4df646ca1d195c6..7cfc1b6d99499c34ba3831f63495cc109921dba5 100644 (file)
@@ -11,6 +11,8 @@
 #include "vertexarray.h"
 #include "vertexsetup.h"
 
+using namespace std;
+
 namespace Msp {
 namespace GL {
 
@@ -36,6 +38,9 @@ VertexSetup::~VertexSetup()
 
 void VertexSetup::set_vertex_array(const VertexArray &a)
 {
+       if(!a.get_buffer())
+               throw invalid_argument("VertexSetup::set_vertex_array");
+
        vertex_array = &a;
        update(VERTEX_ARRAY);
 }
@@ -43,7 +48,12 @@ void VertexSetup::set_vertex_array(const VertexArray &a)
 void VertexSetup::set_instance_array(const VertexArray *a)
 {
        if(a)
+       {
+               if(!a->get_buffer())
+                       throw invalid_argument("VertexSetup::set_instance_array");
+
                static Require req(ARB_instanced_arrays);
+       }
 
        inst_array = a;
        update(INSTANCE_ARRAY);