glDrawElements causes an exception

-1

So I'm trying to render a quad with indexing, and I've got the data allocated, and all that stuff, but this draw call:

glBindVertexArray(vao);

glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);

glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT,  (void*) 0);

glDisableVertexAttribArray(2);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);

glBindVertexArray(0);

And more precisely, the glDrawElements drops an error. The argument (void*) 0 causes the error, the program says "Access violation reading location 0x00000000", which is understandable, cause I'm passing a nullptr, but in every tutorial and source code I've seen, this is written like this. If I pass in the memory address of the index buffer, it runs, but nothing is draw, and if I pass in the memory address of the first element of the indices array, the quad is drawn.

c++
opengl
nullptr
asked on Stack Overflow Feb 21, 2020 by Andrew • edited Feb 21, 2020 by genpfault

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0