My desired output of my program would be a simple quad being drawn onto the screen, instead nothing is being drawn on my screen. The relevant methods of my program are below.
What is wrong in my code causing this issue?
I'm trying to draw a quad on the screen using the glDrawElements method like this:
glDrawElements(GL_TRIANGLES, model.get_vertex_count(), GL_UNSIGNED_INT, 0)
To get the indices I've written this method:
@classmethod
def bind_indices_buffer(cls, indices: list[int]):
indices = numpy.array(indices, dtype=numpy.uint32) # convert the data into an unsigned integer array
vbo_id = glGenBuffers(1)
cls.__vbos.append(vbo_id)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_id)
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices, GL_STATIC_DRAW)
And for the vertices:
@classmethod
def store_data_in_attribute_list(cls, attribute_number: int, data: list[float]):
data = numpy.array(data, dtype='float32') # convert the data into a float32 array
vbo_id = glGenBuffers(1) # create 1 VBO buffer
cls.__vbos.append(vbo_id) # appends it to the VBO list in the class
glBindBuffer(GL_ARRAY_BUFFER, vbo_id) # binds the buffer to use it
glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW) # specifies the buffer, data and usage
glVertexAttribPointer(attribute_number, 3, GL_FLOAT, False, 0, None) # put the VBO into a VAO
glBindBuffer(GL_ARRAY_BUFFER, 0)
The type of the lase argument of glDrawElements
is const GLvoid *
. So the argument must be None
or ctypes.c_void_p(0)
, but not 0:
glDrawElements(GL_TRIANGLES, model.get_vertex_count(), GL_UNSIGNED_INT, 0)
glDrawElements(GL_TRIANGLES, model.get_vertex_count(), GL_UNSIGNED_INT, None)