pythonopenglglutpyopenglfreeglut

Is the last parameter of glVertexAttribPointer a '0' or 'None'?


I am trying to setup a simple 3D Engine in pyOpenGL. My current goal was to achieve a 2D rectangle being displayed to the screen, which isn't working at all. (nothing is being rendered to the screen, no exception is being thrown by the program.)

The render method I use is following:

 @staticmethod
    def render(model: RawModel):
        glBindVertexArray(model.get_vao_id())
        glEnableVertexAttribArray(0)
        glDrawArrays(GL_TRIANGLES, 1, model.get_vertex_count())
        glDisableVertexAttribArray(0)
        glBindVertexArray(0)

I suppose something goes wrong with the glDrawArrays() method, because of how I bound my Buffer data:

@classmethod
    def bind_indices_buffer(cls, attribute_number: int, data: list):
        data = numpy.array(data, dtype='float32')
        vbo_id = glGenBuffers(1)
        cls.__vbos.append(vbo_id)
        glBindBuffer(GL_ARRAY_BUFFER, vbo_id)
        glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW)
        glVertexAttribPointer(attribute_number, 3, GL_FLOAT, False, 0, 0)
        glBindBuffer(GL_ARRAY_BUFFER, 0)

Solution

  • The problem is here:

    glVertexAttribPointer(attribute_number, 3, GL_FLOAT, False, 0, 0)

    glVertexAttribPointer(attribute_number, 3, GL_FLOAT, False, 0, None)
    

    The type of the lase argument of glVertexAttribIPointer is const GLvoid *. So the argument must be None or ctypes.c_void_p(0), but not 0.