title: Basic OpenGL (python)
body: <p>I'm looking into opengl and python and have created a basic program to draw a rectangle using two triangles.</p>
  
  <pre><code>def draw(self, shader):
      shader.bind()
      #glDrawArrays(GL_TRIANGLES, 1, 3)
      glDrawElements(GL_TRIANGLES,
                     len(self.indices),
                     GL_UNSIGNED_INT,
                     0)
      glBindVertexArray(0)
      shader.unbind()
  
  def _setupMesh(self):
      # VAO
      glGenVertexArrays(1, self._VAO)
      glBindVertexArray(self._VAO)
  
      #VBO
      glGenBuffers(1, self._VBO)
      glBindBuffer(GL_ARRAY_BUFFER, self._VBO)
      self.vertices_size = (GLfloat * len(self.vertices))(*self.vertices)
      glBufferData(GL_ARRAY_BUFFER,
                   len(self.vertices)*sizeof(GLfloat),
                   self.vertices_size,
                   GL_STATIC_DRAW)
  
  
      #EBO
      glGenBuffers(1, self._EBO)
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self._EBO)
      self.indices_size = (GLfloat * len(self.indices))(*self.indices)
      glBufferData(GL_ELEMENT_ARRAY_BUFFER,
                   len(self.indices)*sizeof(GLfloat),
                   self.indices_size,
                   GL_STATIC_DRAW)
  
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), c_void_p(0))
      glEnableVertexAttribArray(0)
  </code></pre>
  
  <p>I send in data as follows:</p>
  
  <pre><code>vertices: [  0.5,  0.5,  0.0,
           0.5, -0.5,  0.0,
          -0.5, -0.5,  0.0,
          -0.5,  0.5,  0.0] 
  indices: [0,1,3,1,2,3]
  </code></pre>
  
  <p>The <code>glDrawElements</code> call does nothing, <code>glDrawArrays</code> paints a nice triangle in the window.</p>
  
  <p>Somthing obvious I suspect why the <code>glDrawElements</code> doesn't work?</p>