[ad_1]
So I was watching Cherno’s Video on Vertex attributes and he was successful in drawing a triangle without a VAO, but in tutorials from learnopengl.com they specifically say they we need a VAO to draw VBO and I tested it and it works fine.
Here is my snippet :
//==============================================================================
// glGenVertexArrays(1, &VAO);
// glBindVertexArray(VAO);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(triangleVertices), triangleVertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
//-----------------------------------------------------------------------------
// Game Loop
//-----------------------------------------------------------------------------
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Poll for and process events */
glfwPollEvents();
/* Render here */
glClearColor(0.2f, 0.3f, 0.3f, 1.0f); // RGBA
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(shaderProgram);
// glBindVertexArray(VAO);// we did not unbind it so it's still binded to the assigned VAO
glDrawArrays(GL_TRIANGLES, 0, 3);
/* Swap front and back buffers */
glfwSwapBuffers(window);
}
//-----------------------------------------------------------------------------
This only works if I uncomment the VAO which is understandable, what I can’t get my head around is how did Cherno got it working without a VAO and just using a VBO? Is it a MacOS specific thing?
[ad_2]