@@ -1751,6 +1751,54 @@ void GLShaderProgram::setAttribute(std::string name, const std::vector<uint32_t>
17511751 throw std::invalid_argument (" Tried to set nonexistent attribute with name " + name);
17521752}
17531753
1754+ void GLShaderProgram::setAttribute (std::string name, const std::vector<std::array<glm::vec3, 2 >>& data) {
1755+ glBindVertexArray (vaoHandle);
1756+
1757+ // pass-through to the buffer
1758+ for (GLShaderAttribute& a : attributes) {
1759+ if (a.name == name && a.location != -1 ) {
1760+ if (a.arrayCount != 2 ) throw std::invalid_argument (" Tried to set attribute " + name + " with wrong array count" );
1761+ ensureBufferExists (a);
1762+ a.buff ->setData (data);
1763+ return ;
1764+ }
1765+ }
1766+
1767+ throw std::invalid_argument (" Tried to set nonexistent attribute with name " + name);
1768+ }
1769+
1770+ void GLShaderProgram::setAttribute (std::string name, const std::vector<std::array<glm::vec3, 3 >>& data) {
1771+ glBindVertexArray (vaoHandle);
1772+
1773+ // pass-through to the buffer
1774+ for (GLShaderAttribute& a : attributes) {
1775+ if (a.name == name && a.location != -1 ) {
1776+ if (a.arrayCount != 3 ) throw std::invalid_argument (" Tried to set attribute " + name + " with wrong array count" );
1777+ ensureBufferExists (a);
1778+ a.buff ->setData (data);
1779+ return ;
1780+ }
1781+ }
1782+
1783+ throw std::invalid_argument (" Tried to set nonexistent attribute with name " + name);
1784+ }
1785+
1786+ void GLShaderProgram::setAttribute (std::string name, const std::vector<std::array<glm::vec3, 4 >>& data) {
1787+ glBindVertexArray (vaoHandle);
1788+
1789+ // pass-through to the buffer
1790+ for (GLShaderAttribute& a : attributes) {
1791+ if (a.name == name && a.location != -1 ) {
1792+ if (a.arrayCount != 4 ) throw std::invalid_argument (" Tried to set attribute " + name + " with wrong array count" );
1793+ ensureBufferExists (a);
1794+ a.buff ->setData (data);
1795+ return ;
1796+ }
1797+ }
1798+
1799+ throw std::invalid_argument (" Tried to set nonexistent attribute with name " + name);
1800+ }
1801+
17541802bool GLShaderProgram::hasTexture (std::string name) {
17551803 for (GLShaderTexture& t : textures) {
17561804 if (t.name == name && t.location != -1 ) {
0 commit comments