I`m trying to create opengl triangle and I bumped up with some problem.
EBO : ElementArrayBufferObject VAO : VertexArrayObject
While I'm trying to bind the EBO before binding the VAO it causes an error and I don't know why.
my code :
// Generate the VAO and VBO with only 1 object each
glGenVertexArrays(1, &VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
// Make the VAO the current Vertex Array Object by binding it
glBindVertexArray(VAO);
It causing problem while rendering.
and if i fix the code like this order.
// Generate the VAO and VBO with only 1 object each
glGenVertexArrays(1, &VAO);
// Make the VAO the current Vertex Array Object by binding it
glBindVertexArray(VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
it`s working as i expected.
I really don`t know why not working binding EBO before VAO.