Home Game Development opengl – Cannot Draw a triangle without VAO on MacOS

opengl – Cannot Draw a triangle without VAO on MacOS

0
opengl – Cannot Draw a triangle without VAO on MacOS

[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.enter image description here
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]

Previous article Wikipedia reveals its most viewed articles of 2023
Next article The best origins in Warhammer 40K Rogue Trader
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!