In a tutorial about OpenGL 3.0+, we create a Vertex Array Object and Vertex Buffer Object this way:
GLuint VAO, VBO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
Here, VAO is an unsigned int
(GLuint
) and we pass a̶ ̶r̶e̶f̶e̶r̶e̶n̶c̶e̶ its address to it in the function glGenVertexArray
. However, according to the documentation, the second argument of the function should be an array of unsigned int
(GLuint*
). Same goes for VBO and glGenBuffers
. I don't understand why the above code works with such arguments.
I've tried to replace the above code by this one (and do the necessary modifications elsewhere in my code) :
GLuint VAO[1];
GLuint VBO[1];
glGenVertexArrays(1, VAO);
glGenBuffers(1, VBO);
glBindVertexArray(VAO[1]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[1]);
It compiles and executes, but I get an unexpected behaviour : my textured rectangle renders with the first syntax but not with the second one. I don't understand why this happens as well.
EDIT : Thank you. As stated, there is an indexing mistake in the second code.