title: OpenGL 4.5 Direct State Access Render a Triangle - GL_INVALID_VALUE
body: <h1>The Description</h1>
  
  <p>I'm currently learning OpenGL and want to try out the the direct state access extension from OpenGL 4.5. Thus I setup a simple triangle render example (in 3D) which should render my triangle. The code below is executed each frame and draws a triangle in 3D space.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>    void Geometry::draw(glm::vec3 pos, glm::vec3 pos1, glm::vec3 pos2) {
          float vertices[9] = {
              pos.x, pos.y, pos.z,
              pos1.x, pos1.y, pos1.z,
              pos2.x, pos2.y, pos2.z
          };
  
          unsigned int m_VaoID;
          glGenVertexArrays(1, &amp;m_VaoID);
          glBindVertexArray(m_VaoID);
  
          unsigned int m_VboID;
          glGenBuffers(1, &amp;m_VboID);
          glBindBuffer(GL_ARRAY_BUFFER, m_VboID);
          glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
  
          glEnableVertexAttribArray(0);
          glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 3, 0);
  
          Shader shader = Shader("../../shader.glsl");
          shader.compileShader();
          shader.useShader();
  
          glDrawArrays(GL_TRIANGLES, 0, 3);
  
          glBindVertexArray(0);
          glBindBuffer(GL_ARRAY_BUFFER, 0);
          glDeleteVertexArrays(1, &amp;m_VaoID);
          glDeleteBuffers(1, &amp;m_VboID);
      }
  </code></pre>
  
  <p>However, as soon as I change the code to make use of the direct state access extension, it no longer renders a triangle and instead produces error messages.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>    void Geometry::drawDSA(glm::vec3 pos, glm::vec3 pos1, glm::vec3 pos2) {
          float vertices[9] = {
              pos.x, pos.y, pos.z,
              pos1.x, pos1.y, pos1.z,
              pos2.x, pos2.y, pos2.z
          };
  
          unsigned int m_VaoID;
          glCreateVertexArrays(1, &amp;m_VaoID);
          glVertexArrayAttribFormat(m_VaoID, 0, 3, GL_FLOAT, GL_FALSE, 0);
  
          unsigned int m_VboID;
          glCreateBuffers(1, &amp;m_VboID);
          glNamedBufferData(m_VboID, sizeof(vertices), vertices, GL_STATIC_DRAW);
  
          glVertexArrayAttribBinding(m_VaoID, 0, m_VboID);
  
          Shader shader = Shader("../../shader.glsl");
          shader.compileShader();
          shader.useShader();
  
          glBindVertexArray(m_VaoID);
          glBindBuffer(GL_ARRAY_BUFFER, m_VboID);
  
          glDrawArrays(GL_TRIANGLES, 0, 3);
  
          glBindVertexArray(0);
          glBindBuffer(GL_ARRAY_BUFFER, 0);
          glDeleteVertexArrays(1, &amp;m_VaoID);
          glDeleteBuffers(1, &amp;m_VboID);
      }
  </code></pre>
  
  <p>Both methods get called in my <strong>update loop</strong> with the same values (between -1.f and 0.f).</p>
  
  <h1>The error output:</h1>
  
  <p>Here is the console output of the error I'm getting:</p>
  
  <pre><code>[OpenGL Debug HIGH] GL_INVALID_VALUE in glVertexArrayAttribBinding(bindingindex=16 &gt;= GL_MAX_VERTEX_ATTRIB_BINDINGS)
  [OpenGL Debug HIGH] GL_INVALID_VALUE in glVertexArrayAttribBinding(bindingindex=17 &gt;= GL_MAX_VERTEX_ATTRIB_BINDINGS)
  [OpenGL Debug HIGH] GL_INVALID_VALUE in glVertexArrayAttribBinding(bindingindex=18 &gt;= GL_MAX_VERTEX_ATTRIB_BINDINGS)
  [OpenGL Debug HIGH] GL_INVALID_VALUE in glVertexArrayAttribBinding(bindingindex=19 &gt;= GL_MAX_VERTEX_ATTRIB_BINDINGS)
  </code></pre>
  
  <h1>What I tried so far</h1>
  
  <p>I looked through the Khronos Wiki and through the docs.gl documentation, but I could not find out why my code produces the above error instead of rendering my triangle.</p>