title: Why wont glDrawElements render my triangles?
body: <p>i have been following the 3D game engine tutorial series by theBennyBox on youtube. the series is done in java and i like c++ because of computing speed reasons, i followed the tutorials all the way up to #15 where he starts using glDrawElements instead of glDrawArrays. up until now in the tutorials i have been fine converting his java code to c++ but now i can draw anything and opengl is giving me no errors. im almost sure that the problem is buffering the data for opengl or telling opengl how the data is buffered. here is my code.</p>
  
  <p>mainGame.cpp:</p>
  
  <p>init:</p>
  
  <pre><code>glClearColor(0.1f, 0.0f, 0.5f, 0.0f);
  glFrontFace(GL_CW);
  glCullFace(GL_BACK);
  glEnable(GL_CULL_FACE);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_FRAMEBUFFER_SRGB);
  
  vector&lt;Vertex&gt; vertices;
  vertices.push_back(glm::vec3(-1, 1, 0));
  vertices.push_back(glm::vec3(0, -0.5f, 0));
  vertices.push_back(glm::vec3(-1, -1, 0));
  vertices.push_back(glm::vec3(1, 1, 0));
  vertices.push_back(glm::vec3(1, -1, 0));
  vertices.push_back(glm::vec3(0, 0.5, 0));
  
  vector&lt;unsigned short&gt; indices;
  indices.push_back(0);
  indices.push_back(1);
  indices.push_back(2);
  indices.push_back(3);
  indices.push_back(4);
  indices.push_back(5);
  
  mesh.meshInit();
  mesh.addVerticies(vertices, indices);
  mesh.draw();
  </code></pre>
  
  <p>gameLoop: </p>
  
  <pre><code>    while (_gameState != GameState::EXIT) {
          processInput();
          updateScene();
          drawScene();
          if (_TEST)
          {
              GLenum err;
              while ((err = glGetError()) != GL_NO_ERROR) {
                  cout &lt;&lt; "OpenGL error: " &lt;&lt; err &lt;&lt; endl;
              }
          }
      }
  </code></pre>
  
  <p>processInput() currently affects nothing having to do with opengl drawing, and updateScene() only clears the screen, and updates a transformation object but this is not the problem. i know because i  tried commenting that section out and nothing is still rendered / drawn by opengl.</p>
  
  <p>drawScene: </p>
  
  <pre><code>shader.bind();
  shader.setUniform("translation", transform.getTransformation());
  mesh.draw();
  SDL_GL_SwapWindow(_window);
  </code></pre>
  
  <p>Here are the mesh class's functions that i believe i am not sending the correct information.</p>
  
  <p>mesh.cpp:</p>
  
  <pre><code>void Mesh::meshInit()
  {
      glGenVertexArrays(1, &amp;VAO);
      glBindVertexArray(VAO);
      glGenBuffers(1, &amp;IBO);
      glGenBuffers(1, &amp;VBO);
  }
  
  void Mesh::addVerticies(vector&lt;Vertex&gt; vertices, vector&lt;unsigned short&gt; indices)
  {
      _indices = &amp;indices[0];
  
      _vSize = vertices.size() * sizeof(float);
      _iSize = indices.size() * sizeof(unsigned short);
  
      if (_TEST) {
          cout &lt;&lt; "size of verticies: " &lt;&lt; _vSize &lt;&lt; endl;
          cout &lt;&lt; "size of indices: " &lt;&lt; _iSize &lt;&lt; endl;
          cout &lt;&lt; "number of verticies: " &lt;&lt; vertices.size() &lt;&lt; endl;
          cout &lt;&lt; "number of indices: " &lt;&lt; indices.size() &lt;&lt; endl;
          for (int i = 0; i &lt; vertices.size() ; i++)
          {
              cout &lt;&lt; vertices[i].getPos().x &lt;&lt; " ";
              cout &lt;&lt; vertices[i].getPos().y &lt;&lt; " ";
              cout &lt;&lt; vertices[i].getPos().z &lt;&lt; " ";
              cout &lt;&lt; "\n";
          }
      }    
  
      glBindBuffer(GL_ARRAY_BUFFER, VBO);
      glBufferData(GL_ARRAY_BUFFER, _vSize, &amp;vertices[0], GL_STATIC_DRAW);
  
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, _iSize, &amp;indices[0], GL_STATIC_DRAW);
  }
  
  int vertexAtribStride = Vertex::SIZE * sizeof(float);
  
  void Mesh::draw()
  {
      glBindBuffer(GL_ARRAY_BUFFER, VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, vertexAtribStride, 0);
      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
      glDrawElements(GL_TRIANGLES, _iSize, GL_INT, _indices);
      glDisableVertexAttribArray(0);
  }
  </code></pre>