[ad_1]

So I used to be watching Cherno’s Video on Vertex attributes and he was profitable in drawing a triangle with no VAO, however in tutorials from learnopengl.com they particularly say they we want a VAO to attract VBO and I examined it and it really works high quality.enter image description here
Right 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);

//-----------------------------------------------------------------------------
// Sport Loop
//-----------------------------------------------------------------------------
/* Loop till the person closes the window */
whereas (!glfwWindowShouldClose(window))
{
    /* Ballot for and course of occasions */
    glfwPollEvents();

    /* Render right here */
    glClearColor(0.2f, 0.3f, 0.3f, 1.0f);   // RGBA
    glClear(GL_COLOR_BUFFER_BIT);

    glUseProgram(shaderProgram);
    // glBindVertexArray(VAO);// we didn't unbind it so it is nonetheless binded to the assigned      VAO
    glDrawArrays(GL_TRIANGLES, 0, 3);


    /* Swap back and front buffers */
    glfwSwapBuffers(window);
}
//-----------------------------------------------------------------------------

This solely works if I uncomment the VAO which is comprehensible, what I can not get my head round is how did Cherno received it working with no VAO and simply utilizing a VBO? Is it a MacOS particular factor?

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *