diff --git a/J/basic.cpp b/J/basic.cpp index fd8f63f..e981861 100644 --- a/J/basic.cpp +++ b/J/basic.cpp @@ -7,6 +7,7 @@ // #include "basic.h" +#include namespace J { void check_error(){ diff --git a/J/shader.h b/J/shader.h index d34cf13..9f6ca94 100644 --- a/J/shader.h +++ b/J/shader.h @@ -105,10 +105,11 @@ public: // ***************** // attribute setters // NOTE: the normalized parameter is for integer types, if true they will be mapped to [0, 1], if false it stays in [0, 256] or so. - void set_attribute(const std::string& name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){ - const GLuint index = attributes[name]; - glVertexAttribPointer(index, size, type, normalized, stride, ptr); - glEnableVertexAttribArray(index); + void set_attribute(const std::string& name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) const { + auto it = attributes.find(name); + if(it == attributes.end()) throw std::runtime_error(name + " attribute could not be found"); + glVertexAttribPointer(it->second, size, type, normalized, stride, ptr); + glEnableVertexAttribArray(it->second); } // ***************